This repository has been archived by the owner on Nov 10, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathfabfile.py
executable file
·68 lines (49 loc) · 1.81 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date : 2016-03-14 15:58:57
# @Author : Linsir ([email protected])
# @Link : http://linsir.org
# @Version :
import os
# from fabric.api import local,cd,run,env,put
from fabric.colors import *
from fabric.api import *
import paramiko
paramiko.util.log_to_file('/tmp/paramiko.log')
# 2. using sshd_config
env.hosts = [
'master',# master
]
env.use_ssh_config = True
prefix = '/usr/local/openresty/'
def local_update():
print(yellow("copy ngx-lua-images and configure..."))
# run('sudo rm -rf /usr/local/openresty/ngx-lua-images/')
# put('ngx-lua-images', '/usr/local/openresty/')
if os.path.exists("%sngx-lua-images/" %prefix):
local("sudo rm -rf %sngx-lua-images/" %prefix)
local("sudo cp -r ngx-lua-images %s" %prefix)
if os.path.exists("%snginx/conf/conf.d/ngx-lua-images.conf" %prefix):
local("sudo rm -rf %snginx/conf/conf.d/ngx-lua-images.conf" %prefix)
local("sudo ln -s %sngx-lua-images/ngx-lua-images.conf %snginx/conf/conf.d/ngx-lua-images.conf" %(prefix, prefix))
restart()
def remote_update():
print(yellow("copy ngx-lua-images and configure..."))
run('sudo rm -rf /usr/local/openresty/ngx-lua-images/')
put('ngx-lua-images', '/usr/local/openresty/')
with cd('/usr/local/openresty/nginx/conf/conf.d/'):
if not os.path.exists("%snginx/conf/conf.d/ngx-lua-images.conf" %prefix):
run('sudo ln -s /usr/local/openresty/ngx-lua-images/ngx-lua-images.conf ngx-lua-images.conf')
print(green("nginx restarting..."))
run('/etc/init.d/nginx restart')
def restart():
print(green("nginx restarting..."))
local('sudo systemctl restart nginx')
def update():
# local update
local_update()
# remote update
# remote_update()
pass
if __name__ == '__main__':
pass