diff --git a/package/gluon-alfred/luasrc/lib/gluon/upgrade/500-enable-alfred b/package/gluon-alfred/luasrc/lib/gluon/upgrade/500-enable-alfred index ce4ac0ad..e4555e55 100755 --- a/package/gluon-alfred/luasrc/lib/gluon/upgrade/500-enable-alfred +++ b/package/gluon-alfred/luasrc/lib/gluon/upgrade/500-enable-alfred @@ -1,18 +1,14 @@ #!/usr/bin/lua -local uci = require 'luci.model.uci' -local c = uci.cursor() +local uci = require('simple-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') -c:section('alfred', 'alfred', 'alfred', - { - interface = 'local-node', - mode = 'slave', - batmanif = 'bat0', - start_vis = '1', - run_facters = '0', - } -) - -c:save('alfred') +uci:save('alfred') diff --git a/package/gluon-autoupdater/luasrc/lib/gluon/upgrade/500-autoupdater b/package/gluon-autoupdater/luasrc/lib/gluon/upgrade/500-autoupdater index 17006b70..e43d6ea2 100755 --- a/package/gluon-autoupdater/luasrc/lib/gluon/upgrade/500-autoupdater +++ b/package/gluon-autoupdater/luasrc/lib/gluon/upgrade/500-autoupdater @@ -1,45 +1,39 @@ #!/usr/bin/lua local site = require 'gluon.site_config' -local uci = require 'luci.model.uci' - -local c = uci.cursor() +local uci = require('simple-uci').cursor() for name, config in pairs(site.autoupdater.branches) do - c:delete('autoupdater', name) - c:section('autoupdater', 'branch', name, - { - name = config.name, - mirror = config.mirrors, - good_signatures = config.good_signatures, - pubkey = config.pubkeys, - } - ) + uci:delete('autoupdater', name) + uci:section('autoupdater', 'branch', name, { + name = config.name, + mirror = config.mirrors, + good_signatures = config.good_signatures, + pubkey = config.pubkeys, + }) end -if not c:get('autoupdater', 'settings') then - local enabled = 0 +if not uci:get('autoupdater', 'settings') then + local enabled = false local branch = site.autoupdater.branch local f = io.open('/lib/gluon/autoupdater/default_branch') if f then - enabled = 1 + enabled = true branch = f:read('*line') f:close() end - c:section('autoupdater', 'autoupdater', 'settings', - { - enabled = enabled, - branch = branch, - } - ) + uci:section('autoupdater', 'autoupdater', 'settings', { + enabled = enabled, + branch = branch, + }) 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' diff --git a/package/gluon-client-bridge/luasrc/lib/gluon/upgrade/300-gluon-client-bridge-network b/package/gluon-client-bridge/luasrc/lib/gluon/upgrade/300-gluon-client-bridge-network index 7540ecb5..fbc97a1f 100755 --- a/package/gluon-client-bridge/luasrc/lib/gluon/upgrade/300-gluon-client-bridge-network +++ b/package/gluon-client-bridge/luasrc/lib/gluon/upgrade/300-gluon-client-bridge-network @@ -6,7 +6,7 @@ local util = require 'gluon.util' local ip = require 'luci.ip' local lutil = require 'luci.util' -local uci = require('luci.model.uci').cursor() +local uci = require('simple-uci').cursor() local ip4, netmask, ip6 @@ -58,15 +58,15 @@ uci:save('network') local dnsmasq = uci:get_first('dhcp', 'dnsmasq') -uci:set('dhcp', dnsmasq, 'boguspriv', 0) -uci:set('dhcp', dnsmasq, 'localise_queries', 0) -uci:set('dhcp', dnsmasq, 'rebind_protection', 0) +uci:set('dhcp', dnsmasq, 'boguspriv', false) +uci:set('dhcp', dnsmasq, 'localise_queries', false) +uci:set('dhcp', dnsmasq, 'rebind_protection', false) uci:delete('dhcp', 'client') uci:section('dhcp', 'dhcp', 'client', { interface = 'client', - ignore = 1, + ignore = true, } ) diff --git a/package/gluon-client-bridge/luasrc/lib/gluon/upgrade/320-gluon-client-bridge-wireless b/package/gluon-client-bridge/luasrc/lib/gluon/upgrade/320-gluon-client-bridge-wireless index 6c25f995..8c7e07e1 100755 --- a/package/gluon-client-bridge/luasrc/lib/gluon/upgrade/320-gluon-client-bridge-wireless +++ b/package/gluon-client-bridge/luasrc/lib/gluon/upgrade/320-gluon-client-bridge-wireless @@ -3,16 +3,18 @@ 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 function is_disabled(config, name) - local disabled = config and config.disabled + local disabled if uci:get('wireless', name) then disabled = uci:get_bool('wireless', name, 'disabled') + else + disabled = config and config.disabled end - return disabled and 1 or 0 + return disabled end local function configure_client(config, radio, index, suffix) @@ -38,7 +40,7 @@ local function configure_client(config, radio, index, suffix) ssid = config.ssid, macaddr = macaddr, ifname = suffix and 'client' .. suffix, - disabled = disabled, + disabled = disabled or false, } ) end diff --git a/package/gluon-config-mode-autoupdater/luasrc/lib/gluon/config-mode/wizard/0050-autoupdater-info.lua b/package/gluon-config-mode-autoupdater/luasrc/lib/gluon/config-mode/wizard/0050-autoupdater-info.lua index 3bbe0390..e49bd7d7 100644 --- a/package/gluon-config-mode-autoupdater/luasrc/lib/gluon/config-mode/wizard/0050-autoupdater-info.lua +++ b/package/gluon-config-mode-autoupdater/luasrc/lib/gluon/config-mode/wizard/0050-autoupdater-info.lua @@ -1,6 +1,6 @@ local cbi = require "luci.cbi" local i18n = require "luci.i18n" -local uci = luci.model.uci.cursor() +local uci = require("simple-uci").cursor() local M = {} diff --git a/package/gluon-config-mode-contact-info/luasrc/lib/gluon/config-mode/wizard/0500-contact-info.lua b/package/gluon-config-mode-contact-info/luasrc/lib/gluon/config-mode/wizard/0500-contact-info.lua index 46ff4567..94d5f00c 100644 --- a/package/gluon-config-mode-contact-info/luasrc/lib/gluon/config-mode/wizard/0500-contact-info.lua +++ b/package/gluon-config-mode-contact-info/luasrc/lib/gluon/config-mode/wizard/0500-contact-info.lua @@ -1,6 +1,6 @@ local cbi = require "luci.cbi" local i18n = require "luci.i18n" -local uci = luci.model.uci.cursor() +local uci = require("simple-uci").cursor() local site = require 'gluon.site_config' local M = {} diff --git a/package/gluon-config-mode-core/luasrc/lib/gluon/config-mode/reboot/0900-msg-reboot.lua b/package/gluon-config-mode-core/luasrc/lib/gluon/config-mode/reboot/0900-msg-reboot.lua index 96557f41..0e2a7e25 100644 --- a/package/gluon-config-mode-core/luasrc/lib/gluon/config-mode/reboot/0900-msg-reboot.lua +++ b/package/gluon-config-mode-core/luasrc/lib/gluon/config-mode/reboot/0900-msg-reboot.lua @@ -4,7 +4,7 @@ local gluon_luci = require 'gluon.luci' local sysconfig = require 'gluon.sysconfig' 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 contact = uci:get_first('gluon-node-info', 'owner', 'contact') diff --git a/package/gluon-config-mode-core/luasrc/usr/lib/lua/luci/model/cbi/gluon-config-mode/wizard.lua b/package/gluon-config-mode-core/luasrc/usr/lib/lua/luci/model/cbi/gluon-config-mode/wizard.lua index 569dd60e..b5dbe0af 100644 --- a/package/gluon-config-mode-core/luasrc/usr/lib/lua/luci/model/cbi/gluon-config-mode/wizard.lua +++ b/package/gluon-config-mode-core/luasrc/usr/lib/lua/luci/model/cbi/gluon-config-mode/wizard.lua @@ -1,6 +1,6 @@ local wizard_dir = "/lib/gluon/config-mode/wizard/" local i18n = luci.i18n -local uci = luci.model.uci.cursor() +local uci = require("simple-uci").cursor() local fs = require "nixio.fs" local util = require "nixio.util" local f, s diff --git a/package/gluon-config-mode-geo-location/luasrc/lib/gluon/config-mode/wizard/0400-geo-location.lua b/package/gluon-config-mode-geo-location/luasrc/lib/gluon/config-mode/wizard/0400-geo-location.lua index 04e9b144..6821da59 100644 --- a/package/gluon-config-mode-geo-location/luasrc/lib/gluon/config-mode/wizard/0400-geo-location.lua +++ b/package/gluon-config-mode-geo-location/luasrc/lib/gluon/config-mode/wizard/0400-geo-location.lua @@ -1,6 +1,6 @@ local cbi = require "luci.cbi" local i18n = require "luci.i18n" -local uci = luci.model.uci.cursor() +local uci = require("simple-uci").cursor() local site = require 'gluon.site_config' local M = {} diff --git a/package/gluon-config-mode-hostname/luasrc/lib/gluon/config-mode/wizard/0100-hostname.lua b/package/gluon-config-mode-hostname/luasrc/lib/gluon/config-mode/wizard/0100-hostname.lua index 2ffde723..0f7d0b2c 100644 --- a/package/gluon-config-mode-hostname/luasrc/lib/gluon/config-mode/wizard/0100-hostname.lua +++ b/package/gluon-config-mode-hostname/luasrc/lib/gluon/config-mode/wizard/0100-hostname.lua @@ -1,7 +1,7 @@ local cbi = require "luci.cbi" local i18n = require "luci.i18n" local pretty_hostname = require "pretty_hostname" -local uci = luci.model.uci.cursor() +local uci = require("simple-uci").cursor() local M = {} diff --git a/package/gluon-config-mode-mesh-vpn/luasrc/lib/gluon/config-mode/reboot/0100-mesh-vpn.lua b/package/gluon-config-mode-mesh-vpn/luasrc/lib/gluon/config-mode/reboot/0100-mesh-vpn.lua index 07b6d228..f68d230e 100644 --- a/package/gluon-config-mode-mesh-vpn/luasrc/lib/gluon/config-mode/reboot/0100-mesh-vpn.lua +++ b/package/gluon-config-mode-mesh-vpn/luasrc/lib/gluon/config-mode/reboot/0100-mesh-vpn.lua @@ -1,7 +1,7 @@ -local uci = luci.model.uci.cursor() -local meshvpn_enabled = uci:get("fastd", "mesh_vpn", "enabled", "0") +local uci = require("simple-uci").cursor() +local meshvpn_enabled = uci:get_bool("fastd", "mesh_vpn", "enabled") -if meshvpn_enabled ~= "1" then +if not meshvpn_enabled then return nil else local i18n = require "luci.i18n" diff --git a/package/gluon-config-mode-mesh-vpn/luasrc/lib/gluon/config-mode/wizard/0300-mesh-vpn.lua b/package/gluon-config-mode-mesh-vpn/luasrc/lib/gluon/config-mode/wizard/0300-mesh-vpn.lua index f0172421..87109f37 100644 --- a/package/gluon-config-mode-mesh-vpn/luasrc/lib/gluon/config-mode/wizard/0300-mesh-vpn.lua +++ b/package/gluon-config-mode-mesh-vpn/luasrc/lib/gluon/config-mode/wizard/0300-mesh-vpn.lua @@ -1,6 +1,6 @@ local cbi = require "luci.cbi" local i18n = require "luci.i18n" -local uci = luci.model.uci.cursor() +local uci = require("simple-uci").cursor() local M = {} diff --git a/package/gluon-core/Makefile b/package/gluon-core/Makefile index 5a15fc36..43d00e53 100644 --- a/package/gluon-core/Makefile +++ b/package/gluon-core/Makefile @@ -15,7 +15,7 @@ define Package/gluon-core SECTION:=gluon CATEGORY:=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 define Package/gluon-core/description diff --git a/package/gluon-core/luasrc/lib/gluon/upgrade/020-interfaces b/package/gluon-core/luasrc/lib/gluon/upgrade/020-interfaces index 7ce1af4d..c8ef8600 100755 --- a/package/gluon-core/luasrc/lib/gluon/upgrade/020-interfaces +++ b/package/gluon-core/luasrc/lib/gluon/upgrade/020-interfaces @@ -4,7 +4,7 @@ local sysconfig = require 'gluon.sysconfig' local gluon_util = require 'gluon.util' 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 diff --git a/package/gluon-core/luasrc/lib/gluon/upgrade/030-system b/package/gluon-core/luasrc/lib/gluon/upgrade/030-system index 90ad1ba5..e51d9f73 100755 --- a/package/gluon-core/luasrc/lib/gluon/upgrade/030-system +++ b/package/gluon-core/luasrc/lib/gluon/upgrade/030-system @@ -7,7 +7,7 @@ local sysconfig = require 'gluon.sysconfig' if not sysconfig.gluon_version then 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 system = uci:get_first('system', 'system') diff --git a/package/gluon-core/luasrc/lib/gluon/upgrade/110-network b/package/gluon-core/luasrc/lib/gluon/upgrade/110-network index c61b81d1..72a9a7eb 100755 --- a/package/gluon-core/luasrc/lib/gluon/upgrade/110-network +++ b/package/gluon-core/luasrc/lib/gluon/upgrade/110-network @@ -1,6 +1,6 @@ #!/usr/bin/lua -local uci = require('luci.model.uci').cursor() +local uci = require('simple-uci').cursor() local sysctl = require 'gluon.sysctl' local sysconfig = require 'gluon.sysconfig' @@ -9,9 +9,9 @@ uci:section('network', 'interface', 'wan', { ifname = sysconfig.wan_ifname, type = 'bridge', - multicast_querier = 0, - peerdns = 0, - auto = 1, + multicast_querier = false, + peerdns = false, + auto = true, } ) uci:delete('network', 'wan', 'igmp_snooping') @@ -24,9 +24,9 @@ end uci:section('network', 'interface', 'wan6', { ifname = 'br-wan', - peerdns = 0, + peerdns = false, ip6table = 1, - sourcefilter = 0, + sourcefilter = false, } ) diff --git a/package/gluon-core/luasrc/lib/gluon/upgrade/120-ntp-servers b/package/gluon-core/luasrc/lib/gluon/upgrade/120-ntp-servers index f38c1f5d..2afe3a2a 100755 --- a/package/gluon-core/luasrc/lib/gluon/upgrade/120-ntp-servers +++ b/package/gluon-core/luasrc/lib/gluon/upgrade/120-ntp-servers @@ -1,7 +1,7 @@ #!/usr/bin/lua 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 os.exit(0) diff --git a/package/gluon-core/luasrc/lib/gluon/upgrade/140-firewall-rules b/package/gluon-core/luasrc/lib/gluon/upgrade/140-firewall-rules index abd45381..9af4e515 100755 --- a/package/gluon-core/luasrc/lib/gluon/upgrade/140-firewall-rules +++ b/package/gluon-core/luasrc/lib/gluon/upgrade/140-firewall-rules @@ -1,29 +1,25 @@ #!/usr/bin/lua local site = require 'gluon.site_config' -local uci = require 'luci.model.uci' - -local c = uci.cursor() +local uci = require('simple-uci').cursor() local function reject_input_on_wan(zone) if zone.name == 'wan' then - c:set('firewall', zone['.name'], 'input', 'REJECT') - c:set('firewall', zone['.name'], 'conntrack', '1') + uci:set('firewall', zone['.name'], 'input', 'REJECT') + uci:set('firewall', zone['.name'], 'conntrack', true) end return true end -c:foreach('firewall', 'zone', reject_input_on_wan) +uci:foreach('firewall', 'zone', reject_input_on_wan) -c:section('firewall', 'rule', 'wan_ssh', - { - name = 'wan_ssh', - src = 'wan', - dest_port = '22', - proto = 'tcp', - target = 'ACCEPT', - } -) +uci:section('firewall', 'rule', 'wan_ssh', { + name = 'wan_ssh', + src = 'wan', + dest_port = '22', + proto = 'tcp', + target = 'ACCEPT', +}) -c:save('firewall') +uci:save('firewall') diff --git a/package/gluon-core/luasrc/lib/gluon/upgrade/150-poe-passthrough b/package/gluon-core/luasrc/lib/gluon/upgrade/150-poe-passthrough index 81e6740b..1ee362b8 100755 --- a/package/gluon-core/luasrc/lib/gluon/upgrade/150-poe-passthrough +++ b/package/gluon-core/luasrc/lib/gluon/upgrade/150-poe-passthrough @@ -3,11 +3,11 @@ local sysconfig = require 'gluon.sysconfig' local site = require 'gluon.site_config' -if (not sysconfig.gluon_version) and (site.poe_passthrough == true) then - local uci = require('luci.model.uci').cursor() +if (not sysconfig.gluon_version) and site.poe_passthrough then + local uci = require('simple-uci').cursor() 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') end end diff --git a/package/gluon-core/luasrc/lib/gluon/upgrade/200-wireless b/package/gluon-core/luasrc/lib/gluon/upgrade/200-wireless index 6e809572..e6234e3d 100755 --- a/package/gluon-core/luasrc/lib/gluon/upgrade/200-wireless +++ b/package/gluon-core/luasrc/lib/gluon/upgrade/200-wireless @@ -4,7 +4,7 @@ local util = require 'gluon.util' local site = require 'gluon.site_config' local sysconfig = require 'gluon.sysconfig' -local uci = require('luci.model.uci').cursor() +local uci = require('simple-uci').cursor() -- Initial if not sysconfig.gluon_version then @@ -22,6 +22,8 @@ end local function is_disabled(name) if uci:get('wireless', name) then return uci:get_bool('wireless', name, 'disabled') + else + return false end end @@ -82,7 +84,7 @@ local function configure_ibss(config, radio, index, suffix, disabled) macaddr = macaddr, mcast_rate = config.mcast_rate, ifname = suffix and 'ibss' .. suffix, - disabled = disabled and 1 or 0, + disabled = disabled, } ) end @@ -116,11 +118,11 @@ local function configure_mesh(config, radio, index, suffix, disabled) network = name, mode = 'mesh', mesh_id = config.id, - mesh_fwding = 0, + mesh_fwding = false, macaddr = macaddr, mcast_rate = config.mcast_rate, ifname = suffix and 'mesh' .. suffix, - disabled = disabled and 1 or 0, + disabled = disabled, macfilter = macfilter, maclist = maclist, } diff --git a/package/gluon-core/luasrc/lib/gluon/upgrade/210-interface-wan b/package/gluon-core/luasrc/lib/gluon/upgrade/210-interface-wan index 0c780f07..c5bb11ad 100755 --- a/package/gluon-core/luasrc/lib/gluon/upgrade/210-interface-wan +++ b/package/gluon-core/luasrc/lib/gluon/upgrade/210-interface-wan @@ -1,15 +1,15 @@ #!/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 diff --git a/package/gluon-core/luasrc/lib/gluon/upgrade/220-interface-lan b/package/gluon-core/luasrc/lib/gluon/upgrade/220-interface-lan index 21759aa9..9ff04650 100755 --- a/package/gluon-core/luasrc/lib/gluon/upgrade/220-interface-lan +++ b/package/gluon-core/luasrc/lib/gluon/upgrade/220-interface-lan @@ -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') diff --git a/package/gluon-core/luasrc/lib/gluon/upgrade/800-migrate-batadv b/package/gluon-core/luasrc/lib/gluon/upgrade/800-migrate-batadv index 7843e6a1..ddd03c0a 100755 --- a/package/gluon-core/luasrc/lib/gluon/upgrade/800-migrate-batadv +++ b/package/gluon-core/luasrc/lib/gluon/upgrade/800-migrate-batadv @@ -1,6 +1,6 @@ #!/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) diff --git a/package/gluon-core/luasrc/lib/gluon/upgrade/820-dns-config b/package/gluon-core/luasrc/lib/gluon/upgrade/820-dns-config index e95a53a1..5b64b413 100755 --- a/package/gluon-core/luasrc/lib/gluon/upgrade/820-dns-config +++ b/package/gluon-core/luasrc/lib/gluon/upgrade/820-dns-config @@ -1,11 +1,11 @@ #!/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) diff --git a/package/gluon-core/luasrc/usr/lib/lua/gluon/util.lua b/package/gluon-core/luasrc/usr/lib/lua/gluon/util.lua index f013ec23..68c25445 100644 --- a/package/gluon-core/luasrc/usr/lib/lua/gluon/util.lua +++ b/package/gluon-core/luasrc/usr/lib/lua/gluon/util.lua @@ -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' diff --git a/package/gluon-luci-admin/files/usr/lib/lua/luci/view/admin/info.htm b/package/gluon-luci-admin/files/usr/lib/lua/luci/view/admin/info.htm index 03f3f2ca..c60761e5 100644 --- a/package/gluon-luci-admin/files/usr/lib/lua/luci/view/admin/info.htm +++ b/package/gluon-luci-admin/files/usr/lib/lua/luci/view/admin/info.htm @@ -1,6 +1,6 @@ <%- 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 diff --git a/package/gluon-luci-mesh-vpn-fastd/luasrc/usr/lib/lua/luci/model/cbi/admin/mesh_vpn_fastd.lua b/package/gluon-luci-mesh-vpn-fastd/luasrc/usr/lib/lua/luci/model/cbi/admin/mesh_vpn_fastd.lua index 1e918936..7dc5267c 100644 --- a/package/gluon-luci-mesh-vpn-fastd/luasrc/usr/lib/lua/luci/model/cbi/admin/mesh_vpn_fastd.lua +++ b/package/gluon-luci-mesh-vpn-fastd/luasrc/usr/lib/lua/luci/model/cbi/admin/mesh_vpn_fastd.lua @@ -1,4 +1,4 @@ -local uci = luci.model.uci.cursor() +local uci = require("simple-uci").cursor() local util = luci.util local f = SimpleForm('mesh_vpn', translate('Mesh VPN')) diff --git a/package/gluon-luci-node-role/luasrc/usr/lib/lua/luci/model/cbi/admin/noderole.lua b/package/gluon-luci-node-role/luasrc/usr/lib/lua/luci/model/cbi/admin/noderole.lua index 8450a39c..ea8202a4 100644 --- a/package/gluon-luci-node-role/luasrc/usr/lib/lua/luci/model/cbi/admin/noderole.lua +++ b/package/gluon-luci-node-role/luasrc/usr/lib/lua/luci/model/cbi/admin/noderole.lua @@ -1,7 +1,7 @@ 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 diff --git a/package/gluon-luci-portconfig/luasrc/usr/lib/lua/luci/model/cbi/admin/portconfig.lua b/package/gluon-luci-portconfig/luasrc/usr/lib/lua/luci/model/cbi/admin/portconfig.lua index 2cab7606..2af1cbb8 100644 --- a/package/gluon-luci-portconfig/luasrc/usr/lib/lua/luci/model/cbi/admin/portconfig.lua +++ b/package/gluon-luci-portconfig/luasrc/usr/lib/lua/luci/model/cbi/admin/portconfig.lua @@ -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' diff --git a/package/gluon-luci-private-wifi/luasrc/usr/lib/lua/luci/model/cbi/admin/privatewifi.lua b/package/gluon-luci-private-wifi/luasrc/usr/lib/lua/luci/model/cbi/admin/privatewifi.lua index c4ff78d9..08e987a5 100644 --- a/package/gluon-luci-private-wifi/luasrc/usr/lib/lua/luci/model/cbi/admin/privatewifi.lua +++ b/package/gluon-luci-private-wifi/luasrc/usr/lib/lua/luci/model/cbi/admin/privatewifi.lua @@ -1,4 +1,4 @@ -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 ) diff --git a/package/gluon-luci-theme/files/usr/lib/lua/luci/view/themes/gluon/header.htm b/package/gluon-luci-theme/files/usr/lib/lua/luci/view/themes/gluon/header.htm index 7e894603..8b374c57 100644 --- a/package/gluon-luci-theme/files/usr/lib/lua/luci/view/themes/gluon/header.htm +++ b/package/gluon-luci-theme/files/usr/lib/lua/luci/view/themes/gluon/header.htm @@ -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; diff --git a/package/gluon-luci-wifi-config/luasrc/usr/lib/lua/luci/model/cbi/admin/wifi-config.lua b/package/gluon-luci-wifi-config/luasrc/usr/lib/lua/luci/model/cbi/admin/wifi-config.lua index 4f280de1..903d33a6 100644 --- a/package/gluon-luci-wifi-config/luasrc/usr/lib/lua/luci/model/cbi/admin/wifi-config.lua +++ b/package/gluon-luci-wifi-config/luasrc/usr/lib/lua/luci/model/cbi/admin/wifi-config.lua @@ -1,4 +1,4 @@ -local uci = luci.model.uci.cursor() +local uci = require("simple-uci").cursor() local fs = require 'nixio.fs' local iwinfo = require 'iwinfo' diff --git a/package/gluon-mesh-batman-adv-core/luasrc/lib/gluon/upgrade/310-gluon-mesh-batman-adv-core-mesh b/package/gluon-mesh-batman-adv-core/luasrc/lib/gluon/upgrade/310-gluon-mesh-batman-adv-core-mesh index 6558671c..3ae48c85 100755 --- a/package/gluon-mesh-batman-adv-core/luasrc/lib/gluon/upgrade/310-gluon-mesh-batman-adv-core-mesh +++ b/package/gluon-mesh-batman-adv-core/luasrc/lib/gluon/upgrade/310-gluon-mesh-batman-adv-core-mesh @@ -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, } ) diff --git a/package/gluon-mesh-batman-adv-core/luasrc/lib/gluon/upgrade/320-gluon-mesh-batman-adv-core-client-bridge b/package/gluon-mesh-batman-adv-core/luasrc/lib/gluon/upgrade/320-gluon-mesh-batman-adv-core-client-bridge index 30a0dfb2..2d356e30 100755 --- a/package/gluon-mesh-batman-adv-core/luasrc/lib/gluon/upgrade/320-gluon-mesh-batman-adv-core-client-bridge +++ b/package/gluon-mesh-batman-adv-core/luasrc/lib/gluon/upgrade/320-gluon-mesh-batman-adv-core-client-bridge @@ -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) diff --git a/package/gluon-mesh-batman-adv-core/luasrc/lib/gluon/upgrade/330-gluon-mesh-batman-adv-core-local-node b/package/gluon-mesh-batman-adv-core/luasrc/lib/gluon/upgrade/330-gluon-mesh-batman-adv-core-local-node index ea3a29d0..ff1f12f4 100755 --- a/package/gluon-mesh-batman-adv-core/luasrc/lib/gluon/upgrade/330-gluon-mesh-batman-adv-core-local-node +++ b/package/gluon-mesh-batman-adv-core/luasrc/lib/gluon/upgrade/330-gluon-mesh-batman-adv-core-local-node @@ -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, } ) diff --git a/package/gluon-mesh-batman-adv-core/luasrc/lib/gluon/upgrade/340-gluon-mesh-batman-adv-core-mac-addresses b/package/gluon-mesh-batman-adv-core/luasrc/lib/gluon/upgrade/340-gluon-mesh-batman-adv-core-mac-addresses index 38011107..a8e69d78 100755 --- a/package/gluon-mesh-batman-adv-core/luasrc/lib/gluon/upgrade/340-gluon-mesh-batman-adv-core-mac-addresses +++ b/package/gluon-mesh-batman-adv-core/luasrc/lib/gluon/upgrade/340-gluon-mesh-batman-adv-core-mac-addresses @@ -1,7 +1,7 @@ #!/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) diff --git a/package/gluon-mesh-vpn-fastd/luasrc/lib/gluon/upgrade/400-mesh-vpn-fastd b/package/gluon-mesh-vpn-fastd/luasrc/lib/gluon/upgrade/400-mesh-vpn-fastd index 102ae0b4..27e2b3cd 100755 --- a/package/gluon-mesh-vpn-fastd/luasrc/lib/gluon/upgrade/400-mesh-vpn-fastd +++ b/package/gluon-mesh-vpn-fastd/luasrc/lib/gluon/upgrade/400-mesh-vpn-fastd @@ -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), } ) diff --git a/package/gluon-mesh-vpn-fastd/luasrc/lib/gluon/upgrade/410-mesh-vpn-fastd-generate-secret b/package/gluon-mesh-vpn-fastd/luasrc/lib/gluon/upgrade/410-mesh-vpn-fastd-generate-secret index e581dea8..f43e8b1f 100755 --- a/package/gluon-mesh-vpn-fastd/luasrc/lib/gluon/upgrade/410-mesh-vpn-fastd-generate-secret +++ b/package/gluon-mesh-vpn-fastd/luasrc/lib/gluon/upgrade/410-mesh-vpn-fastd-generate-secret @@ -1,6 +1,6 @@ #!/usr/bin/lua -local uci = require 'luci.model.uci' +local uci = require 'simple-uci' local c = uci.cursor() diff --git a/package/gluon-mesh-vpn-fastd/luasrc/lib/gluon/upgrade/420-mesh-vpn-fastd-simple-tc b/package/gluon-mesh-vpn-fastd/luasrc/lib/gluon/upgrade/420-mesh-vpn-fastd-simple-tc index 3c3e10a4..59de6185 100755 --- a/package/gluon-mesh-vpn-fastd/luasrc/lib/gluon/upgrade/420-mesh-vpn-fastd-simple-tc +++ b/package/gluon-mesh-vpn-fastd/luasrc/lib/gluon/upgrade/420-mesh-vpn-fastd-simple-tc @@ -1,7 +1,7 @@ #!/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 diff --git a/package/gluon-neighbour-info/luasrc/lib/gluon/upgrade/400-neighbour-info-firewall b/package/gluon-neighbour-info/luasrc/lib/gluon/upgrade/400-neighbour-info-firewall index 373f166a..aa54de5f 100755 --- a/package/gluon-neighbour-info/luasrc/lib/gluon/upgrade/400-neighbour-info-firewall +++ b/package/gluon-neighbour-info/luasrc/lib/gluon/upgrade/400-neighbour-info-firewall @@ -1,6 +1,6 @@ #!/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 diff --git a/package/gluon-node-info/files/lib/gluon/upgrade/500-node-info-system b/package/gluon-node-info/files/lib/gluon/upgrade/500-node-info-system index a70eb282..6ee047ec 100755 --- a/package/gluon-node-info/files/lib/gluon/upgrade/500-node-info-system +++ b/package/gluon-node-info/files/lib/gluon/upgrade/500-node-info-system @@ -1,6 +1,6 @@ #!/usr/bin/lua -local uci = require('luci.model.uci').cursor() +local uci = require('simple-uci').cursor() local config = 'gluon-node-info' diff --git a/package/gluon-node-info/files/lib/gluon/upgrade/510-node-info-role b/package/gluon-node-info/files/lib/gluon/upgrade/510-node-info-role index 06d42f8e..d7a440fb 100755 --- a/package/gluon-node-info/files/lib/gluon/upgrade/510-node-info-role +++ b/package/gluon-node-info/files/lib/gluon/upgrade/510-node-info-role @@ -1,7 +1,7 @@ #!/usr/bin/lua 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 role = uci:get(config, uci:get_first(config, 'system'), 'role') diff --git a/package/gluon-node-info/files/lib/gluon/upgrade/520-node-info-whitespace-fix b/package/gluon-node-info/files/lib/gluon/upgrade/520-node-info-whitespace-fix index 49e7053d..d062ab91 100755 --- a/package/gluon-node-info/files/lib/gluon/upgrade/520-node-info-whitespace-fix +++ b/package/gluon-node-info/files/lib/gluon/upgrade/520-node-info-whitespace-fix @@ -1,5 +1,6 @@ #!/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') if sname then diff --git a/package/gluon-respondd/luasrc/lib/gluon/upgrade/400-respondd-firewall b/package/gluon-respondd/luasrc/lib/gluon/upgrade/400-respondd-firewall index a78cfb3d..5e303feb 100755 --- a/package/gluon-respondd/luasrc/lib/gluon/upgrade/400-respondd-firewall +++ b/package/gluon-respondd/luasrc/lib/gluon/upgrade/400-respondd-firewall @@ -1,6 +1,6 @@ #!/usr/bin/lua -local uci = require('luci.model.uci').cursor() +local uci = require('simple-uci').cursor() uci:delete('firewall', 'wan_announced') diff --git a/package/gluon-setup-mode/luasrc/lib/gluon/upgrade/300-setup-mode b/package/gluon-setup-mode/luasrc/lib/gluon/upgrade/300-setup-mode index 481a4fa0..248861ee 100755 --- a/package/gluon-setup-mode/luasrc/lib/gluon/upgrade/300-setup-mode +++ b/package/gluon-setup-mode/luasrc/lib/gluon/upgrade/300-setup-mode @@ -1,15 +1,14 @@ #!/usr/bin/lua 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 and site.setup_mode.skip - and not c:get_first('gluon-setup-mode', 'setup_mode', 'configured', false) then - local name = c:get_first("gluon-setup-mode", "setup_mode") - c:set("gluon-setup-mode", name, "configured", 1) - c:save('gluon-setup-mode') + and not uci:get_first('gluon-setup-mode', 'setup_mode', 'configured', false) then + local name = uci:get_first("gluon-setup-mode", "setup_mode") + uci:set("gluon-setup-mode", name, "configured", true) + uci:save('gluon-setup-mode') end diff --git a/package/gluon-setup-mode/luasrc/lib/gluon/upgrade/310-setup-mode-migrate b/package/gluon-setup-mode/luasrc/lib/gluon/upgrade/310-setup-mode-migrate index 8526dd29..ecaa07f9 100755 --- a/package/gluon-setup-mode/luasrc/lib/gluon/upgrade/310-setup-mode-migrate +++ b/package/gluon-setup-mode/luasrc/lib/gluon/upgrade/310-setup-mode-migrate @@ -1,16 +1,14 @@ #!/usr/bin/lua -local uci = require 'luci.model.uci' - -local c = uci.cursor() +local uci = require('simple-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 - local setup_mode = c:get_first('gluon-setup-mode', 'setup_mode') - c:set('gluon-setup-mode', setup_mode, 'configured', '1') + local setup_mode = uci:get_first('gluon-setup-mode', 'setup_mode') + uci:set('gluon-setup-mode', setup_mode, 'configured', true) - c:save('gluon-setup-mode') + uci:save('gluon-setup-mode') end os.remove('/etc/config/gluon-config-mode') diff --git a/package/gluon-wan-dnsmasq/luasrc/lib/gluon/wan-dnsmasq/update.lua b/package/gluon-wan-dnsmasq/luasrc/lib/gluon/wan-dnsmasq/update.lua index 2997f1c4..d1a3d99e 100755 --- a/package/gluon-wan-dnsmasq/luasrc/lib/gluon/wan-dnsmasq/update.lua +++ b/package/gluon-wan-dnsmasq/luasrc/lib/gluon/wan-dnsmasq/update.lua @@ -5,7 +5,7 @@ local RESOLV_CONF = RESOLV_CONF_DIR .. '/resolv.conf' local ubus = require('ubus').connect() -local uci = require('luci.model.uci').cursor() +local uci = require('simple-uci').cursor() local fs = require 'nixio.fs'