forked from keminar/pacfab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fabfile.py
executable file
·79 lines (70 loc) · 2.74 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
76
77
78
79
# encoding: utf-8
import os
import sys
import conf
import core.utils as cu
from fabric.api import *
from fabric.colors import green
@parallel
def install(name = ""):
if (name != ""):
initClass = cu.utils().initClass(name)
# check
func = getattr(initClass, 'check')
code = func()
if (code == "0"):
if (name == "init"):
lock = '/var/log/.install.log'
else:
lock = conf.INSTALL_DIR + '/opt/' + name + '/.install.log'
print(green('[' + env.host + '] \"' + name + '\" has been installed, reinstall please remove ' + lock))
return
# require
func = getattr(initClass, 'require')
require = func()
for r in require.split(","):
if (r != ""):
install(r)
# install
func = getattr(initClass, 'install')
Code = func()
else:
help()
@parallel
def instance(name = "", port = ""):
if (name != "" and port !=""):
initClass = cu.utils().initClass(name)
# instance
func = getattr(initClass, 'instance')
code = func(port)
else:
help()
# 用户帮助提示参数
def help():
paramMap = {
"int" : "Int system",
"git" : "Git is a free and open source distributed version control system",
"screen" : "Screen is a full-screen window manager that multiplexes a physical terminal between several processes",
"vim" : "Vim is a highly configurable text editor built to enable efficient text editing",
"anmp" : "apache nginx mysql php",
"apache" : "The Apache HTTP Server Project is an effort to develop and maintain an open-source HTTP server",
"nginx" : "nginx [engine x] is an HTTP and reverse proxy server",
"mysql" : "The world's most popular open source database",
"php" : "PHP is a popular general-purpose scripting language",
"apr" : "Apache Portable Runtime (APR) project",
"cmake" : "CMake is a family of tools designed to build, test and package software. ",
"iconv" : "iconv is a computer program used to convert between different character encodings",
"mcrypt" : "mcrypt, and the accompanying libmcrypt, are intended to be replacements for the old Unix crypt",
"mhash" : "Libmhash is a library that provides a uniform interface to several hash algorithms.",
"openssl": "The OpenSSL Project is a collaborative effort to develop a general purpose cryptography library.",
"pcre" : "The PCRE library is a set of functions that implement regular expression pattern",
"redis" : "Redis is an open source, BSD licensed, advanced key-value store.",
}
print("Usage: ./local.sh [option] install:name=[name]")
print("Usage: ./local.sh [option] instance:name=[name],port=[port]")
print("install:")
for soft in paramMap:
print("\t%-16s[%s]" % (soft, paramMap[soft]))
print("instance:")
print("\t%-16s[%s]" % ('mysql', paramMap['mysql']))
print("\t%-16s[%s]" % ('redis', paramMap['redis']))