summaryrefslogtreecommitdiffhomepage
path: root/applications
diff options
context:
space:
mode:
authorMarkus Wigge <markus@cultcom.de>2009-08-12 14:05:31 +0000
committerMarkus Wigge <markus@cultcom.de>2009-08-12 14:05:31 +0000
commit6bbbd9095afa9730854db5332eefc9d71d4a089d (patch)
tree4c5e5ec1af227c2d440032f49ad87f27ab0e0e39 /applications
parentf72c9704aeb762a6b51fc73ddf428c16872405ea (diff)
added start/stop button column to selectively start and stop
OpenVPN connections
Diffstat (limited to 'applications')
-rw-r--r--applications/luci-openvpn/luasrc/model/cbi/openvpn.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/applications/luci-openvpn/luasrc/model/cbi/openvpn.lua b/applications/luci-openvpn/luasrc/model/cbi/openvpn.lua
index 1d055a683..400633acc 100644
--- a/applications/luci-openvpn/luasrc/model/cbi/openvpn.lua
+++ b/applications/luci-openvpn/luasrc/model/cbi/openvpn.lua
@@ -83,6 +83,26 @@ function active.cfgvalue(self, section)
return translate("openvpn_active_no")
end
+local updown = s:option( Button, "_updown", translate("openvpn_updown", "Start/Stop") )
+updown._state = false
+function updown.cbid(self, section)
+ local pid = fs.readfile("/var/run/openvpn-%s.pid" % section)
+ self._state = pid and #pid > 0 and sys.process.signal(pid, 0)
+ self.option = self._state and "stop" or "start"
+ return AbstractValue.cbid(self, section)
+end
+function updown.cfgvalue(self, section)
+ self.title = self._state and "stop" or "start"
+ self.inputstyle = self._state and "reset" or "reload"
+end
+function updown.write(self, section, value)
+ if self.option == "stop" then
+ luci.sys.call("/etc/init.d/openvpn down %s" % section)
+ else
+ luci.sys.call("/etc/init.d/openvpn up %s" % section)
+ end
+end
+
local port = s:option( DummyValue, "port", translate("openvpn_port") )
function port.cfgvalue(self, section)
local val = AbstractValue.cfgvalue(self, section)