profile.lua 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. -- Copyright 2011-2012 Manuel Munz <freifunk at somakoma dot de>
  2. -- Licensed to the public under the Apache License 2.0.
  3. local uci = require "luci.model.uci".cursor()
  4. local ipkg = require "luci.model.ipkg"
  5. local community = uci:get("freifunk", "community", "name")
  6. if community == nil then
  7. luci.http.redirect(luci.dispatcher.build_url("admin", "freifunk", "profile_error"))
  8. return
  9. else
  10. community = "profile_" .. community
  11. m = Map(community, translate("Community settings"), translate("These are the settings of your local community."))
  12. c = m:section(NamedSection, "profile", "community")
  13. local name = c:option(Value, "name", "Name")
  14. name.rmempty = false
  15. local homepage = c:option(Value, "homepage", translate("Homepage"))
  16. local cc = c:option(Value, "country", translate("Country code"))
  17. function cc.cfgvalue(self, section)
  18. return uci:get(community, "wifi_device", "country")
  19. end
  20. function cc.write(self, sec, value)
  21. if value then
  22. uci:set(community, "wifi_device", "country", value)
  23. uci:save(community)
  24. end
  25. end
  26. local ssid = c:option(Value, "ssid", translate("ESSID"))
  27. ssid.rmempty = false
  28. local prefix = c:option(Value, "mesh_network", translate("Mesh prefix"))
  29. prefix.datatype = "ip4addr"
  30. prefix.rmempty = false
  31. local splash_net = c:option(Value, "splash_network", translate("Network for client DHCP addresses"))
  32. splash_net.datatype = "ip4addr"
  33. splash_net.rmempty = false
  34. local splash_prefix = c:option(Value, "splash_prefix", translate("Client network size"))
  35. splash_prefix.datatype = "range(0,32)"
  36. splash_prefix.rmempty = false
  37. local ipv6 = c:option(Flag, "ipv6", translate("Enable IPv6"))
  38. ipv6.rmempty = true
  39. local ipv6_config = c:option(ListValue, "ipv6_config", translate("IPv6 Config"))
  40. ipv6_config:depends("ipv6", 1)
  41. ipv6_config:value("static")
  42. if ipkg.installed ("auto-ipv6-ib") then
  43. ipv6_config:value("auto-ipv6-random")
  44. ipv6_config:value("auto-ipv6-fromv4")
  45. end
  46. ipv6_config.rmempty = true
  47. local ipv6_prefix = c:option(Value, "ipv6_prefix", translate("IPv6 Prefix"), translate("IPv6 network in CIDR notation."))
  48. ipv6_prefix:depends("ipv6", 1)
  49. ipv6_prefix.datatype = "ip6addr"
  50. ipv6_prefix.rmempty = true
  51. local vap = c:option(Flag, "vap", translate("VAP"), translate("Enable a virtual access point (VAP) by default if possible."))
  52. vap.rmempty = true
  53. local lat = c:option(Value, "latitude", translate("Latitude"))
  54. lat.datatype = "range(-180, 180)"
  55. lat.rmempty = false
  56. local lon = c:option(Value, "longitude", translate("Longitude"))
  57. lon.rmempty = false
  58. return m
  59. end