* libs/uci: Fixed uci.delete_all
* Fixed Freifunk wizard
This commit is contained in:
parent
0eefbbe91d
commit
a7a2afdb0a
2 changed files with 25 additions and 24 deletions
|
@ -195,12 +195,11 @@ function configure_freifunk()
|
||||||
function (section)
|
function (section)
|
||||||
local device = section[".name"]
|
local device = section[".name"]
|
||||||
|
|
||||||
if luci.http.formvalue("wifi."..iface) then
|
if luci.http.formvalue("wifi."..device) then
|
||||||
uci.delete_all("wireless", "wifi-iface",
|
uci.delete_all("wireless", "wifi-iface",
|
||||||
function (section)
|
function (section)
|
||||||
return (section.device == device)
|
return (section.device == device)
|
||||||
end)
|
end)
|
||||||
end
|
|
||||||
|
|
||||||
uci.tset("wireless", device, {
|
uci.tset("wireless", device, {
|
||||||
disabled = "0",
|
disabled = "0",
|
||||||
|
@ -211,13 +210,14 @@ function configure_freifunk()
|
||||||
})
|
})
|
||||||
|
|
||||||
uci.section("wireless", "wifi-iface", nil, {
|
uci.section("wireless", "wifi-iface", nil, {
|
||||||
device = iface,
|
device = device,
|
||||||
network = "ff",
|
network = "ff",
|
||||||
mode = "adhoc",
|
mode = "adhoc",
|
||||||
ssid = uci.get("freifunk", "community", "essid"),
|
ssid = uci.get("freifunk", "community", "essid"),
|
||||||
bssid = uci.get("freifunk", "community", "bssid"),
|
bssid = uci.get("freifunk", "community", "bssid"),
|
||||||
txpower = 13
|
txpower = 13
|
||||||
})
|
})
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ local uci = require("uci")
|
||||||
local util = require("luci.util")
|
local util = require("luci.util")
|
||||||
local setmetatable, rawget, rawset = setmetatable, rawget, rawset
|
local setmetatable, rawget, rawset = setmetatable, rawget, rawset
|
||||||
local error, pairs, ipairs, tostring = error, pairs, ipairs, tostring
|
local error, pairs, ipairs, tostring = error, pairs, ipairs, tostring
|
||||||
|
local table, print = table, print
|
||||||
|
|
||||||
module("luci.model.uci", function(m) setmetatable(m, {__index = uci}) end)
|
module("luci.model.uci", function(m) setmetatable(m, {__index = uci}) end)
|
||||||
|
|
||||||
|
@ -37,16 +38,16 @@ savedir_state = "/var/state"
|
||||||
|
|
||||||
function delete_all(config, type, comparator)
|
function delete_all(config, type, comparator)
|
||||||
local del = {}
|
local del = {}
|
||||||
|
local function helper (section)
|
||||||
foreach(config, type,
|
|
||||||
function (section)
|
|
||||||
if not comparator or comparator(section) then
|
if not comparator or comparator(section) then
|
||||||
table.insert(del, section[".name"])
|
table.insert(del, section[".name"])
|
||||||
end
|
end
|
||||||
end)
|
end
|
||||||
|
|
||||||
|
foreach(config, type, helper)
|
||||||
|
|
||||||
for i, j in ipairs(del) do
|
for i, j in ipairs(del) do
|
||||||
uci.delete(config, j)
|
delete(config, j)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue