|
|
@ -5,6 +5,7 @@ import io |
|
|
|
import os |
|
|
|
import os |
|
|
|
import time |
|
|
|
import time |
|
|
|
import subprocess |
|
|
|
import subprocess |
|
|
|
|
|
|
|
import re |
|
|
|
|
|
|
|
|
|
|
|
sys.path.append(os.getcwd() + "/class/core") |
|
|
|
sys.path.append(os.getcwd() + "/class/core") |
|
|
|
import public |
|
|
|
import public |
|
|
@ -103,10 +104,30 @@ def status(): |
|
|
|
return 'start' |
|
|
|
return 'start' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def getDataDir(): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
file = getConf() |
|
|
|
|
|
|
|
content = public.readFile(file) |
|
|
|
|
|
|
|
rep = 'datadir\s*=\s*(.*)' |
|
|
|
|
|
|
|
tmp = re.search(rep, content) |
|
|
|
|
|
|
|
return tmp.groups()[0].strip() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def initMysqlData(): |
|
|
|
|
|
|
|
datadir = getDataDir() |
|
|
|
|
|
|
|
serverdir = getServerDir() |
|
|
|
|
|
|
|
if not os.path.exists(datadir + '/mysql'): |
|
|
|
|
|
|
|
cmd = 'cd ' + serverdir + ' && ./scripts/mysql_install_db --user=midoks --basedir=' + \ |
|
|
|
|
|
|
|
serverdir + ' --ldata=' + datadir |
|
|
|
|
|
|
|
public.execShell(cmd) |
|
|
|
|
|
|
|
return True |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def myOp(method): |
|
|
|
def myOp(method): |
|
|
|
init_file = initDreplace() |
|
|
|
init_file = initDreplace() |
|
|
|
cmd = init_file + ' ' + method |
|
|
|
cmd = init_file + ' ' + method |
|
|
|
if method == 'start': |
|
|
|
if method == 'start': |
|
|
|
|
|
|
|
initMysqlData() |
|
|
|
subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True, |
|
|
|
subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True, |
|
|
|
bufsize=4096, stderr=subprocess.PIPE) |
|
|
|
bufsize=4096, stderr=subprocess.PIPE) |
|
|
|
return 'ok' |
|
|
|
return 'ok' |
|
|
@ -166,6 +187,9 @@ def initdUinstall(): |
|
|
|
return 'ok' |
|
|
|
return 'ok' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def getShowLog(): |
|
|
|
|
|
|
|
return 'ok' |
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
|
if __name__ == "__main__": |
|
|
|
func = sys.argv[1] |
|
|
|
func = sys.argv[1] |
|
|
|
if func == 'status': |
|
|
|
if func == 'status': |
|
|
@ -188,5 +212,7 @@ if __name__ == "__main__": |
|
|
|
print runInfo() |
|
|
|
print runInfo() |
|
|
|
elif func == 'conf': |
|
|
|
elif func == 'conf': |
|
|
|
print getConf() |
|
|
|
print getConf() |
|
|
|
|
|
|
|
elif func == 'show_log': |
|
|
|
|
|
|
|
print getShowLog() |
|
|
|
else: |
|
|
|
else: |
|
|
|
print 'error' |
|
|
|
print 'error' |
|
|
|