/
fabfile.py
49 lines (40 loc) · 1.72 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
from calendar import timegm
from time import gmtime
from fabric.api import *
from hosts import hosts, secret
env.password = secret
env.hosts = hosts
domain_dir = "/a/mattdeboard.net/"
appdir = domain_dir + "src/yukproj/"
whoosh_dir = appdir + "yuk/whoosh/"
# directory where git puts the css files on git pull
css_dir = appdir + "yuk/static/css/blueprint/"
# where nginx looks for static files
static_file_dir = domain_dir + "root/yukmarks/css/blueprint/"
pg_dump_dir = domain_dir + "pg_dumps/"
def run_all():
git_pull()
dump_data()
pg_dump()
def git_pull():
run("cd %s; . bin/activate; cd %s; git pull; ./manage.py schemamigration"
" --auto yuk; ./manage.py migrate yuk;cp %s* %s;sudo /etc/init.d/apache2"
" force-reload" % (domain_dir, appdir, css_dir, static_file_dir))
def pg_dump():
timestamp = timegm(gmtime())
run("cd %s; . bin/activate; cd %s; pg_dump -f %spg_dump_%s.sql pg_links" %
(domain_dir, appdir, pg_dump_dir, timestamp))
def dump_data():
timestamp = timegm(gmtime())
run("cd %s; . bin/activate; cd %s; ./manage.py dumpdata --format=json yuk"
" >> /a/mattdeboard.net/yuk_data_dumps/dump_%s.json" %
(domain_dir, appdir, timestamp))
def update_search():
run("sudo -u www-data /a/mattdeboard.net/bin/python %smanage.py update_inde"
"x; sudo /etc/init.d/apache2 force-reload" % appdir)
def rebuild_search():
run("cd %s; . bin/activate; cd %s; sudo chown matt:matt %s; sudo chown matt"
":matt %s*; ./manage.py rebuild_index; sudo chown www-data:www-data %s;"
" sudo chown www-data:www-data %s*; sudo /etc/init.d/apache2 force-relo"
"ad" % (domain_dir, appdir, whoosh_dir,
whoosh_dir, whoosh_dir, whoosh_dir))