79a38f7c53a09dd011fa16eb886ce76b21aacab6
[project/luci.git] / applications / luci-upnp / luasrc / model / cbi / upnp / upnp.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2008 Steven Barth <steven@midlink.org>
5 Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
6
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
10
11         http://www.apache.org/licenses/LICENSE-2.0
12
13 $Id$
14 ]]--
15 m = Map("upnpd", translate("upnpd"), translate("upnpd_desc"))
16
17 s = m:section(NamedSection, "config", "upnpd", "")
18 e = s:option(Flag, "enabled", translate("enable"))
19 function e.write(self, section, value)
20         local cmd = (value == "1") and "enable" or "disable"
21         os.execute("/etc/init.d/miniupnpd " .. cmd)
22 end
23
24 function e.cfgvalue(self, section)
25         return (os.execute("/etc/init.d/miniupnpd enabled") == 0) and "1" or "0"
26 end
27
28 s:option(Flag, "log_output").rmempty = true
29 s:option(Value, "download").rmempty = true
30 s:option(Value, "upload").rmempty = true
31
32 return m