def _setup_repo(repo_dir): from fabricghdeploykeys.fabric_commands.permissions import make_directory make_directory(WEBADMIN_GROUP, repo_dir) if not exists('{0}/.git'.format(repo_dir)): from fabricghdeploykeys.fabric_commands.git import clone from fabricghdeploykeys.fabric_commands.ssh_key import create_key from fabricghdeploykeys.oauth_flow import verify_access_token from fabricghdeploykeys.repo_keys import add_repo_key if not verify_access_token(): raise Exception('Unable to access GitHub account') create_key(REPO_FULL_NAME, WEBADMIN_GROUP) add_repo_key(REPO_FULL_NAME) clone(REPO_FULL_NAME, repo_dir)
def setup_server(setup_wins=''): from fabricghdeploykeys.fabric_commands.permissions import make_directory base_packages = [ 'git', 'python3-venv', 'postgresql', 'python3-psycopg2', 'nginx', 'uwsgi', 'uwsgi-plugin-python3', ] _install_packages(base_packages) if setup_wins: _setup_wins() sudo('mkdir -p /etc/nginx/ssl') make_directory(WEBADMIN_GROUP, '/var/www') make_directory(WEBADMIN_GROUP, '/var/www/python') with settings(abort_exception=AllowedException): try: run('createuser -s root') except AllowedException: pass make_directory('root', '/var/uwsgi', '777') default_site = '/etc/nginx/sites-enabled/default' if exists(default_site): sudo('rm {0}'.format(default_site)) sudo('/etc/init.d/nginx start')