applications/ffwizard: show heartbeat config only when heartbeat is installed

This commit is contained in:
Manuel Munz 2011-01-13 14:07:55 +00:00
parent 71515db03a
commit 9245e86d5d

View file

@ -32,6 +32,7 @@ local has_rom = fs.access("/rom/etc")
local has_autoipv6 = fs.access("/usr/bin/auto-ipv6") local has_autoipv6 = fs.access("/usr/bin/auto-ipv6")
local has_qos = fs.access("/etc/init.d/qos") local has_qos = fs.access("/etc/init.d/qos")
local has_ipv6 = fs.access("/proc/sys/net/ipv6") local has_ipv6 = fs.access("/proc/sys/net/ipv6")
local has_hb = fs.access("/sbin/heartbeat")
luci.i18n.loadc("freifunk") luci.i18n.loadc("freifunk")
@ -557,15 +558,17 @@ if has_l2gvpn then
end end
end end
hb = f:field(Flag, "hb", "Heartbeat aktivieren","Dem Gerät erlauben anonyme Statistiken zu übertragen. (empfohlen)") if has_hb then
hb.rmempty = false hb = f:field(Flag, "hb", "Heartbeat aktivieren","Dem Gerät erlauben anonyme Statistiken zu übertragen. (empfohlen)")
hb:depends("netconfig", "1") hb.rmempty = false
function hb.cfgvalue(self, section) hb:depends("netconfig", "1")
return uci:get("freifunk", "wizard", "hb") function hb.cfgvalue(self, section)
end return uci:get("freifunk", "wizard", "hb")
function hb.write(self, section, value) end
uci:set("freifunk", "wizard", "hb", value) function hb.write(self, section, value)
uci:save("freifunk") uci:set("freifunk", "wizard", "hb", value)
uci:save("freifunk")
end
end end
-------------------- Control -------------------- -------------------- Control --------------------
@ -694,8 +697,10 @@ function main.write(self, section, value)
end) end)
end end
uci:save("firewall") uci:save("firewall")
uci:delete("manager", "heartbeat", "interface") if has_hb then
uci:save("manager") uci:delete("manager", "heartbeat", "interface")
uci:save("manager")
end
-- Delete olsrdv4 -- Delete olsrdv4
uci:delete_all("olsrd", "olsrd") uci:delete_all("olsrd", "olsrd")
local olsrbase local olsrbase
@ -878,10 +883,12 @@ function main.write(self, section, value)
local client = luci.http.formvalue("cbid.ffwizward.1.client_" .. device) local client = luci.http.formvalue("cbid.ffwizward.1.client_" .. device)
if client then if client then
local dhcpmeshnet = luci.http.formvalue("cbid.ffwizward.1.dhcpmesh_" .. device) and ip.IPv4(luci.http.formvalue("cbid.ffwizward.1.dhcpmesh_" .. device)) local dhcpmeshnet = luci.http.formvalue("cbid.ffwizward.1.dhcpmesh_" .. device) and ip.IPv4(luci.http.formvalue("cbid.ffwizward.1.dhcpmesh_" .. device))
local ifacelist = uci:get_list("manager", "heartbeat", "interface") or {} if has_hb then
table.insert(ifacelist,nif .. "dhcp") local ifacelist = uci:get_list("manager", "heartbeat", "interface") or {}
uci:set_list("manager", "heartbeat", "interface", ifacelist) table.insert(ifacelist,nif .. "dhcp")
uci:save("manager") uci:set_list("manager", "heartbeat", "interface", ifacelist)
uci:save("manager")
end
if dhcpmeshnet then if dhcpmeshnet then
if not dhcpmeshnet:minhost() or not dhcpmeshnet:mask() then if not dhcpmeshnet:minhost() or not dhcpmeshnet:mask() then
dhcpmesh.tag_missing[section] = true dhcpmesh.tag_missing[section] = true
@ -1107,10 +1114,12 @@ function main.write(self, section, value)
local client = luci.http.formvalue("cbid.ffwizward.1.client_" .. device) local client = luci.http.formvalue("cbid.ffwizward.1.client_" .. device)
if client then if client then
local dhcpmeshnet = luci.http.formvalue("cbid.ffwizward.1.dhcpmesh_" .. device) and ip.IPv4(luci.http.formvalue("cbid.ffwizward.1.dhcpmesh_" .. device)) local dhcpmeshnet = luci.http.formvalue("cbid.ffwizward.1.dhcpmesh_" .. device) and ip.IPv4(luci.http.formvalue("cbid.ffwizward.1.dhcpmesh_" .. device))
local ifacelist = uci:get_list("manager", "heartbeat", "interface") or {} if has_hb then
table.insert(ifacelist,device .. "dhcp") local ifacelist = uci:get_list("manager", "heartbeat", "interface") or {}
uci:set_list("manager", "heartbeat", "interface", ifacelist) table.insert(ifacelist,device .. "dhcp")
uci:save("manager") uci:set_list("manager", "heartbeat", "interface", ifacelist)
uci:save("manager")
end
if dhcpmeshnet then if dhcpmeshnet then
if not dhcpmeshnet:minhost() or not dhcpmeshnet:mask() then if not dhcpmeshnet:minhost() or not dhcpmeshnet:mask() then
dhcpmesh.tag_missing[section] = true dhcpmesh.tag_missing[section] = true
@ -1254,18 +1263,19 @@ function main.write(self, section, value)
local new_hostname = uci:get("freifunk", "wizard", "hostname") local new_hostname = uci:get("freifunk", "wizard", "hostname")
local old_hostname = sys.hostname() local old_hostname = sys.hostname()
local dhcphb = hb:formvalue(section) if has_hb then
if dhcphb then local dhcphb = hb:formvalue(section)
uci:set("manager", "heartbeat", "enabled", "1") if dhcphb then
-- Make sure that heartbeat is enabled uci:set("manager", "heartbeat", "enabled", "1")
sys.init.enable("machash") -- Make sure that heartbeat is enabled
sys.init.enable("machash")
else else
uci:set("manager", "heartbeat", "enabled", "0") uci:set("manager", "heartbeat", "enabled", "0")
-- Make sure that heartbeat is enabled -- Make sure that heartbeat is enabled
sys.init.disable("machash") sys.init.disable("machash")
end
uci:save("manager")
end end
uci:save("manager")
local custom_hostname = hostname:formvalue(section) local custom_hostname = hostname:formvalue(section)
uci:foreach("system", "system", uci:foreach("system", "system",