Update firewall_api.py

pull/267/head
midoks 3 years ago
parent 7577776214
commit 46ec61d915
  1. 13
      class/core/firewall_api.py

@ -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, '操作成功!')

Loading…
Cancel
Save