autoupdater.lua 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. --[[
  2. Copyright 2013 Nils Schneider <nils@nilsschneider.net>
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. ]]--
  8. local uci = require("simple-uci").cursor()
  9. local autoupdater = uci:get_first("autoupdater", "autoupdater")
  10. local f = Form(translate("Automatic updates"))
  11. local s = f:section(Section)
  12. local o
  13. o = s:option(Flag, "enabled", translate("Enable"))
  14. o.default = uci:get_bool("autoupdater", autoupdater, "enabled")
  15. function o:write(data)
  16. uci:set("autoupdater", autoupdater, "enabled", data)
  17. end
  18. o = s:option(ListValue, "branch", translate("Branch"))
  19. uci:foreach("autoupdater", "branch",
  20. function (section)
  21. o:value(section[".name"])
  22. end
  23. )
  24. o.default = uci:get("autoupdater", autoupdater, "branch")
  25. function o:write(data)
  26. uci:set("autoupdater", autoupdater, "branch", data)
  27. end
  28. function f:write()
  29. uci:commit("autoupdater")
  30. end
  31. return f