2013-10-02 22:56:19 +02:00
local configmode = require " luci.tools.gluon-config-mode "
2013-09-28 23:18:36 +02:00
local meshvpn_name = " mesh_vpn "
local uci = luci.model . uci.cursor ( )
local f , s , o
-- prepare fastd key as early as possible
configmode.setup_fastd_secret ( meshvpn_name )
2013-10-09 21:13:36 +02:00
f = SimpleForm ( " wizard " , " Willkommen! " , " Willkommen zum Einrichtungsassistenten für deinen neuen Lübecker Freifunk-Knoten. Fülle das folgende Formular deinen Vorstellungen entsprechend aus und klicke anschließend auf den „Senden“-Button. " )
2014-01-21 23:42:03 +01:00
f.reset = false
2013-09-28 23:18:36 +02:00
2014-01-21 17:08:03 +01:00
s = f : section ( SimpleSection , nil , nil )
2013-09-28 23:18:36 +02:00
o = s : option ( Value , " _hostname " , " Knotenname " )
o.value = uci : get_first ( " system " , " system " , " hostname " )
o.rmempty = false
o.datatype = " hostname "
2013-10-09 21:13:36 +02:00
o.description = " Öffentlicher Name deines Knotens. Wird z.B. für die Anzeige auf der Knotenkarte benutzt. "
2013-09-28 23:18:36 +02:00
2013-10-03 23:00:47 +02:00
o = s : option ( Flag , " _autoupdate " , " Automatische Updates aktivieren? " )
o.default = uci : get_bool ( " autoupdater " , " settings " , " enabled " ) and o.enabled or o.disabled
o.rmempty = false
2013-10-09 21:13:36 +02:00
o.description = " Aktiviert automatische Updates der Firmware (empfohlen) "
2013-10-03 23:00:47 +02:00
2014-01-21 17:08:03 +01:00
s = f : section ( SimpleSection , nil , " Nutzt die Internet-Verbindung, um diesem Knoten auch dann Zugang zum Freifunknetz zu geben, wenn er außerhalb der Funkreichweite anderer Freifunk-Knoten ist. " )
2013-10-03 23:00:47 +02:00
2013-09-28 23:18:36 +02:00
o = s : option ( Flag , " _meshvpn " , " Mesh-VPN aktivieren? " )
2013-10-02 14:46:39 +02:00
o.default = uci : get_bool ( " fastd " , meshvpn_name , " enabled " ) and o.enabled or o.disabled
2013-09-28 23:18:36 +02:00
o.rmempty = false
2013-10-03 23:00:47 +02:00
o = s : option ( Flag , " _limit_enabled " , " Bandbreitenbegrenzung aktivieren? " )
2014-01-21 20:02:17 +01:00
o : depends ( " _meshvpn " , " 1 " )
2013-10-03 23:00:47 +02:00
o.default = uci : get_bool ( " gluon-simple-tc " , meshvpn_name , " enabled " ) and o.enabled or o.disabled
o.rmempty = false
2013-10-09 21:13:36 +02:00
o.description = " Begrenzt die Geschwindigkeit, mit der dieser Knoten auf das Internet zugreifen darf. Kann aktiviert werden, wenn der eigene Internetanschluss durch den Freifunkknoten merklich ausgebremst wird. "
2013-09-30 15:14:01 +02:00
2013-10-03 23:00:47 +02:00
o = s : option ( Value , " _limit_ingress " , " Downstream " )
2014-01-21 19:48:19 +01:00
o : depends ( " _limit_enabled " , " 1 " )
2013-10-03 23:00:47 +02:00
o.value = uci : get ( " gluon-simple-tc " , meshvpn_name , " limit_ingress " )
2013-09-28 23:18:36 +02:00
o.rmempty = false
2013-10-03 23:00:47 +02:00
o.datatype = " integer "
2013-09-28 23:18:36 +02:00
2013-10-03 23:00:47 +02:00
o = s : option ( Value , " _limit_egress " , " Upstream " )
2014-01-21 19:48:19 +01:00
o : depends ( " _limit_enabled " , " 1 " )
2013-10-03 23:00:47 +02:00
o.value = uci : get ( " gluon-simple-tc " , meshvpn_name , " limit_egress " )
2013-09-28 23:18:36 +02:00
o.rmempty = false
2013-10-03 23:00:47 +02:00
o.datatype = " integer "
2013-09-28 23:18:36 +02:00
2014-01-21 17:08:03 +01:00
s = f : section ( SimpleSection , nil , " Hier kannst du die GPS-Koordinaten deines Knotens eintragen, um ihn in der Knotenkarte anzeigen zu lassen. " )
2013-09-28 23:18:36 +02:00
2013-10-02 14:46:39 +02:00
o = s : option ( Flag , " _location " , " Koordinaten veröffentlichen? " )
2014-01-19 23:14:52 +01:00
o.default = uci : get_first ( " gluon-locaton " , " location " , " share_location " , o.disabled )
2013-10-02 14:46:39 +02:00
o.rmempty = false
2013-09-28 23:18:36 +02:00
o = s : option ( Value , " _latitude " , " Breitengrad " )
2014-01-19 23:14:52 +01:00
o.default = string.format ( " %f " , uci : get_first ( " gluon-location " , " location " , " latitude " , " 0 " ) )
2013-09-28 23:18:36 +02:00
o.rmempty = false
o.datatype = " float "
o = s : option ( Value , " _longitude " , " Längengrad " )
2014-01-19 23:14:52 +01:00
o.default = string.format ( " %f " , uci : get_first ( " gluon-location " , " location " , " longitude " , " 0 " ) )
2013-09-28 23:18:36 +02:00
o.rmempty = false
o.datatype = " float "
function f . handle ( self , state , data )
if state == FORM_VALID then
local stat = false
2013-10-02 14:46:39 +02:00
uci : set ( " autoupdater " , " settings " , " enabled " , data._autoupdate )
2013-09-28 23:18:36 +02:00
uci : save ( " autoupdater " )
uci : commit ( " autoupdater " )
2014-01-21 22:19:25 +01:00
-- checks for nil needed due to o:depends(...)
if data._limit_enabled ~= nil then
uci : set ( " gluon-simple-tc " , meshvpn_name , " interface " )
uci : set ( " gluon-simple-tc " , meshvpn_name , " enabled " , data._limit_enabled )
uci : set ( " gluon-simple-tc " , meshvpn_name , " ifname " , " mesh-vpn " )
if data._limit_ingress ~= nil then
uci : set ( " gluon-simple-tc " , meshvpn_name , " limit_ingress " , data._limit_ingress )
end
if data._limit_egress ~= nil then
uci : set ( " gluon-simple-tc " , meshvpn_name , " limit_egress " , data._limit_egress )
end
uci : commit ( " gluon-simple-tc " )
end
2013-09-28 23:18:36 +02:00
uci : set ( " fastd " , meshvpn_name , " enabled " , data._meshvpn )
uci : save ( " fastd " )
uci : commit ( " fastd " )
uci : foreach ( " system " , " system " , function ( s )
uci : set ( " system " , s [ " .name " ] , " hostname " , data._hostname )
end )
uci : save ( " system " )
uci : commit ( " system " )
2014-01-19 23:14:52 +01:00
uci : foreach ( " gluon-location " , " location " , function ( s )
uci : set ( " gluon-location " , s [ " .name " ] , " share_location " , data._location )
uci : set ( " gluon-location " , s [ " .name " ] , " latitude " , data._latitude )
uci : set ( " gluon-location " , s [ " .name " ] , " longitude " , data._longitude )
end )
uci : save ( " gluon-location " )
uci : commit ( " gluon-location " )
2013-10-02 22:56:19 +02:00
luci.http . redirect ( luci.dispatcher . build_url ( " gluon-config-mode " , " reboot " ) )
2013-09-28 23:18:36 +02:00
end
return true
end
return f