ipkg.lua 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. local ipkgfile = "/etc/opkg.conf"
  5. local distfeeds = "/etc/opkg/distfeeds.conf"
  6. local customfeeds = "/etc/opkg/customfeeds.conf"
  7. f = SimpleForm("ipkgconf", translate("OPKG-Configuration"), translate("General options for opkg"))
  8. f:append(Template("admin_system/ipkg"))
  9. t = f:field(TextValue, "lines")
  10. t.wrap = "off"
  11. t.rows = 10
  12. function t.cfgvalue()
  13. return nixio.fs.readfile(ipkgfile) or ""
  14. end
  15. function t.write(self, section, data)
  16. return nixio.fs.writefile(ipkgfile, data:gsub("\r\n", "\n"))
  17. end
  18. function f.handle(self, state, data)
  19. return true
  20. end
  21. g = SimpleForm("distfeedconf", translate("Distribution feeds"),
  22. translate("Build/distribution specific feed definitions. This file will NOT be preserved in any sysupgrade."))
  23. d = g:field(TextValue, "lines2")
  24. d.wrap = "off"
  25. d.rows = 10
  26. function d.cfgvalue()
  27. return nixio.fs.readfile(distfeeds) or ""
  28. end
  29. function d.write(self, section, data)
  30. return nixio.fs.writefile(distfeeds, data:gsub("\r\n", "\n"))
  31. end
  32. function g.handle(self, state, data)
  33. return true
  34. end
  35. h = SimpleForm("customfeedconf", translate("Custom feeds"),
  36. translate("Custom feed definitions, e.g. private feeds. This file can be preserved in a sysupgrade."))
  37. c = h:field(TextValue, "lines3")
  38. c.wrap = "off"
  39. c.rows = 10
  40. function c.cfgvalue()
  41. return nixio.fs.readfile(customfeeds) or ""
  42. end
  43. function c.write(self, section, data)
  44. return nixio.fs.writefile(customfeeds, data:gsub("\r\n", "\n"))
  45. end
  46. function h.handle(self, state, data)
  47. return true
  48. end
  49. return f, g, h