mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-18 23:45:52 +08:00
Update firewall_api.py
This commit is contained in:
@@ -271,20 +271,21 @@ class firewall_api:
|
|||||||
return mw.returnJson(True, '开发机不能操作!')
|
return mw.returnJson(True, '开发机不能操作!')
|
||||||
|
|
||||||
status = request.form.get('status', '1').strip()
|
status = request.form.get('status', '1').strip()
|
||||||
version = mw.readFile('/etc/redhat-release')
|
if status == "1":
|
||||||
if int(status) == 1:
|
|
||||||
msg = 'SSH服务已停用'
|
msg = 'SSH服务已停用'
|
||||||
act = 'stop'
|
act = 'stop'
|
||||||
else:
|
else:
|
||||||
msg = 'SSH服务已启用'
|
msg = 'SSH服务已启用'
|
||||||
act = 'start'
|
act = 'start'
|
||||||
|
|
||||||
if not os.path.exists('/etc/redhat-release'):
|
ssh_service = get.systemdCfgDir() + '/sshd.service'
|
||||||
mw.execShell('service ssh ' + act)
|
if os.path.exists(ssh_service):
|
||||||
elif version.find(' 7.') != -1:
|
|
||||||
mw.execShell("systemctl " + act + " sshd.service")
|
mw.execShell("systemctl " + act + " sshd.service")
|
||||||
else:
|
else:
|
||||||
mw.execShell("/etc/init.d/sshd " + act)
|
mw.execShell('service sshd ' + act)
|
||||||
|
|
||||||
|
if os.path.exists('/etc/init.d/sshd'):
|
||||||
|
mw.execShell('/etc/init.d/sshd ' + act)
|
||||||
|
|
||||||
mw.writeLog("防火墙管理", msg)
|
mw.writeLog("防火墙管理", msg)
|
||||||
return mw.returnJson(True, '操作成功!')
|
return mw.returnJson(True, '操作成功!')
|
||||||
|
|||||||
Reference in New Issue
Block a user