diff options
author | Stan <stangri@melmac.net> | 2020-09-21 11:41:40 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-21 11:41:40 -0700 |
commit | 3348009c7054dd97fbabe27daa1f1cb8b783e5b7 (patch) | |
tree | a5801e80b8f9c15f48ae0c4f271863fa55facb76 /applications/luci-app-vpnbypass/luasrc/controller/vpnbypass.lua | |
parent | 482e367e022bf4de8dbe866661d2220de1f2a28c (diff) | |
parent | 053e3952f02319ae5e0d8668cf67ce8c4a8c7f6d (diff) |
Merge pull request #4457 from stangri/master-luci-app-vpnbypass
luci-app-vpnbypass: ACL-related update
Diffstat (limited to 'applications/luci-app-vpnbypass/luasrc/controller/vpnbypass.lua')
-rw-r--r-- | applications/luci-app-vpnbypass/luasrc/controller/vpnbypass.lua | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/applications/luci-app-vpnbypass/luasrc/controller/vpnbypass.lua b/applications/luci-app-vpnbypass/luasrc/controller/vpnbypass.lua index 0de6ff6481..057aee787f 100644 --- a/applications/luci-app-vpnbypass/luasrc/controller/vpnbypass.lua +++ b/applications/luci-app-vpnbypass/luasrc/controller/vpnbypass.lua @@ -3,26 +3,32 @@ function index() if nixio.fs.access("/etc/config/vpnbypass") then local e = entry({"admin", "vpn"}, firstchild(), _("VPN"), 60) e.dependent = false - - entry({"admin", "vpn", "vpnbypass"}, cbi("vpnbypass"), _("VPN Bypass")).acl_depends = { "luci-app-vpnbypass" } + e.acl_depends = { "luci-app-vpnbypass" } + entry({"admin", "vpn", "vpnbypass"}, cbi("vpnbypass"), _("VPN Bypass")) entry({"admin", "vpn", "vpnbypass", "action"}, call("vpnbypass_action"), nil).leaf = true end end function vpnbypass_action(name) local packageName = "vpnbypass" + local http = require "luci.http" + local sys = require "luci.sys" + local uci = require "luci.model.uci".cursor() + local util = require "luci.util" if name == "start" then - luci.sys.init.start(packageName) + sys.init.start(packageName) elseif name == "action" then - luci.util.exec("/etc/init.d/" .. packageName .. " restart >/dev/null 2>&1") - luci.util.exec("/etc/init.d/dnsmasq restart >/dev/null 2>&1") + util.exec("/etc/init.d/" .. packageName .. " restart >/dev/null 2>&1") + util.exec("/etc/init.d/dnsmasq restart >/dev/null 2>&1") elseif name == "stop" then - luci.sys.init.stop(packageName) + sys.init.stop(packageName) elseif name == "enable" then - luci.util.exec("uci set " .. packageName .. ".config.enabled=1; uci commit " .. packageName) + uci:set(packageName, "config", "enabled", "1") + uci:commit(packageName) elseif name == "disable" then - luci.util.exec("uci set " .. packageName .. ".config.enabled=0; uci commit " .. packageName) + uci:set(packageName, "config", "enabled", "0") + uci:commit(packageName) end - luci.http.prepare_content("text/plain") - luci.http.write("0") + http.prepare_content("text/plain") + http.write("0") end |