in infrastructure-provisioning/src/general/lib/os/fab.py [0:0]
def install_ungit(os_user, notebook_name, edge_ip):
if not exists(conn, '/home/{}/.ensure_dir/ungit_ensured'.format(os_user)):
try:
manage_npm_pkg('npm -g install ungit@{}'.format(os.environ['notebook_ungit_version']))
if os.environ['conf_deeplearning_cloud_ami'] =='true' and os.environ['conf_cloud_provider'] =='azure' and os.environ['application'] =='deeplearning':
conn.put('/root/templates/ungit.service.18_04', '/tmp/ungit.service')
else:
conn.put('/root/templates/ungit.service', '/tmp/ungit.service')
conn.sudo("sed -i 's|OS_USR|{}|' /tmp/ungit.service".format(os_user))
http_proxy = conn.run('''bash -l -c 'echo $http_proxy' ''').stdout.replace('\n', '')
conn.sudo("sed -i 's|PROXY_HOST|{}|g' /tmp/ungit.service".format(http_proxy))
conn.sudo("sed -i 's|NOTEBOOK_NAME|{}|' /tmp/ungit.service".format(
notebook_name))
conn.sudo("mv -f /tmp/ungit.service /etc/systemd/system/ungit.service")
conn.run('git config --global user.name "Example User"')
conn.run('git config --global user.email "example@example.com"')
conn.run('mkdir -p ~/.git/templates/hooks')
conn.put('/root/scripts/git_pre_commit.py', '/home/{}/.git/templates/hooks/pre-commit'.format(os_user))
conn.sudo('chmod 755 ~/.git/templates/hooks/pre-commit')
conn.run('git config --global init.templatedir ~/.git/templates')
conn.run('touch ~/.gitignore')
conn.run('git config --global core.excludesfile ~/.gitignore')
conn.run('echo ".ipynb_checkpoints/" >> ~/.gitignore')
conn.run('echo "spark-warehouse/" >> ~/.gitignore')
conn.run('echo "metastore_db/" >> ~/.gitignore')
conn.run('echo "derby.log" >> ~/.gitignore')
conn.sudo(
'''bash -l -c 'echo -e "Host git.epam.com\n HostName git.epam.com\n ProxyCommand nc -X connect -x {}:3128 %h %p\n" > /home/{}/.ssh/config' '''.format(
edge_ip, os_user))
conn.sudo(
'''bash -l -c 'echo -e "Host github.com\n HostName github.com\n ProxyCommand nc -X connect -x {}:3128 %h %p" >> /home/{}/.ssh/config' '''.format(
edge_ip, os_user))
conn.sudo(
'''bash -l -c 'echo -e "Host gitlab.com\n HostName gitlab.com\n ProxyCommand nc -X connect -x {}:3128 %h %p" >> /home/{}/.ssh/config' '''.format(
edge_ip, os_user))
conn.sudo('systemctl daemon-reload')
conn.sudo('systemctl enable ungit.service')
conn.sudo('systemctl start ungit.service')
conn.sudo('touch /home/{}/.ensure_dir/ungit_ensured'.format(os_user))
except Exception as err:
logging.error('Function install_ungit error:', str(err))
traceback.print_exc()
sys.exit(1)
else:
try:
conn.sudo("sed -i 's|--rootPath=/.*-ungit|--rootPath=/{}-ungit|' /etc/systemd/system/ungit.service".format(
notebook_name))
http_proxy = conn.run('''bash -l -c 'echo $http_proxy' ''').stdout.replace('\n', '')
conn.sudo(
"sed -i 's|HTTPS_PROXY=.*3128|HTTPS_PROXY={}|g' /etc/systemd/system/ungit.service".format(http_proxy))
conn.sudo(
"sed -i 's|HTTP_PROXY=.*3128|HTTP_PROXY={}|g' /etc/systemd/system/ungit.service".format(http_proxy))
conn.sudo('systemctl daemon-reload')
conn.sudo('systemctl restart ungit.service')
except Exception as err:
logging.error('Function install_ungit error:', str(err))
traceback.print_exc()
sys.exit(1)
try:
conn.run('''bash -l -c 'git config --global http.proxy $http_proxy' ''')
conn.run('''bash -l -c 'git config --global https.proxy $https_proxy' ''')
except Exception as err:
logging.error('Function install_ungit error:', str(err))
traceback.print_exc()
sys.exit(1)