|
|
|
@ -58,25 +58,25 @@ def doContentReplace(src, dst): |
|
|
|
|
def initInitD(): |
|
|
|
|
|
|
|
|
|
# systemctl |
|
|
|
|
sysCfgDir = mw.systemdCfgDir() |
|
|
|
|
if os.path.exists(sysCfgDir) and mw.getOsName() == 'centos' and mw.getOsID() == '9': |
|
|
|
|
systemd_mw = sysCfgDir + '/mw.service' |
|
|
|
|
systemd_mw_task = sysCfgDir + '/mw-task.service' |
|
|
|
|
# sysCfgDir = mw.systemdCfgDir() |
|
|
|
|
# if os.path.exists(sysCfgDir) and mw.getOsName() == 'centos' and mw.getOsID() == '9': |
|
|
|
|
# systemd_mw = sysCfgDir + '/mw.service' |
|
|
|
|
# systemd_mw_task = sysCfgDir + '/mw-task.service' |
|
|
|
|
|
|
|
|
|
systemd_mw_tpl = mw.getRunDir() + '/scripts/init.d/mw.service.tpl' |
|
|
|
|
systemd_mw_task_tpl = mw.getRunDir() + '/scripts/init.d/mw-task.service.tpl' |
|
|
|
|
# systemd_mw_tpl = mw.getRunDir() + '/scripts/init.d/mw.service.tpl' |
|
|
|
|
# systemd_mw_task_tpl = mw.getRunDir() + '/scripts/init.d/mw-task.service.tpl' |
|
|
|
|
|
|
|
|
|
if os.path.exists(systemd_mw): |
|
|
|
|
os.remove(systemd_mw) |
|
|
|
|
if os.path.exists(systemd_mw_task): |
|
|
|
|
os.remove(systemd_mw_task) |
|
|
|
|
# if os.path.exists(systemd_mw): |
|
|
|
|
# os.remove(systemd_mw) |
|
|
|
|
# if os.path.exists(systemd_mw_task): |
|
|
|
|
# os.remove(systemd_mw_task) |
|
|
|
|
|
|
|
|
|
doContentReplace(systemd_mw_tpl, systemd_mw) |
|
|
|
|
doContentReplace(systemd_mw_task_tpl, systemd_mw_task) |
|
|
|
|
# doContentReplace(systemd_mw_tpl, systemd_mw) |
|
|
|
|
# doContentReplace(systemd_mw_task_tpl, systemd_mw_task) |
|
|
|
|
|
|
|
|
|
mw.execShell('systemctl enable mw') |
|
|
|
|
mw.execShell('systemctl enable mw-task') |
|
|
|
|
mw.execShell('systemctl daemon-reload') |
|
|
|
|
# mw.execShell('systemctl enable mw') |
|
|
|
|
# mw.execShell('systemctl enable mw-task') |
|
|
|
|
# mw.execShell('systemctl daemon-reload') |
|
|
|
|
|
|
|
|
|
script = mw.getRunDir() + '/scripts/init.d/mw.tpl' |
|
|
|
|
script_bin = mw.getRunDir() + '/scripts/init.d/mw' |
|
|
|
@ -84,12 +84,12 @@ def initInitD(): |
|
|
|
|
mw.execShell('chmod +x ' + script_bin) |
|
|
|
|
|
|
|
|
|
# 在linux系统中,确保/etc/init.d存在 |
|
|
|
|
if not mw.isAppleSystem() and not os.path.exists("/etc/init.d"): |
|
|
|
|
mw.execShell('mkdir -p /etc/init.d') |
|
|
|
|
if not mw.isAppleSystem() and not os.path.exists("/etc/rc.d/init.d"): |
|
|
|
|
mw.execShell('mkdir -p /etc/rc.d/init.d') |
|
|
|
|
|
|
|
|
|
# initd |
|
|
|
|
if os.path.exists('/etc/init.d'): |
|
|
|
|
initd_bin = '/etc/init.d/mw' |
|
|
|
|
if os.path.exists('/etc/rc.d/init.d'): |
|
|
|
|
initd_bin = '/etc/rc.d/init.d/mw' |
|
|
|
|
if not os.path.exists(initd_bin): |
|
|
|
|
import shutil |
|
|
|
|
shutil.copyfile(script_bin, initd_bin) |
|
|
|
|