wizard.lua 1.2 KB

123456789101112131415161718192021222324252627282930
  1. module("luci.controller.freifunk.wizard", package.seeall)
  2. function index()
  3. local uci_state = luci.model.uci.cursor_state()
  4. if uci_state:get_first("config_mode", "wizard", "running", "0") == "1" then
  5. entry({"wizard", "welcome"}, template("freifunk-wizard/welcome"), "Willkommen", 10).dependent=false
  6. entry({"wizard", "password"}, form("freifunk-wizard/password"), "Passwort", 20).dependent=false
  7. entry({"wizard", "hostname"}, form("freifunk-wizard/hostname"), "Hostname", 30).dependent=false
  8. entry({"wizard", "meshvpn"}, form("freifunk-wizard/meshvpn"), "Mesh-VPN", 40).dependent=false
  9. entry({"wizard", "meshvpn", "pubkey"}, template("freifunk-wizard/meshvpn-key"), "Mesh-VPN Key", 1).dependent=false
  10. entry({"wizard", "completed"}, template("freifunk-wizard/completed"), "Fertig", 50).dependent=false
  11. entry({"wizard", "completed", "reboot"}, call("reboot"), "reboot", 1).dependent=false
  12. end
  13. end
  14. function reboot()
  15. local uci = luci.model.uci.cursor()
  16. uci:foreach("config_mode", "wizard",
  17. function(s)
  18. uci:set("config_mode", s[".name"], "configured", "1")
  19. end
  20. )
  21. uci:save("config_mode")
  22. uci:commit("config_mode")
  23. luci.sys.reboot()
  24. end