-------------------- View --------------------
f = SimpleForm("ffwizward", "Freifunkassistent",
"Dieser Assistent unterstützt Sie bei der Einrichtung des Routers für das Freifunknetz.")
--- main netconfig
-local newpsswd = has_rom and sys.exec("diff /rom/etc/passwd /etc/passwd")
-if newpsswd ~= "" then
- pw = f:field(Flag, "pw", "Router Passwort", "Setzen Sie den Haken, um Ihr Passwort zu ändern.")
- function pw.cfgvalue(self, section)
- return 1
- end
-end
-pw1 = f:field(Value, "pw1", translate("password"))
-pw1.password = true
-pw1.rmempty = false
+-- if password is not set or default then force the user to set a new one
+if sys.exec("diff /rom/etc/passwd /etc/passwd") == "" then
+ pw1 = f:field(Value, "pw1", translate("password"))
+ pw1.password = true
+ pw1.rmempty = false
-pw2 = f:field(Value, "pw2", translate("confirmation"))
-pw2.password = true
-pw2.rmempty = false
-
-function pw2.validate(self, value, section)
- return pw1:formvalue(section) == value and value
-end
+ pw2 = f:field(Value, "pw2", translate("confirmation"))
+ pw2.password = true
+ pw2.rmempty = false
-if newpsswd ~= "" then
- pw1:depends("pw", "1")
- pw2:depends("pw", "1")
+ function pw2.validate(self, value, section)
+ return pw1:formvalue(section) == value and value
+ end
end
net = f:field(ListValue, "net", "Freifunk Community", "Nutzen Sie die Einstellungen der Freifunk Gemeinschaft in ihrer Nachbarschaft.")
uci:save("freifunk")
end
function hostname.validate(self, value)
- if (#value > 16) then
- return
- elseif (string.find(value, "[^%w%_%-]")) then
+ if (#value > 24) or string.find(value, "[^%w%.%-]") or string.find(string.sub(value, value:len()), "[%.%-]") or string.find(string.sub(value, 1), "[%.%-]") then
return
else
return value
else
if data.pw1 then
local stat = luci.sys.user.setpasswd("root", data.pw1) == 0
--- if stat then
--- f.message = translate("a_s_changepw_changed")
--- else
--- f.errmessage = translate("unknownerror")
- end
+ end
data.pw1 = nil
data.pw2 = nil
uci:commit("freifunk")
if has_radvd then
uci:commit("radvd")
end
--- the following line didn't work without admin-mini, for now i just replaced it with sys.exec... soma
--- luci.http.redirect(luci.dispatcher.build_url(unpack(luci.dispatcher.context.requested.path), "system", "reboot") .. "?reboot=1")
- sys.exec("reboot")
+
+ sys.exec("for s in network dnsmasq luci_splash firewall uhttpd olsrd radvd l2gvpn; do [ -x /etc/init.d/$s ] && /etc/init.d/$s restart;done > /dev/null &")
+ luci.http.redirect(luci.dispatcher.build_url(luci.dispatcher.context.path[1], "freifunk", "ffwizard"))
end
return false
elseif state == FORM_INVALID then
local chan = tonumber(channel)
if chan >= 0 and chan < 10 then
bssid = channel .. "2:CA:FF:EE:BA:BE"
+ elseif chan == 10 then
+ bssid = "02:CA:FF:EE:BA:BE"
elseif chan >= 11 and chan <= 14 then
bssid = string.format("%X",channel) .. "2:CA:FF:EE:BA:BE"
elseif chan >= 36 and chan <= 64 then