/
fabfile.py
75 lines (65 loc) · 2.36 KB
/
fabfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
from fabric.api import *
from fabric.colors import green, red
from fabric.contrib.project import rsync_project
from config import servers # A dictonary with all your enviornments
def set_environment(environment = False):
if environment == False:
print "You must specify and environment to push"
else:
env = servers[environment]
return env
def deploy(environment = False):
"""This pushes to your environment"""
environment = set_environment(environment)
__deploy__(environment)
def __deploy__(environment):
env.host_string = environment.host_string
env.user = environment.user
env.password = environment.password
with cd(environment.main_path):
run('pwd')
run('git stash')
run('git fetch --all')
run('git reset --hard origin/master')
run('composer update')
run('composer install')
run('service apache2 restart')
with cd(environment.theme_path):
run('npm install')
run('bower install --allow-root')
run('grunt production')
def restart_mysql(environment = False):
"""This pushes to your environment"""
environment = set_environment(environment)
__restart_mysql__(environment)
def __restart_mysql__(environment):
# https://www.digitalocean.com/community/articles/how-to-add-swap-on-ubuntu-12-04
"""Restart Mysql"""
env.host_string = environment.host_string
env.user = environment.user
env.password = environment.password
with cd('/'):
run('/etc/init.d/mysql restart')
def install_dependencies():
environment = set_environment(environment)
__install_dependencies__(environment)
def __install_dependencies__():
"""Install Nodejs"""
env.host_string = environment.host_string
env.user = environment.user
env.password = environment.password
with cd('/'):
sudo('apt-get install python-software-properties')
sudo('apt-add-repository ppa:chris-lea/node.js')
sudo('apt-get update')
sudo('apt-get install nodejs')
sudo('apt-get install git') # you have to config your username and email afterwards
sudo('apt-get install php5-json')
sudo('apt-get install libmagickwand-dev imagemagick')
run('npm install -g grunt-cli bower')
run('curl -sS https://getcomposer.org/installer | php')
run('mv composer.phar /usr/local/bin/composer')
with cd('var/www/adelleninja.com/public_html/'):
run('git clone git@github.com:thejsj/Adelle.git')
with cd('var/www/staging.adelleninja.com/public_html/'):
run('git clone git@github.com:thejsj/Adelle.git')