-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfabfile.py
52 lines (42 loc) · 1.13 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
from fabric.api import run, env, task, local, put, cd, sudo
from datetime import datetime
env.host_string = 'xsh.gxun.edu.cn:443'
now = datetime.now().strftime('%Y-%m-%d.%H-%M-%S')
_source_list = [
'extensions/',
'libs/AmsProxy/',
'models/',
'modules/',
'public/',
]
_source_vendor_list = [
'libs/Requests/',
'libs/SimplePie/',
'libs/yii/',
]
def _create_source():
local('7z a amsproxy.7z ' + ' '.join(_source_list))
def _create_vendor():
local('7z a vendor.7z ' + ' '.join(_source_vendor_list))
@task
def backup_db():
with cd('/var/www/AmsProxy'):
run('scp data/amsProxy.db 210.36.79.100:/var/xsh_backups/amsproxy/amsProxy.' + now + '.db')
@task(default=True)
def deploy():
_create_source()
with cd('/var/www/AmsProxy'):
run('rm -rf ' + ' '.join(_source_list))
put('amsproxy.7z', 'amsproxy.7z')
run('7z x amsproxy.7z')
run('rm amsproxy.7z')
local('rm amsproxy.7z')
@task
def deploy_vendor():
_create_vendor()
with cd('/var/www/AmsProxy'):
run('rm -rf ' + ' '.join(_source_vendor_list))
put('vendor.7z', 'vendor.7z')
run('7z x vendor.7z')
run('rm vendor.7z')
local('rm vendor.7z')