Skip to content
Snippets Groups Projects
Unverified Commit 6cf03bab authored by Matthias Schiffer's avatar Matthias Schiffer
Browse files

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.
parent 6f48fc42
No related branches found
No related tags found
No related merge requests found
Showing
with 50 additions and 50 deletions
#!/usr/bin/lua
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
uci:section('network', 'interface', 'mesh_wan', {
ifname = 'br-wan',
proto = 'gluon_mesh',
transitive = 1,
fixed_mtu = 1,
auto = site.mesh_on_wan and 1 or 0,
transitive = true,
fixed_mtu = true,
auto = site.mesh_on_wan or false,
})
end
......
......@@ -4,7 +4,7 @@ local site = require 'gluon.site_config'
local util = require 'gluon.util'
local sysconfig = require 'gluon.sysconfig'
local uci = require('luci.model.uci').cursor()
local uci = require('simple-uci').cursor()
local lutil = require 'luci.util'
if not sysconfig.lan_ifname then
......@@ -14,10 +14,10 @@ end
uci:section('network', 'interface', 'mesh_lan', {
ifname = sysconfig.lan_ifname,
type = 'bridge',
igmp_snooping = 0,
igmp_snooping = false,
proto = 'gluon_mesh',
transitive = 1,
fixed_mtu = 1,
transitive = true,
fixed_mtu = true,
})
if uci:get('network', 'mesh_lan', 'auto') == nil then
......@@ -36,7 +36,7 @@ if uci:get('network', 'mesh_lan', 'auto') == nil then
end
end
uci:set('network', 'mesh_lan', 'auto', enable and 1 or 0)
uci:set('network', 'mesh_lan', 'auto', enable or false)
end
uci:save('network')
#!/usr/bin/lua
local uci = require('luci.model.uci').cursor()
local uci = require('simple-uci').cursor()
local function migrate_iface(iface)
if iface.proto ~= 'batadv' or iface.mesh ~= 'bat0' then
......@@ -10,7 +10,7 @@ local function migrate_iface(iface)
local s = iface['.name']
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
uci:set('network', s, 'transitive', iface.mesh_no_rebroadcast)
......
#!/usr/bin/lua
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")
uci:set('dhcp', dnsmasq, 'localise_queries', '1')
uci:set('dhcp', dnsmasq, 'localservice', '0')
uci:set('dhcp', dnsmasq, 'localise_queries', true)
uci:set('dhcp', dnsmasq, 'localservice', false)
if site.dns and site.dns.servers then
uci:set('dhcp', dnsmasq, 'server', site.dns.servers)
......
......@@ -34,7 +34,7 @@ local nixio = require 'nixio'
local hash = require 'hash'
local sysconfig = require 'gluon.sysconfig'
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 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 i18n = require 'luci.i18n'
local pretty_hostname = require 'pretty_hostname'
......@@ -31,8 +31,8 @@
pubkey = 'n/a',
}
local meshvpn_enabled = uci:get("fastd", "mesh_vpn", "enabled", "0")
if meshvpn_enabled == "1" then
local meshvpn_enabled = uci:get_bool("fastd", "mesh_vpn", "enabled")
if meshvpn_enabled then
local pubkey = util.trim(util.exec('/etc/init.d/fastd show_key mesh_vpn'))
if pubkey ~= '' then
values.pubkey = pubkey
......
local uci = luci.model.uci.cursor()
local uci = require("simple-uci").cursor()
local util = luci.util
local f = SimpleForm('mesh_vpn', translate('Mesh VPN'))
......
local f, s, o
local site = require 'gluon.site_config'
local i18n = require "luci.i18n"
local uci = luci.model.uci.cursor()
local uci = require("simple-uci").cursor()
local config = 'gluon-node-info'
-- where to read the configuration from
......
......@@ -12,7 +12,7 @@ http://www.apache.org/licenses/LICENSE-2.0
$Id$
]]--
local uci = luci.model.uci.cursor()
local uci = require("simple-uci").cursor()
local lutil = require 'luci.util'
local sysconfig = require 'gluon.sysconfig'
local util = require 'gluon.util'
......
local uci = luci.model.uci.cursor()
local uci = require("simple-uci").cursor()
local util = require 'gluon.util'
local f, s, o, ssid
......@@ -49,12 +49,12 @@ function f.handle(self, state, data)
ssid = data.ssid,
key = data.key,
macaddr = macaddr,
disabled = 0,
disabled = false,
}
)
else
-- disable WAN wifi-iface
uci:set('wireless', name, "disabled", 1)
uci:set('wireless', name, "disabled", true)
end
end
)
......
......@@ -16,7 +16,7 @@ $Id$
local sys = require "luci.sys"
local http = require "luci.http"
local disp = require "luci.dispatcher"
local uci = require("luci.model.uci").cursor()
local uci = require("simple-uci").cursor()
local fs = require "nixio.fs"
local gluon_luci = require "gluon.luci"
local pretty_hostname = require "pretty_hostname"
......@@ -141,7 +141,7 @@ $Id$
<%
if tree.nodes[category] and tree.nodes[category].ucidata then
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 m, n in pairs(l) do
ucic = ucic + 1;
......
local uci = luci.model.uci.cursor()
local uci = require("simple-uci").cursor()
local fs = require 'nixio.fs'
local iwinfo = require 'iwinfo'
......
......@@ -4,7 +4,7 @@ local sysconfig = require 'gluon.sysconfig'
local site = require 'gluon.site_config'
local util = require 'gluon.util'
local uci = require('luci.model.uci').cursor()
local uci = require('simple-uci').cursor()
local gw_sel_class
......@@ -19,7 +19,7 @@ uci:section('batman-adv', 'mesh', 'bat0',
gw_mode = 'client',
gw_sel_class = gw_sel_class,
hop_penalty = 15,
multicast_mode = 0,
multicast_mode = false,
}
)
uci:save('batman-adv')
......@@ -31,7 +31,7 @@ uci:section('network', 'interface', 'bat0',
proto = 'none',
macaddr = sysconfig.primary_mac,
multicast_router = 2,
learning = 0,
learning = false,
}
)
......
......@@ -3,7 +3,7 @@
local sysconfig = require 'gluon.sysconfig'
local sysctl = require 'gluon.sysctl'
local uci = require('luci.model.uci').cursor()
local uci = require('simple-uci').cursor()
uci:section('network', 'interface', 'client',
{
......@@ -18,7 +18,7 @@ uci:delete('network', 'client_lan')
if sysconfig.lan_ifname then
uci:section('network', 'interface', 'client_lan',
{
unicast_flood = 0,
unicast_flood = false,
}
)
uci:set('network', 'client_lan', 'ifname', sysconfig.lan_ifname)
......
......@@ -4,7 +4,7 @@ local site = require 'gluon.site_config'
local sysconfig = require 'gluon.sysconfig'
local sysctl = require 'gluon.sysctl'
local uci = require('luci.model.uci').cursor()
local uci = require('simple-uci').cursor()
uci:delete('network', 'local_node_dev')
......@@ -23,9 +23,9 @@ uci:section('network', 'interface', 'local_node',
ifname = 'local-node',
proto = 'dhcpv6',
reqprefix = 'no',
peerdns = 1,
sourcefilter = 0,
keep_ra_dnslifetime = 1,
peerdns = true,
sourcefilter = false,
keep_ra_dnslifetime = true,
}
)
......@@ -72,7 +72,7 @@ uci:delete('dhcp', 'local_node')
uci:section('dhcp', 'dhcp', 'local_node',
{
interface = 'local_node',
ignore = 1,
ignore = true,
}
)
......
#!/usr/bin/lua
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)
......
......@@ -4,7 +4,7 @@ local site = require 'gluon.site_config'
local users = require 'gluon.users'
local util = require 'gluon.util'
local uci = require('luci.model.uci').cursor()
local uci = require('simple-uci').cursor()
local lutil = require 'luci.util'
......@@ -17,7 +17,7 @@ users.add_group('gluon-fastd', 800)
local enabled = uci:get('fastd', 'mesh_vpn', 'enabled')
if not enabled then
enabled = site.fastd_mesh_vpn.enabled and 1 or 0
enabled = site.fastd_mesh_vpn.enabled or false
end
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',
mode = 'tap',
mtu = site.fastd_mesh_vpn.mtu,
secure_handshakes = 1,
secure_handshakes = true,
method = methods,
packet_mark = 1,
status_socket = '/var/run/fastd.mesh_vpn.socket',
......@@ -70,7 +70,7 @@ local add_groups
local function add_peer(group, name, config)
uci:section('fastd', 'peer', group .. '_peer_' .. name,
{
enabled = 1,
enabled = true,
net = 'mesh_vpn',
group = group,
key = config.key,
......@@ -90,7 +90,7 @@ local function add_group(name, config, parent)
uci:section('fastd', 'peer_group', name,
{
enabled = 1,
enabled = true,
net = 'mesh_vpn',
parent = parent,
peer_limit = config.limit,
......@@ -125,8 +125,8 @@ uci:section('network', 'interface', 'mesh_vpn',
{
ifname = 'mesh-vpn',
proto = 'gluon_mesh',
transitive = 1,
fixed_mtu = 1,
transitive = true,
fixed_mtu = true,
macaddr = util.generate_mac(7),
}
)
......
#!/usr/bin/lua
local uci = require 'luci.model.uci'
local uci = require 'simple-uci'
local c = uci.cursor()
......
#!/usr/bin/lua
local site = require 'gluon.site_config'
local uci = require('luci.model.uci').cursor()
local uci = require('simple-uci').cursor()
local fs = require 'nixio.fs'
......@@ -13,13 +13,13 @@ end
if not uci:get('simple-tc', 'mesh_vpn') then
local config = {
ifname = 'mesh-vpn',
enabled = 0,
enabled = false,
}
if site.fastd_mesh_vpn.bandwidth_limit then
if site.fastd_mesh_vpn.bandwidth_limit.enabled then
config.enabled = 1
config.enabled = true
end
config.limit_ingress = site.fastd_mesh_vpn.bandwidth_limit.ingress
......
#!/usr/bin/lua
local uci = require('luci.model.uci').cursor()
local uci = require('simple-uci').cursor()
-- Allow incoming respondd replies to queries on WAN
-- If the query was via multicast, the response isn't matched by --state RELATED
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment