Skip to content

Instantly share code, notes, and snippets.

Created August 30, 2010 17:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2b6c811432c8c736ad3f to your computer and use it in GitHub Desktop.
Save anonymous/2b6c811432c8c736ad3f to your computer and use it in GitHub Desktop.
from fabric.api import *
env.key_filename = ['/home/joel/.ssh/sahana_release']
'''Definitions for 'Test' infrastructure'''
def test():
env.user = 'root'
env.hosts = ['release-test']
'''Definitions for 'Production' infrastructure'''
def production():
env.user = 'root'
env.hosts = ['release-test']
'''Key distribution and management'''
def generate_keys():
local('ssh-keygen -N "" -q -t rsa -f ~/.ssh/sahana_release')
def distribute_keys():
local('ssh-copy-id -i ~/.ssh/sahana_release.pub %s@%s' % (env.user, env.host))
'''Deployment, Maintenance and Migrations'''
def deploy():
with cd('/home/web2py/applications/eden/'):
maintenance_on()
migrate_on()
run('bzr pull',pty=True)
run('chown web2py:web2py ~web2py/applications/eden/languages/*',pty=True)
migrate_off()
maintenance_off()
def maintenance_on():
run('a2dissite %s' % env.host,pty=True)
run('a2ensite maintenance',pty=True)
reload()
def maintenance_off():
run('a2dissite maintenance',pty=True)
run('a2ensite %s' % env.host,pty=True)
reload()
def migrate_on():
"Enabling migrations"
with cd('/home/web2py/applications/eden'):
run('sed -i "s/deployment_settings.base.migrate = False/deployment_settings.base.migrate = True/g" models/000_config.py',pty=True)
def migrate_off():
"Disabling migrations"
with cd('/home/web2py/applications/eden'):
run('sed -i "s/deployment_settings.base.migrate = True/deployment_settings.base.migrate = False/g" models/000_config.py',pty=True)
def reload():
run('apache2ctl restart',pty=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment