treewide: replace normal uses of luci.model.uci with simple-uci to reduce LuCI dependencies

We also make use of the boolean support of simple-uci to make scripts
clearer.
This commit is contained in:
Matthias Schiffer 2017-01-19 12:51:04 +01:00
parent 6f48fc428f
commit 6cf03bab37
No known key found for this signature in database
GPG Key ID: 16EF3F64CB201D9C
47 changed files with 145 additions and 157 deletions

View File

@ -1,18 +1,14 @@
#!/usr/bin/lua #!/usr/bin/lua
local uci = require 'luci.model.uci' local uci = require('simple-uci').cursor()
local c = uci.cursor()
uci:delete('alfred', 'alfred')
uci:section('alfred', 'alfred', 'alfred', {
interface = 'local-node',
mode = 'slave',
batmanif = 'bat0',
start_vis = true,
run_facters = false,
})
c:delete('alfred', 'alfred') uci:save('alfred')
c:section('alfred', 'alfred', 'alfred',
{
interface = 'local-node',
mode = 'slave',
batmanif = 'bat0',
start_vis = '1',
run_facters = '0',
}
)
c:save('alfred')

View File

@ -1,45 +1,39 @@
#!/usr/bin/lua #!/usr/bin/lua
local site = require 'gluon.site_config' local site = require 'gluon.site_config'
local uci = require 'luci.model.uci' local uci = require('simple-uci').cursor()
local c = uci.cursor()
for name, config in pairs(site.autoupdater.branches) do for name, config in pairs(site.autoupdater.branches) do
c:delete('autoupdater', name) uci:delete('autoupdater', name)
c:section('autoupdater', 'branch', name, uci:section('autoupdater', 'branch', name, {
{ name = config.name,
name = config.name, mirror = config.mirrors,
mirror = config.mirrors, good_signatures = config.good_signatures,
good_signatures = config.good_signatures, pubkey = config.pubkeys,
pubkey = config.pubkeys, })
}
)
end end
if not c:get('autoupdater', 'settings') then if not uci:get('autoupdater', 'settings') then
local enabled = 0 local enabled = false
local branch = site.autoupdater.branch local branch = site.autoupdater.branch
local f = io.open('/lib/gluon/autoupdater/default_branch') local f = io.open('/lib/gluon/autoupdater/default_branch')
if f then if f then
enabled = 1 enabled = true
branch = f:read('*line') branch = f:read('*line')
f:close() f:close()
end end
c:section('autoupdater', 'autoupdater', 'settings', uci:section('autoupdater', 'autoupdater', 'settings', {
{ enabled = enabled,
enabled = enabled, branch = branch,
branch = branch, })
}
)
end end
c:set('autoupdater', 'settings', 'version_file', '/lib/gluon/release') uci:set('autoupdater', 'settings', 'version_file', '/lib/gluon/release')
c:save('autoupdater') uci:save('autoupdater')
local autoupdater_util = require 'autoupdater.util' local autoupdater_util = require 'autoupdater.util'

View File

@ -6,7 +6,7 @@ local util = require 'gluon.util'
local ip = require 'luci.ip' local ip = require 'luci.ip'
local lutil = require 'luci.util' local lutil = require 'luci.util'
local uci = require('luci.model.uci').cursor() local uci = require('simple-uci').cursor()
local ip4, netmask, ip6 local ip4, netmask, ip6
@ -58,15 +58,15 @@ uci:save('network')
local dnsmasq = uci:get_first('dhcp', 'dnsmasq') local dnsmasq = uci:get_first('dhcp', 'dnsmasq')
uci:set('dhcp', dnsmasq, 'boguspriv', 0) uci:set('dhcp', dnsmasq, 'boguspriv', false)
uci:set('dhcp', dnsmasq, 'localise_queries', 0) uci:set('dhcp', dnsmasq, 'localise_queries', false)
uci:set('dhcp', dnsmasq, 'rebind_protection', 0) uci:set('dhcp', dnsmasq, 'rebind_protection', false)
uci:delete('dhcp', 'client') uci:delete('dhcp', 'client')
uci:section('dhcp', 'dhcp', 'client', uci:section('dhcp', 'dhcp', 'client',
{ {
interface = 'client', interface = 'client',
ignore = 1, ignore = true,
} }
) )

View File

@ -3,16 +3,18 @@
local site = require 'gluon.site_config' local site = require 'gluon.site_config'
local util = require 'gluon.util' local util = require 'gluon.util'
local uci = require('luci.model.uci').cursor() local uci = require('simple-uci').cursor()
local function is_disabled(config, name) local function is_disabled(config, name)
local disabled = config and config.disabled local disabled
if uci:get('wireless', name) then if uci:get('wireless', name) then
disabled = uci:get_bool('wireless', name, 'disabled') disabled = uci:get_bool('wireless', name, 'disabled')
else
disabled = config and config.disabled
end end
return disabled and 1 or 0 return disabled
end end
local function configure_client(config, radio, index, suffix) local function configure_client(config, radio, index, suffix)
@ -38,7 +40,7 @@ local function configure_client(config, radio, index, suffix)
ssid = config.ssid, ssid = config.ssid,
macaddr = macaddr, macaddr = macaddr,
ifname = suffix and 'client' .. suffix, ifname = suffix and 'client' .. suffix,
disabled = disabled, disabled = disabled or false,
} }
) )
end end

View File

@ -1,6 +1,6 @@
local cbi = require "luci.cbi" local cbi = require "luci.cbi"
local i18n = require "luci.i18n" local i18n = require "luci.i18n"
local uci = luci.model.uci.cursor() local uci = require("simple-uci").cursor()
local M = {} local M = {}

View File

@ -1,6 +1,6 @@
local cbi = require "luci.cbi" local cbi = require "luci.cbi"
local i18n = require "luci.i18n" local i18n = require "luci.i18n"
local uci = luci.model.uci.cursor() local uci = require("simple-uci").cursor()
local site = require 'gluon.site_config' local site = require 'gluon.site_config'
local M = {} local M = {}

View File

@ -4,7 +4,7 @@ local gluon_luci = require 'gluon.luci'
local sysconfig = require 'gluon.sysconfig' local sysconfig = require 'gluon.sysconfig'
local pretty_hostname = require 'pretty_hostname' local pretty_hostname = require 'pretty_hostname'
local uci = luci.model.uci.cursor() local uci = require("simple-uci").cursor()
local hostname = pretty_hostname.get(uci) local hostname = pretty_hostname.get(uci)
local contact = uci:get_first('gluon-node-info', 'owner', 'contact') local contact = uci:get_first('gluon-node-info', 'owner', 'contact')

View File

@ -1,6 +1,6 @@
local wizard_dir = "/lib/gluon/config-mode/wizard/" local wizard_dir = "/lib/gluon/config-mode/wizard/"
local i18n = luci.i18n local i18n = luci.i18n
local uci = luci.model.uci.cursor() local uci = require("simple-uci").cursor()
local fs = require "nixio.fs" local fs = require "nixio.fs"
local util = require "nixio.util" local util = require "nixio.util"
local f, s local f, s

View File

@ -1,6 +1,6 @@
local cbi = require "luci.cbi" local cbi = require "luci.cbi"
local i18n = require "luci.i18n" local i18n = require "luci.i18n"
local uci = luci.model.uci.cursor() local uci = require("simple-uci").cursor()
local site = require 'gluon.site_config' local site = require 'gluon.site_config'
local M = {} local M = {}

View File

@ -1,7 +1,7 @@
local cbi = require "luci.cbi" local cbi = require "luci.cbi"
local i18n = require "luci.i18n" local i18n = require "luci.i18n"
local pretty_hostname = require "pretty_hostname" local pretty_hostname = require "pretty_hostname"
local uci = luci.model.uci.cursor() local uci = require("simple-uci").cursor()
local M = {} local M = {}

View File

@ -1,7 +1,7 @@
local uci = luci.model.uci.cursor() local uci = require("simple-uci").cursor()
local meshvpn_enabled = uci:get("fastd", "mesh_vpn", "enabled", "0") local meshvpn_enabled = uci:get_bool("fastd", "mesh_vpn", "enabled")
if meshvpn_enabled ~= "1" then if not meshvpn_enabled then
return nil return nil
else else
local i18n = require "luci.i18n" local i18n = require "luci.i18n"

View File

@ -1,6 +1,6 @@
local cbi = require "luci.cbi" local cbi = require "luci.cbi"
local i18n = require "luci.i18n" local i18n = require "luci.i18n"
local uci = luci.model.uci.cursor() local uci = require("simple-uci").cursor()
local M = {} local M = {}

View File

@ -15,7 +15,7 @@ define Package/gluon-core
SECTION:=gluon SECTION:=gluon
CATEGORY:=Gluon CATEGORY:=Gluon
TITLE:=Base files of Gluon TITLE:=Base files of Gluon
DEPENDS:=+gluon-site +libgluonutil +lua-platform-info +lua-hash +luci-base +luci-lib-jsonc +odhcp6c +firewall +pretty-hostname DEPENDS:=+gluon-site +libgluonutil +lua-platform-info +lua-simple-uci +lua-hash +luci-base +luci-lib-jsonc +odhcp6c +firewall +pretty-hostname
endef endef
define Package/gluon-core/description define Package/gluon-core/description

View File

@ -4,7 +4,7 @@ local sysconfig = require 'gluon.sysconfig'
local gluon_util = require 'gluon.util' local gluon_util = require 'gluon.util'
local platform = require 'gluon.platform' local platform = require 'gluon.platform'
local uci = require('luci.model.uci').cursor() local uci = require('simple-uci').cursor()
if not (sysconfig.lan_ifname or sysconfig.wan_ifname) then if not (sysconfig.lan_ifname or sysconfig.wan_ifname) then

View File

@ -7,7 +7,7 @@ local sysconfig = require 'gluon.sysconfig'
if not sysconfig.gluon_version then if not sysconfig.gluon_version then
local site = require 'gluon.site_config' local site = require 'gluon.site_config'
local util = require 'gluon.util' local util = require 'gluon.util'
local uci = require('luci.model.uci').cursor() local uci = require('simple-uci').cursor()
local system = uci:get_first('system', 'system') local system = uci:get_first('system', 'system')

View File

@ -1,6 +1,6 @@
#!/usr/bin/lua #!/usr/bin/lua
local uci = require('luci.model.uci').cursor() local uci = require('simple-uci').cursor()
local sysctl = require 'gluon.sysctl' local sysctl = require 'gluon.sysctl'
local sysconfig = require 'gluon.sysconfig' local sysconfig = require 'gluon.sysconfig'
@ -9,9 +9,9 @@ uci:section('network', 'interface', 'wan',
{ {
ifname = sysconfig.wan_ifname, ifname = sysconfig.wan_ifname,
type = 'bridge', type = 'bridge',
multicast_querier = 0, multicast_querier = false,
peerdns = 0, peerdns = false,
auto = 1, auto = true,
} }
) )
uci:delete('network', 'wan', 'igmp_snooping') uci:delete('network', 'wan', 'igmp_snooping')
@ -24,9 +24,9 @@ end
uci:section('network', 'interface', 'wan6', uci:section('network', 'interface', 'wan6',
{ {
ifname = 'br-wan', ifname = 'br-wan',
peerdns = 0, peerdns = false,
ip6table = 1, ip6table = 1,
sourcefilter = 0, sourcefilter = false,
} }
) )

View File

@ -1,7 +1,7 @@
#!/usr/bin/lua #!/usr/bin/lua
local site = require 'gluon.site_config' local site = require 'gluon.site_config'
local uci = require 'luci.model.uci' local uci = require 'simple-uci'
if not site.ntp_servers or #site.ntp_servers == 0 then if not site.ntp_servers or #site.ntp_servers == 0 then
os.exit(0) os.exit(0)

View File

@ -1,29 +1,25 @@
#!/usr/bin/lua #!/usr/bin/lua
local site = require 'gluon.site_config' local site = require 'gluon.site_config'
local uci = require 'luci.model.uci' local uci = require('simple-uci').cursor()
local c = uci.cursor()
local function reject_input_on_wan(zone) local function reject_input_on_wan(zone)
if zone.name == 'wan' then if zone.name == 'wan' then
c:set('firewall', zone['.name'], 'input', 'REJECT') uci:set('firewall', zone['.name'], 'input', 'REJECT')
c:set('firewall', zone['.name'], 'conntrack', '1') uci:set('firewall', zone['.name'], 'conntrack', true)
end end
return true return true
end end
c:foreach('firewall', 'zone', reject_input_on_wan) uci:foreach('firewall', 'zone', reject_input_on_wan)
c:section('firewall', 'rule', 'wan_ssh', uci:section('firewall', 'rule', 'wan_ssh', {
{ name = 'wan_ssh',
name = 'wan_ssh', src = 'wan',
src = 'wan', dest_port = '22',
dest_port = '22', proto = 'tcp',
proto = 'tcp', target = 'ACCEPT',
target = 'ACCEPT', })
}
)
c:save('firewall') uci:save('firewall')

View File

@ -3,11 +3,11 @@
local sysconfig = require 'gluon.sysconfig' local sysconfig = require 'gluon.sysconfig'
local site = require 'gluon.site_config' local site = require 'gluon.site_config'
if (not sysconfig.gluon_version) and (site.poe_passthrough == true) then if (not sysconfig.gluon_version) and site.poe_passthrough then
local uci = require('luci.model.uci').cursor() local uci = require('simple-uci').cursor()
if uci:get('system', 'gpio_switch_poe_passthrough') then if uci:get('system', 'gpio_switch_poe_passthrough') then
uci:set('system', 'gpio_switch_poe_passthrough', 'value', 1) uci:set('system', 'gpio_switch_poe_passthrough', 'value', true)
uci:save('system') uci:save('system')
end end
end end

View File

@ -4,7 +4,7 @@ local util = require 'gluon.util'
local site = require 'gluon.site_config' local site = require 'gluon.site_config'
local sysconfig = require 'gluon.sysconfig' local sysconfig = require 'gluon.sysconfig'
local uci = require('luci.model.uci').cursor() local uci = require('simple-uci').cursor()
-- Initial -- Initial
if not sysconfig.gluon_version then if not sysconfig.gluon_version then
@ -22,6 +22,8 @@ end
local function is_disabled(name) local function is_disabled(name)
if uci:get('wireless', name) then if uci:get('wireless', name) then
return uci:get_bool('wireless', name, 'disabled') return uci:get_bool('wireless', name, 'disabled')
else
return false
end end
end end
@ -82,7 +84,7 @@ local function configure_ibss(config, radio, index, suffix, disabled)
macaddr = macaddr, macaddr = macaddr,
mcast_rate = config.mcast_rate, mcast_rate = config.mcast_rate,
ifname = suffix and 'ibss' .. suffix, ifname = suffix and 'ibss' .. suffix,
disabled = disabled and 1 or 0, disabled = disabled,
} }
) )
end end
@ -116,11 +118,11 @@ local function configure_mesh(config, radio, index, suffix, disabled)
network = name, network = name,
mode = 'mesh', mode = 'mesh',
mesh_id = config.id, mesh_id = config.id,
mesh_fwding = 0, mesh_fwding = false,
macaddr = macaddr, macaddr = macaddr,
mcast_rate = config.mcast_rate, mcast_rate = config.mcast_rate,
ifname = suffix and 'mesh' .. suffix, ifname = suffix and 'mesh' .. suffix,
disabled = disabled and 1 or 0, disabled = disabled,
macfilter = macfilter, macfilter = macfilter,
maclist = maclist, maclist = maclist,
} }

View File

@ -1,15 +1,15 @@
#!/usr/bin/lua #!/usr/bin/lua
local site = require 'gluon.site_config' local site = require 'gluon.site_config'
local uci = require('luci.model.uci').cursor() local uci = require('simple-uci').cursor()
if not uci:get('network', 'mesh_wan') then if not uci:get('network', 'mesh_wan') then
uci:section('network', 'interface', 'mesh_wan', { uci:section('network', 'interface', 'mesh_wan', {
ifname = 'br-wan', ifname = 'br-wan',
proto = 'gluon_mesh', proto = 'gluon_mesh',
transitive = 1, transitive = true,
fixed_mtu = 1, fixed_mtu = true,
auto = site.mesh_on_wan and 1 or 0, auto = site.mesh_on_wan or false,
}) })
end end

View File

@ -4,7 +4,7 @@ local site = require 'gluon.site_config'
local util = require 'gluon.util' local util = require 'gluon.util'
local sysconfig = require 'gluon.sysconfig' local sysconfig = require 'gluon.sysconfig'
local uci = require('luci.model.uci').cursor() local uci = require('simple-uci').cursor()
local lutil = require 'luci.util' local lutil = require 'luci.util'
if not sysconfig.lan_ifname then if not sysconfig.lan_ifname then
@ -14,10 +14,10 @@ end
uci:section('network', 'interface', 'mesh_lan', { uci:section('network', 'interface', 'mesh_lan', {
ifname = sysconfig.lan_ifname, ifname = sysconfig.lan_ifname,
type = 'bridge', type = 'bridge',
igmp_snooping = 0, igmp_snooping = false,
proto = 'gluon_mesh', proto = 'gluon_mesh',
transitive = 1, transitive = true,
fixed_mtu = 1, fixed_mtu = true,
}) })
if uci:get('network', 'mesh_lan', 'auto') == nil then if uci:get('network', 'mesh_lan', 'auto') == nil then
@ -36,7 +36,7 @@ if uci:get('network', 'mesh_lan', 'auto') == nil then
end end
end end
uci:set('network', 'mesh_lan', 'auto', enable and 1 or 0) uci:set('network', 'mesh_lan', 'auto', enable or false)
end end
uci:save('network') uci:save('network')

View File

@ -1,6 +1,6 @@
#!/usr/bin/lua #!/usr/bin/lua
local uci = require('luci.model.uci').cursor() local uci = require('simple-uci').cursor()
local function migrate_iface(iface) local function migrate_iface(iface)
if iface.proto ~= 'batadv' or iface.mesh ~= 'bat0' then if iface.proto ~= 'batadv' or iface.mesh ~= 'bat0' then
@ -10,7 +10,7 @@ local function migrate_iface(iface)
local s = iface['.name'] local s = iface['.name']
uci:set('network', s, 'proto', 'gluon_mesh') uci:set('network', s, 'proto', 'gluon_mesh')
uci:set('network', s, 'fixed_mtu', '1') uci:set('network', s, 'fixed_mtu', true)
if iface.mesh_no_rebroadcast then if iface.mesh_no_rebroadcast then
uci:set('network', s, 'transitive', iface.mesh_no_rebroadcast) uci:set('network', s, 'transitive', iface.mesh_no_rebroadcast)

View File

@ -1,11 +1,11 @@
#!/usr/bin/lua #!/usr/bin/lua
local site = require 'gluon.site_config' local site = require 'gluon.site_config'
local uci = require('luci.model.uci').cursor() local uci = require('simple-uci').cursor()
dnsmasq=uci:get_first("dhcp", "dnsmasq") dnsmasq=uci:get_first("dhcp", "dnsmasq")
uci:set('dhcp', dnsmasq, 'localise_queries', '1') uci:set('dhcp', dnsmasq, 'localise_queries', true)
uci:set('dhcp', dnsmasq, 'localservice', '0') uci:set('dhcp', dnsmasq, 'localservice', false)
if site.dns and site.dns.servers then if site.dns and site.dns.servers then
uci:set('dhcp', dnsmasq, 'server', site.dns.servers) uci:set('dhcp', dnsmasq, 'server', site.dns.servers)

View File

@ -34,7 +34,7 @@ local nixio = require 'nixio'
local hash = require 'hash' local hash = require 'hash'
local sysconfig = require 'gluon.sysconfig' local sysconfig = require 'gluon.sysconfig'
local site = require 'gluon.site_config' local site = require 'gluon.site_config'
local uci = require('luci.model.uci').cursor() local uci = require('simple-uci').cursor()
local lutil = require 'luci.util' local lutil = require 'luci.util'
local fs = require 'nixio.fs' local fs = require 'nixio.fs'

View File

@ -1,6 +1,6 @@
<%- <%-
local fs = require 'nixio.fs' local fs = require 'nixio.fs'
local uci = require('luci.model.uci').cursor() local uci = require('simple-uci').cursor()
local util = require 'luci.util' local util = require 'luci.util'
local i18n = require 'luci.i18n' local i18n = require 'luci.i18n'
local pretty_hostname = require 'pretty_hostname' local pretty_hostname = require 'pretty_hostname'
@ -31,8 +31,8 @@
pubkey = 'n/a', pubkey = 'n/a',
} }
local meshvpn_enabled = uci:get("fastd", "mesh_vpn", "enabled", "0") local meshvpn_enabled = uci:get_bool("fastd", "mesh_vpn", "enabled")
if meshvpn_enabled == "1" then if meshvpn_enabled then
local pubkey = util.trim(util.exec('/etc/init.d/fastd show_key mesh_vpn')) local pubkey = util.trim(util.exec('/etc/init.d/fastd show_key mesh_vpn'))
if pubkey ~= '' then if pubkey ~= '' then
values.pubkey = pubkey values.pubkey = pubkey

View File

@ -1,4 +1,4 @@
local uci = luci.model.uci.cursor() local uci = require("simple-uci").cursor()
local util = luci.util local util = luci.util
local f = SimpleForm('mesh_vpn', translate('Mesh VPN')) local f = SimpleForm('mesh_vpn', translate('Mesh VPN'))

View File

@ -1,7 +1,7 @@
local f, s, o local f, s, o
local site = require 'gluon.site_config' local site = require 'gluon.site_config'
local i18n = require "luci.i18n" local i18n = require "luci.i18n"
local uci = luci.model.uci.cursor() local uci = require("simple-uci").cursor()
local config = 'gluon-node-info' local config = 'gluon-node-info'
-- where to read the configuration from -- where to read the configuration from

View File

@ -12,7 +12,7 @@ http://www.apache.org/licenses/LICENSE-2.0
$Id$ $Id$
]]-- ]]--
local uci = luci.model.uci.cursor() local uci = require("simple-uci").cursor()
local lutil = require 'luci.util' local lutil = require 'luci.util'
local sysconfig = require 'gluon.sysconfig' local sysconfig = require 'gluon.sysconfig'
local util = require 'gluon.util' local util = require 'gluon.util'

View File

@ -1,4 +1,4 @@
local uci = luci.model.uci.cursor() local uci = require("simple-uci").cursor()
local util = require 'gluon.util' local util = require 'gluon.util'
local f, s, o, ssid local f, s, o, ssid
@ -49,12 +49,12 @@ function f.handle(self, state, data)
ssid = data.ssid, ssid = data.ssid,
key = data.key, key = data.key,
macaddr = macaddr, macaddr = macaddr,
disabled = 0, disabled = false,
} }
) )
else else
-- disable WAN wifi-iface -- disable WAN wifi-iface
uci:set('wireless', name, "disabled", 1) uci:set('wireless', name, "disabled", true)
end end
end end
) )

View File

@ -16,7 +16,7 @@ $Id$
local sys = require "luci.sys" local sys = require "luci.sys"
local http = require "luci.http" local http = require "luci.http"
local disp = require "luci.dispatcher" local disp = require "luci.dispatcher"
local uci = require("luci.model.uci").cursor() local uci = require("simple-uci").cursor()
local fs = require "nixio.fs" local fs = require "nixio.fs"
local gluon_luci = require "gluon.luci" local gluon_luci = require "gluon.luci"
local pretty_hostname = require "pretty_hostname" local pretty_hostname = require "pretty_hostname"
@ -141,7 +141,7 @@ $Id$
<% <%
if tree.nodes[category] and tree.nodes[category].ucidata then if tree.nodes[category] and tree.nodes[category].ucidata then
local ucic = 0 local ucic = 0
for i, j in pairs(require("luci.model.uci").cursor():changes()) do for i, j in pairs(require("simple-uci").cursor():changes()) do
for k, l in pairs(j) do for k, l in pairs(j) do
for m, n in pairs(l) do for m, n in pairs(l) do
ucic = ucic + 1; ucic = ucic + 1;

View File

@ -1,4 +1,4 @@
local uci = luci.model.uci.cursor() local uci = require("simple-uci").cursor()
local fs = require 'nixio.fs' local fs = require 'nixio.fs'
local iwinfo = require 'iwinfo' local iwinfo = require 'iwinfo'

View File

@ -4,7 +4,7 @@ local sysconfig = require 'gluon.sysconfig'
local site = require 'gluon.site_config' local site = require 'gluon.site_config'
local util = require 'gluon.util' local util = require 'gluon.util'
local uci = require('luci.model.uci').cursor() local uci = require('simple-uci').cursor()
local gw_sel_class local gw_sel_class
@ -19,7 +19,7 @@ uci:section('batman-adv', 'mesh', 'bat0',
gw_mode = 'client', gw_mode = 'client',
gw_sel_class = gw_sel_class, gw_sel_class = gw_sel_class,
hop_penalty = 15, hop_penalty = 15,
multicast_mode = 0, multicast_mode = false,
} }
) )
uci:save('batman-adv') uci:save('batman-adv')
@ -31,7 +31,7 @@ uci:section('network', 'interface', 'bat0',
proto = 'none', proto = 'none',
macaddr = sysconfig.primary_mac, macaddr = sysconfig.primary_mac,
multicast_router = 2, multicast_router = 2,
learning = 0, learning = false,
} }
) )

View File

@ -3,7 +3,7 @@
local sysconfig = require 'gluon.sysconfig' local sysconfig = require 'gluon.sysconfig'
local sysctl = require 'gluon.sysctl' local sysctl = require 'gluon.sysctl'
local uci = require('luci.model.uci').cursor() local uci = require('simple-uci').cursor()
uci:section('network', 'interface', 'client', uci:section('network', 'interface', 'client',
{ {
@ -18,7 +18,7 @@ uci:delete('network', 'client_lan')
if sysconfig.lan_ifname then if sysconfig.lan_ifname then
uci:section('network', 'interface', 'client_lan', uci:section('network', 'interface', 'client_lan',
{ {
unicast_flood = 0, unicast_flood = false,
} }
) )
uci:set('network', 'client_lan', 'ifname', sysconfig.lan_ifname) uci:set('network', 'client_lan', 'ifname', sysconfig.lan_ifname)

View File

@ -4,7 +4,7 @@ local site = require 'gluon.site_config'
local sysconfig = require 'gluon.sysconfig' local sysconfig = require 'gluon.sysconfig'
local sysctl = require 'gluon.sysctl' local sysctl = require 'gluon.sysctl'
local uci = require('luci.model.uci').cursor() local uci = require('simple-uci').cursor()
uci:delete('network', 'local_node_dev') uci:delete('network', 'local_node_dev')
@ -23,9 +23,9 @@ uci:section('network', 'interface', 'local_node',
ifname = 'local-node', ifname = 'local-node',
proto = 'dhcpv6', proto = 'dhcpv6',
reqprefix = 'no', reqprefix = 'no',
peerdns = 1, peerdns = true,
sourcefilter = 0, sourcefilter = false,
keep_ra_dnslifetime = 1, keep_ra_dnslifetime = true,
} }
) )
@ -72,7 +72,7 @@ uci:delete('dhcp', 'local_node')
uci:section('dhcp', 'dhcp', 'local_node', uci:section('dhcp', 'dhcp', 'local_node',
{ {
interface = 'local_node', interface = 'local_node',
ignore = 1, ignore = true,
} }
) )

View File

@ -1,7 +1,7 @@
#!/usr/bin/lua #!/usr/bin/lua
local util = require 'gluon.util' local util = require 'gluon.util'
local uci = require('luci.model.uci').cursor() local uci = require('simple-uci').cursor()
-- fix up potentially duplicate MAC addresses (for meshing) -- fix up potentially duplicate MAC addresses (for meshing)

View File

@ -4,7 +4,7 @@ local site = require 'gluon.site_config'
local users = require 'gluon.users' local users = require 'gluon.users'
local util = require 'gluon.util' local util = require 'gluon.util'
local uci = require('luci.model.uci').cursor() local uci = require('simple-uci').cursor()
local lutil = require 'luci.util' local lutil = require 'luci.util'
@ -17,7 +17,7 @@ users.add_group('gluon-fastd', 800)
local enabled = uci:get('fastd', 'mesh_vpn', 'enabled') local enabled = uci:get('fastd', 'mesh_vpn', 'enabled')
if not enabled then if not enabled then
enabled = site.fastd_mesh_vpn.enabled and 1 or 0 enabled = site.fastd_mesh_vpn.enabled or false
end end
local syslog_level = uci:get('fastd', 'mesh_vpn', 'syslog_level') or 'verbose' local syslog_level = uci:get('fastd', 'mesh_vpn', 'syslog_level') or 'verbose'
@ -56,7 +56,7 @@ uci:section('fastd', 'fastd', 'mesh_vpn',
interface = 'mesh-vpn', interface = 'mesh-vpn',
mode = 'tap', mode = 'tap',
mtu = site.fastd_mesh_vpn.mtu, mtu = site.fastd_mesh_vpn.mtu,
secure_handshakes = 1, secure_handshakes = true,
method = methods, method = methods,
packet_mark = 1, packet_mark = 1,
status_socket = '/var/run/fastd.mesh_vpn.socket', status_socket = '/var/run/fastd.mesh_vpn.socket',
@ -70,7 +70,7 @@ local add_groups
local function add_peer(group, name, config) local function add_peer(group, name, config)
uci:section('fastd', 'peer', group .. '_peer_' .. name, uci:section('fastd', 'peer', group .. '_peer_' .. name,
{ {
enabled = 1, enabled = true,
net = 'mesh_vpn', net = 'mesh_vpn',
group = group, group = group,
key = config.key, key = config.key,
@ -90,7 +90,7 @@ local function add_group(name, config, parent)
uci:section('fastd', 'peer_group', name, uci:section('fastd', 'peer_group', name,
{ {
enabled = 1, enabled = true,
net = 'mesh_vpn', net = 'mesh_vpn',
parent = parent, parent = parent,
peer_limit = config.limit, peer_limit = config.limit,
@ -125,8 +125,8 @@ uci:section('network', 'interface', 'mesh_vpn',
{ {
ifname = 'mesh-vpn', ifname = 'mesh-vpn',
proto = 'gluon_mesh', proto = 'gluon_mesh',
transitive = 1, transitive = true,
fixed_mtu = 1, fixed_mtu = true,
macaddr = util.generate_mac(7), macaddr = util.generate_mac(7),
} }
) )

View File

@ -1,6 +1,6 @@
#!/usr/bin/lua #!/usr/bin/lua
local uci = require 'luci.model.uci' local uci = require 'simple-uci'
local c = uci.cursor() local c = uci.cursor()

View File

@ -1,7 +1,7 @@
#!/usr/bin/lua #!/usr/bin/lua
local site = require 'gluon.site_config' local site = require 'gluon.site_config'
local uci = require('luci.model.uci').cursor() local uci = require('simple-uci').cursor()
local fs = require 'nixio.fs' local fs = require 'nixio.fs'
@ -13,13 +13,13 @@ end
if not uci:get('simple-tc', 'mesh_vpn') then if not uci:get('simple-tc', 'mesh_vpn') then
local config = { local config = {
ifname = 'mesh-vpn', ifname = 'mesh-vpn',
enabled = 0, enabled = false,
} }
if site.fastd_mesh_vpn.bandwidth_limit then if site.fastd_mesh_vpn.bandwidth_limit then
if site.fastd_mesh_vpn.bandwidth_limit.enabled then if site.fastd_mesh_vpn.bandwidth_limit.enabled then
config.enabled = 1 config.enabled = true
end end
config.limit_ingress = site.fastd_mesh_vpn.bandwidth_limit.ingress config.limit_ingress = site.fastd_mesh_vpn.bandwidth_limit.ingress

View File

@ -1,6 +1,6 @@
#!/usr/bin/lua #!/usr/bin/lua
local uci = require('luci.model.uci').cursor() local uci = require('simple-uci').cursor()
-- Allow incoming respondd replies to queries on WAN -- Allow incoming respondd replies to queries on WAN
-- If the query was via multicast, the response isn't matched by --state RELATED -- If the query was via multicast, the response isn't matched by --state RELATED

View File

@ -1,6 +1,6 @@
#!/usr/bin/lua #!/usr/bin/lua
local uci = require('luci.model.uci').cursor() local uci = require('simple-uci').cursor()
local config = 'gluon-node-info' local config = 'gluon-node-info'

View File

@ -1,7 +1,7 @@
#!/usr/bin/lua #!/usr/bin/lua
local site = require 'gluon.site_config' local site = require 'gluon.site_config'
local uci = require('luci.model.uci').cursor() local uci = require('simple-uci').cursor()
local config = 'gluon-node-info' local config = 'gluon-node-info'
local role = uci:get(config, uci:get_first(config, 'system'), 'role') local role = uci:get(config, uci:get_first(config, 'system'), 'role')

View File

@ -1,5 +1,6 @@
#!/usr/bin/lua #!/usr/bin/lua
local uci = require('luci.model.uci').cursor() local uci = require('simple-uci').cursor()
require 'luci.util'
local sname = uci:get_first('gluon-node-info', 'location') local sname = uci:get_first('gluon-node-info', 'location')
if sname then if sname then

View File

@ -1,6 +1,6 @@
#!/usr/bin/lua #!/usr/bin/lua
local uci = require('luci.model.uci').cursor() local uci = require('simple-uci').cursor()
uci:delete('firewall', 'wan_announced') uci:delete('firewall', 'wan_announced')

View File

@ -1,15 +1,14 @@
#!/usr/bin/lua #!/usr/bin/lua
local site = require 'gluon.site_config' local site = require 'gluon.site_config'
local uci = require 'luci.model.uci' local uci = require('simple-uci').cursor()
local c = uci.cursor()
if site.setup_mode if site.setup_mode
and site.setup_mode.skip and site.setup_mode.skip
and not c:get_first('gluon-setup-mode', 'setup_mode', 'configured', false) then and not uci:get_first('gluon-setup-mode', 'setup_mode', 'configured', false) then
local name = c:get_first("gluon-setup-mode", "setup_mode") local name = uci:get_first("gluon-setup-mode", "setup_mode")
c:set("gluon-setup-mode", name, "configured", 1) uci:set("gluon-setup-mode", name, "configured", true)
c:save('gluon-setup-mode') uci:save('gluon-setup-mode')
end end

View File

@ -1,16 +1,14 @@
#!/usr/bin/lua #!/usr/bin/lua
local uci = require 'luci.model.uci' local uci = require('simple-uci').cursor()
local c = uci.cursor()
local old = c:get_first('gluon-config-mode', 'wizard', 'configured') local old = uci:get_first('gluon-config-mode', 'wizard', 'configured')
if old == '1' then if old == '1' then
local setup_mode = c:get_first('gluon-setup-mode', 'setup_mode') local setup_mode = uci:get_first('gluon-setup-mode', 'setup_mode')
c:set('gluon-setup-mode', setup_mode, 'configured', '1') uci:set('gluon-setup-mode', setup_mode, 'configured', true)
c:save('gluon-setup-mode') uci:save('gluon-setup-mode')
end end
os.remove('/etc/config/gluon-config-mode') os.remove('/etc/config/gluon-config-mode')

View File

@ -5,7 +5,7 @@ local RESOLV_CONF = RESOLV_CONF_DIR .. '/resolv.conf'
local ubus = require('ubus').connect() local ubus = require('ubus').connect()
local uci = require('luci.model.uci').cursor() local uci = require('simple-uci').cursor()
local fs = require 'nixio.fs' local fs = require 'nixio.fs'