modules/luci-mod-failsafe: Fix nil file descriptor error
[project/luci.git] / modules / luci-mod-admin-full / luasrc / model / cbi / admin_system / ipkg.lua
1 -- Copyright 2008 Steven Barth <steven@midlink.org>
2 -- Copyright 2008-2011 Jo-Philipp Wich <jow@openwrt.org>
3 -- Licensed to the public under the Apache License 2.0.
4
5 local ipkgfile = "/etc/opkg.conf"
6
7 f = SimpleForm("ipkgconf", translate("OPKG-Configuration"))
8
9 f:append(Template("admin_system/ipkg"))
10
11 t = f:field(TextValue, "lines")
12 t.rows = 10
13 function t.cfgvalue()
14         return nixio.fs.readfile(ipkgfile) or ""
15 end
16
17 function t.write(self, section, data)
18         return nixio.fs.writefile(ipkgfile, data:gsub("\r\n", "\n"))
19 end
20
21 function f.handle(self, state, data)
22         return true
23 end
24
25 return f