modules/admin-full: when deleting wifi-ifaces, remove all empty leftover networks, not only the first one

This commit is contained in:
Jo-Philipp Wich 2012-06-26 21:49:27 +00:00
parent 61883f2c3f
commit 254ad2dfd1

View file

@ -43,13 +43,13 @@ function index()
local has_wifi = false local has_wifi = false
uci:foreach("wireless", "wifi-device", uci:foreach("wireless", "wifi-device",
function(s) function(s)
has_wifi = true has_wifi = true
return false return false
end) end)
if has_wifi then if has_wifi then
page = entry({"admin", "network", "wireless_join"}, call("wifi_join"), nil) page = entry({"admin", "network", "wireless_join"}, call("wifi_join"), nil)
page.leaf = true page.leaf = true
@ -214,14 +214,17 @@ function wifi_delete(network)
local wnet = ntm:get_wifinet(network) local wnet = ntm:get_wifinet(network)
if wnet then if wnet then
local dev = wnet:get_device() local dev = wnet:get_device()
local net = wnet:get_network() local nets = wnet:get_networks()
if dev then if dev then
luci.sys.call("env -i /sbin/wifi down %q >/dev/null" % dev:name()) luci.sys.call("env -i /sbin/wifi down %q >/dev/null" % dev:name())
ntm:del_wifinet(network) ntm:del_wifinet(network)
ntm:commit("wireless") ntm:commit("wireless")
if net and net:is_empty() then local _, net
ntm:del_network(net:name()) for _, net in ipairs(nets) do
ntm:commit("network") if net:is_empty() then
ntm:del_network(net:name())
ntm:commit("network")
end
end end
luci.sys.call("env -i /sbin/wifi up %q >/dev/null" % dev:name()) luci.sys.call("env -i /sbin/wifi up %q >/dev/null" % dev:name())
end end