autoupdater.lua 1.5 KB

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