diff --git a/package/gluon-authorized-keys/luasrc/lib/gluon/upgrade/100-authorized-keys b/package/gluon-authorized-keys/luasrc/lib/gluon/upgrade/100-authorized-keys index 643fa076..34efd0b8 100755 --- a/package/gluon-authorized-keys/luasrc/lib/gluon/upgrade/100-authorized-keys +++ b/package/gluon-authorized-keys/luasrc/lib/gluon/upgrade/100-authorized-keys @@ -1,6 +1,6 @@ #!/usr/bin/lua -local site = require 'gluon.site_config' +local site = require 'gluon.site' local file = '/etc/dropbear/authorized_keys' local keys = {} @@ -14,7 +14,7 @@ end pcall(load_keys) local f = io.open(file, 'a') -for _, key in ipairs(site.authorized_keys) do +for _, key in ipairs(site.authorized_keys()) do if not keys[key] then f:write(key .. '\n') end diff --git a/package/gluon-autoupdater/luasrc/lib/gluon/upgrade/500-autoupdater b/package/gluon-autoupdater/luasrc/lib/gluon/upgrade/500-autoupdater index 6f3070bf..a4e042a9 100755 --- a/package/gluon-autoupdater/luasrc/lib/gluon/upgrade/500-autoupdater +++ b/package/gluon-autoupdater/luasrc/lib/gluon/upgrade/500-autoupdater @@ -1,10 +1,10 @@ #!/usr/bin/lua -local site = require 'gluon.site_config' +local site = require 'gluon.site' local uci = require('simple-uci').cursor() -for name, config in pairs(site.autoupdater.branches) do +for name, config in pairs(site.autoupdater.branches()) do uci:delete('autoupdater', name) uci:section('autoupdater', 'branch', name, { name = config.name, @@ -16,7 +16,7 @@ end if not uci:get('autoupdater', 'settings') then local enabled = false - local branch = site.autoupdater.branch + local branch = site.autoupdater.branch() local f = io.open('/lib/gluon/autoupdater/default_branch') if f then 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 f374828b..a0c47760 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 @@ -1,6 +1,5 @@ #!/usr/bin/lua -local site = require 'gluon.site_config' local util = require 'gluon.util' local uci = require('simple-uci').cursor() 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 36f8ff3b..8cbba849 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 @@ -1,4 +1,4 @@ -local site = require 'gluon.site_config' +local site = require 'gluon.site' local sysconfig = require 'gluon.sysconfig' local pretty_hostname = require 'pretty_hostname' 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 14e834e7..fc3f8123 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 @@ -2,14 +2,13 @@ local uci = require("simple-uci").cursor() local lutil = require "gluon.web.util" local fs = require "nixio.fs" -local site = require 'gluon.site_config' +local site = require 'gluon.site' local sysconfig = require 'gluon.sysconfig' local util = require "gluon.util" local pretty_hostname = require 'pretty_hostname' - local has_fastd = fs.access('/lib/gluon/mesh-vpn/fastd') local has_tunneldigger = fs.access('/lib/gluon/mesh-vpn/tunneldigger') diff --git a/package/gluon-core/luasrc/lib/gluon/upgrade/020-interfaces b/package/gluon-core/luasrc/lib/gluon/upgrade/020-interfaces index d1b6cee2..47757699 100755 --- a/package/gluon-core/luasrc/lib/gluon/upgrade/020-interfaces +++ b/package/gluon-core/luasrc/lib/gluon/upgrade/020-interfaces @@ -10,7 +10,7 @@ end local util = require 'gluon.util' local platform = require 'gluon.platform' -local site = require 'gluon.site_config' +local site = require 'gluon.site' local fs = require 'nixio.fs' local uci = require('simple-uci').cursor() @@ -50,7 +50,7 @@ if wan_ifname and lan_ifname then sysconfig.lan_ifname = lan_ifname else local single_ifname = lan_ifname or wan_ifname - if site.single_as_lan then + if site.single_as_lan(false) then sysconfig.lan_ifname = single_ifname else sysconfig.wan_ifname = single_ifname diff --git a/package/gluon-core/luasrc/lib/gluon/upgrade/030-system b/package/gluon-core/luasrc/lib/gluon/upgrade/030-system index 3258e4f8..7d8eeda1 100755 --- a/package/gluon-core/luasrc/lib/gluon/upgrade/030-system +++ b/package/gluon-core/luasrc/lib/gluon/upgrade/030-system @@ -1,18 +1,21 @@ #!/usr/bin/lua -local pretty_hostname = require 'pretty_hostname' local sysconfig = require 'gluon.sysconfig' -- Initial -if not sysconfig.gluon_version then - local site = require 'gluon.site_config' - local util = require 'gluon.util' - local uci = require('simple-uci').cursor() - - local system = uci:get_first('system', 'system') - - pretty_hostname.set(uci, (site.hostname_prefix or '') .. util.node_id()) - uci:set('system', system, 'timezone', site.timezone) - - uci:save('system') +if sysconfig.gluon_version then + os.exit(0) end + + +local site = require 'gluon.site' +local util = require 'gluon.util' +local uci = require('simple-uci').cursor() +local pretty_hostname = require 'pretty_hostname' + +local system = uci:get_first('system', 'system') + +pretty_hostname.set(uci, site.hostname_prefix('') .. util.node_id()) +uci:set('system', system, 'timezone', site.timezone()) + +uci:save('system') 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 2afe3a2a..e3718b68 100755 --- a/package/gluon-core/luasrc/lib/gluon/upgrade/120-ntp-servers +++ b/package/gluon-core/luasrc/lib/gluon/upgrade/120-ntp-servers @@ -1,13 +1,13 @@ #!/usr/bin/lua -local site = require 'gluon.site_config' -local uci = require 'simple-uci' +local site = require 'gluon.site' -if not site.ntp_servers or #site.ntp_servers == 0 then +if #site.ntp_servers({}) == 0 then os.exit(0) end -local c = uci.cursor() -c:delete('system', 'ntp', 'server') -c:set_list('system', 'ntp', 'server', site.ntp_servers) -c:save('system') + +local uci = require('simple-uci').cursor() +uci:delete('system', 'ntp', 'server') +uci:set_list('system', 'ntp', 'server', site.ntp_servers({})) +uci:save('system') 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 9af4e515..e871f9ed 100755 --- a/package/gluon-core/luasrc/lib/gluon/upgrade/140-firewall-rules +++ b/package/gluon-core/luasrc/lib/gluon/upgrade/140-firewall-rules @@ -1,6 +1,5 @@ #!/usr/bin/lua -local site = require 'gluon.site_config' local uci = require('simple-uci').cursor() 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 ded75509..e8737259 100755 --- a/package/gluon-core/luasrc/lib/gluon/upgrade/150-poe-passthrough +++ b/package/gluon-core/luasrc/lib/gluon/upgrade/150-poe-passthrough @@ -1,13 +1,16 @@ #!/usr/bin/lua local sysconfig = require 'gluon.sysconfig' -local site = require 'gluon.site_config' +local site = require 'gluon.site' -if (not sysconfig.gluon_version) and site.poe_passthrough then - local uci = require('simple-uci').cursor() - - if uci:get('system', 'poe_passthrough') then - uci:set('system', 'poe_passthrough', 'value', true) - uci:save('system') - end +if sysconfig.gluon_version or not site.poe_passthrough(false) then + os.exit(0) +end + + +local uci = require('simple-uci').cursor() + +if uci:get('system', 'poe_passthrough') then + uci:set('system', 'poe_passthrough', 'value', true) + uci:save('system') end 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 8ba6d301..ac708f99 100755 --- a/package/gluon-core/luasrc/lib/gluon/upgrade/210-interface-wan +++ b/package/gluon-core/luasrc/lib/gluon/upgrade/210-interface-wan @@ -1,6 +1,6 @@ #!/usr/bin/lua -local site = require 'gluon.site_config' +local site = require 'gluon.site' local uci = require('simple-uci').cursor() local old_proto = uci:get('network', 'mesh_wan', 'proto') @@ -12,7 +12,7 @@ uci:section('network', 'interface', 'mesh_wan', { }) if uci:get('network', 'mesh_wan', 'auto') == nil then - uci:set('network', 'mesh_wan', 'auto', site.mesh_on_wan or false) + uci:set('network', 'mesh_wan', 'auto', site.mesh_on_wan(false)) end if uci:get('network', 'mesh_wan', 'transitive') == nil then uci:set('network', 'mesh_wan', 'transitive', true) 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 04502560..2e72ff10 100755 --- a/package/gluon-core/luasrc/lib/gluon/upgrade/220-interface-lan +++ b/package/gluon-core/luasrc/lib/gluon/upgrade/220-interface-lan @@ -1,6 +1,6 @@ #!/usr/bin/lua -local site = require 'gluon.site_config' +local site = require 'gluon.site' local util = require 'gluon.util' local sysconfig = require 'gluon.sysconfig' @@ -22,7 +22,7 @@ uci:section('network', 'interface', 'mesh_lan', { }) if uci:get('network', 'mesh_lan', 'auto') == nil then - local enable = site.mesh_on_lan + local enable = site.mesh_on_lan(false) if enable then local interfaces = uci:get_list('network', 'client', 'ifname') @@ -37,7 +37,7 @@ if uci:get('network', 'mesh_lan', 'auto') == nil then end end - uci:set('network', 'mesh_lan', 'auto', enable or false) + uci:set('network', 'mesh_lan', 'auto', enable) end if uci:get('network', 'mesh_lan', 'transitive') == nil then diff --git a/package/gluon-core/luasrc/lib/gluon/upgrade/500-opkg b/package/gluon-core/luasrc/lib/gluon/upgrade/500-opkg index 52742798..81e437b5 100755 --- a/package/gluon-core/luasrc/lib/gluon/upgrade/500-opkg +++ b/package/gluon-core/luasrc/lib/gluon/upgrade/500-opkg @@ -1,7 +1,13 @@ #!/usr/bin/lua local fs = require 'nixio.fs' -local site = require 'gluon.site_config' + +if not fs.access('/etc/opkg/distfeeds.conf') then + os.exit(0) +end + + +local site = require 'gluon.site' local util = require 'gluon.util' @@ -15,11 +21,14 @@ subst['%%S'] = f:read() subst['%%A'] = f:read() f:close() -subst['%%GS'] = site.site_code +subst['%%GS'] = site.site_code() subst['%%GV'] = util.trim(fs.readfile('/lib/gluon/gluon-version')) subst['%%GR'] = util.trim(fs.readfile('/lib/gluon/release')) -function replace_patterns(url) +local prefix = subst['%%n'] .. '_' + + +local function replace_patterns(url) for k, v in pairs(subst) do url = url:gsub(k, v) end @@ -28,39 +37,39 @@ function replace_patterns(url) end -local prefix = subst['%%n'] .. '_' +local lede = site.opkg.lede() +local extra = site.opkg.extra({}) -if fs.access('/etc/opkg/distfeeds.conf') then - local distfeeds = {} - for line in io.lines('/etc/opkg/distfeeds.conf') do - table.insert(distfeeds, line) + +local distfeeds = {} +for line in io.lines('/etc/opkg/distfeeds.conf') do + table.insert(distfeeds, line) +end + +local f = io.open('/etc/opkg/distfeeds.conf', 'w') + +for _, line in ipairs(distfeeds) do + local name = line:match('^src/gz%s' .. prefix .. '(%S+)%s') + if name == 'core' then + f:write('# ' .. line .. '\n') + elseif name and lede then + f:write(string.format('src/gz %s %s/%s\n', prefix .. name, replace_patterns(lede), name)) + else + f:write(line .. '\n') end +end - local f = io.open('/etc/opkg/distfeeds.conf', 'w') +f:close() - for _, line in ipairs(distfeeds) do - local name = line:match('^src/gz%s' .. prefix .. '(%S+)%s') - if name == 'core' then - f:write('# ' .. line .. '\n') - elseif name and site.opkg and site.opkg.lede then - f:write(string.format('src/gz %s %s/%s\n', prefix .. name, replace_patterns(site.opkg.lede), name)) - else - f:write(line .. '\n') - end +if next(extra) then + local f = io.open('/etc/opkg/gluon.conf', 'w') + + for k, v in pairs(extra) do + f:write(string.format('src/gz %s %s\n', k, replace_patterns(v))) end f:close() - if site.opkg and site.opkg.extra and next(site.opkg.extra) then - local f = io.open('/etc/opkg/gluon.conf', 'w') - - for k, v in pairs(site.opkg.extra) do - f:write(string.format('src/gz %s %s\n', k, replace_patterns(v))) - end - - f:close() - - else - os.remove('/etc/opkg/gluon.conf') - end +else + os.remove('/etc/opkg/gluon.conf') end diff --git a/package/gluon-ebtables-source-filter/files/lib/gluon/ebtables/110-local-forward-allow-arp b/package/gluon-ebtables-source-filter/files/lib/gluon/ebtables/110-local-forward-allow-arp index e8de3120..06436cf2 100644 --- a/package/gluon-ebtables-source-filter/files/lib/gluon/ebtables/110-local-forward-allow-arp +++ b/package/gluon-ebtables-source-filter/files/lib/gluon/ebtables/110-local-forward-allow-arp @@ -1,4 +1,4 @@ -prefix4 = require('gluon.site_config').prefix4 +local prefix4 = require('gluon.site').prefix4() if prefix4 then rule('LOCAL_FORWARD -p ARP --arp-ip-src ' .. prefix4 .. ' --arp-ip-dst ' .. prefix4 .. ' -j RETURN') diff --git a/package/gluon-ebtables-source-filter/files/lib/gluon/ebtables/110-local-forward-allow-ipv4 b/package/gluon-ebtables-source-filter/files/lib/gluon/ebtables/110-local-forward-allow-ipv4 index 048e700f..e712c5fb 100644 --- a/package/gluon-ebtables-source-filter/files/lib/gluon/ebtables/110-local-forward-allow-ipv4 +++ b/package/gluon-ebtables-source-filter/files/lib/gluon/ebtables/110-local-forward-allow-ipv4 @@ -1,4 +1,4 @@ -prefix4 = require('gluon.site_config').prefix4 +local prefix4 = require('gluon.site').prefix4() if prefix4 then rule('LOCAL_FORWARD -p IPv4 --ip-protocol udp --ip-destination-port 67 -j RETURN') diff --git a/package/gluon-l3roamd/files/etc/init.d/gluon-l3roamd b/package/gluon-l3roamd/files/etc/init.d/gluon-l3roamd index a14e96ee..460e6c9b 100755 --- a/package/gluon-l3roamd/files/etc/init.d/gluon-l3roamd +++ b/package/gluon-l3roamd/files/etc/init.d/gluon-l3roamd @@ -12,7 +12,7 @@ start_service () { procd_set_param respawn ${respawn_threshold:-3660} ${respawn_timeout:-5} ${respawn_retry:-0} interfaces=$(for dev in $( ubus call network.interface dump | jsonfilter -e "@.interface[@.proto='gluon_mesh' && @.up=true].device");do echo " -m $dev"; done; [ "$(ifstatus client | jsonfilter -e "@.up")" = "true" ] && echo " -i local-node") - procd_set_param command "$PROG" -p $(lua -e 'print(require("gluon.site_config").prefix6)') $interfaces -t 11 -a $(uci get network.loopback.ip6addr | cut -d/ -f1) -4 0:0:0:0:0:ffff::/96 + procd_set_param command "$PROG" -p $(lua -e 'print(require("gluon.site").prefix6())') $interfaces -t 11 -a $(uci get network.loopback.ip6addr | cut -d/ -f1) -4 0:0:0:0:0:ffff::/96 procd_close_instance } @@ -24,4 +24,3 @@ service_triggers() { procd_add_raw_trigger "interface.*" 0 "/etc/init.d/$name" reload procd_close_trigger } - diff --git a/package/gluon-l3roamd/luasrc/lib/gluon/upgrade/380-gluon-l3roamd-route b/package/gluon-l3roamd/luasrc/lib/gluon/upgrade/380-gluon-l3roamd-route index 237280f1..4bd579c7 100755 --- a/package/gluon-l3roamd/luasrc/lib/gluon/upgrade/380-gluon-l3roamd-route +++ b/package/gluon-l3roamd/luasrc/lib/gluon/upgrade/380-gluon-l3roamd-route @@ -1,7 +1,7 @@ #!/usr/bin/lua local uci = require('simple-uci').cursor() -local site = require 'gluon.site_config' +local site = require 'gluon.site' uci:delete('network', 'l3roam') uci:section('network', 'interface', 'l3roam', { @@ -12,7 +12,7 @@ uci:section('network', 'interface', 'l3roam', { uci:delete('network', 'l3roamd_client') uci:section('network', 'route6', 'l3roamd_client', { interface = 'l3roam', - target = site.prefix6, + target = site.prefix6(), gateway = '::', table = '10', }) diff --git a/package/gluon-mesh-batman-adv/luasrc/lib/gluon/radvd/arguments b/package/gluon-mesh-batman-adv/luasrc/lib/gluon/radvd/arguments index 36ac3c2d..c7f43e11 100755 --- a/package/gluon-mesh-batman-adv/luasrc/lib/gluon/radvd/arguments +++ b/package/gluon-mesh-batman-adv/luasrc/lib/gluon/radvd/arguments @@ -1,9 +1,9 @@ #!/usr/bin/lua -local site = require "gluon.site_config" +local site = require "gluon.site" -io.write("-i local-node -p " .. site.prefix6) +io.write("-i local-node -p " .. site.prefix6()) -if site.dns and site.dns.servers and site.next_node and site.next_node.ip6 then - io.write(" --rdnss " .. site.next_node.ip6) +if site.dns.servers() and site.next_node.ip6() then + io.write(" --rdnss " .. site.next_node.ip6()) end diff --git a/package/gluon-mesh-batman-adv/luasrc/lib/gluon/upgrade/310-gluon-mesh-batman-adv-mesh b/package/gluon-mesh-batman-adv/luasrc/lib/gluon/upgrade/310-gluon-mesh-batman-adv-mesh index c70fa218..be5f18b5 100755 --- a/package/gluon-mesh-batman-adv/luasrc/lib/gluon/upgrade/310-gluon-mesh-batman-adv-mesh +++ b/package/gluon-mesh-batman-adv/luasrc/lib/gluon/upgrade/310-gluon-mesh-batman-adv-mesh @@ -1,20 +1,15 @@ #!/usr/bin/lua local sysconfig = require 'gluon.sysconfig' -local site = require 'gluon.site_config' +local site = require 'gluon.site' local util = require 'gluon.util' local uci = require('simple-uci').cursor() -local gw_mode, gw_sel_class, routing_algo - -gw_mode = uci:get('batman-adv', 'bat0', 'gw_mode') or 'client' - -if site.mesh and site.mesh.batman_adv then - gw_sel_class = site.mesh.batman_adv.gw_sel_class - routing_algo = site.mesh.batman_adv.routing_algo -end +local gw_mode = uci:get('batman-adv', 'bat0', 'gw_mode') or 'client' +local gw_sel_class = site.mesh.batman_adv.gw_sel_class() +local routing_algo = site.mesh.batman_adv.routing_algo() uci:delete('batman-adv', 'bat0') diff --git a/package/gluon-mesh-batman-adv/luasrc/lib/gluon/upgrade/320-gluon-mesh-batman-adv-client-bridge b/package/gluon-mesh-batman-adv/luasrc/lib/gluon/upgrade/320-gluon-mesh-batman-adv-client-bridge index 2bfcdd57..50e68d2f 100755 --- a/package/gluon-mesh-batman-adv/luasrc/lib/gluon/upgrade/320-gluon-mesh-batman-adv-client-bridge +++ b/package/gluon-mesh-batman-adv/luasrc/lib/gluon/upgrade/320-gluon-mesh-batman-adv-client-bridge @@ -4,7 +4,7 @@ -- it overrides parts of network.client -local site = require 'gluon.site_config' +local site = require 'gluon.site' local sysconfig = require 'gluon.sysconfig' local sysctl = require 'gluon.sysctl' @@ -15,7 +15,7 @@ uci:section('network', 'interface', 'client', { ipv6 = true, proto = 'dhcpv6', reqprefix = 'no', - peerdns = not (site.dns and site.dns.servers), + peerdns = not site.dns.servers(), sourcefilter = false, keep_ra_dnslifetime = true, robustness = 3, @@ -28,7 +28,7 @@ uci:delete('network', 'client_lan') uci:delete('network', 'local_node_route6') uci:section('network', 'route6', 'local_node_route6', { interface = 'client', - target = site.prefix6, + target = site.prefix6(), gateway = '::', }) diff --git a/package/gluon-mesh-vpn-core/luasrc/lib/gluon/upgrade/500-mesh-vpn b/package/gluon-mesh-vpn-core/luasrc/lib/gluon/upgrade/500-mesh-vpn index 6475d70a..ad89db8d 100755 --- a/package/gluon-mesh-vpn-core/luasrc/lib/gluon/upgrade/500-mesh-vpn +++ b/package/gluon-mesh-vpn-core/luasrc/lib/gluon/upgrade/500-mesh-vpn @@ -1,6 +1,6 @@ #!/usr/bin/lua -local site = require 'gluon.site_config' +local site = require 'gluon.site' local users = require 'gluon.users' local util = require 'gluon.util' local fs = require 'nixio.fs' @@ -14,7 +14,7 @@ uci:section('network', 'interface', 'mesh_vpn', { transitive = true, fixed_mtu = true, macaddr = util.generate_mac(7), - mtu = site.mesh_vpn.mtu, + mtu = site.mesh_vpn.mtu(), }) uci:save('network') @@ -25,22 +25,12 @@ if fs.access('/etc/config/gluon-simple-tc') then end if not uci:get('simple-tc', 'mesh_vpn') then - local config = { + uci:section('simple-tc', 'interface', 'mesh_vpn', { ifname = 'mesh-vpn', - enabled = false, - } - - - if site.mesh_vpn.bandwidth_limit then - if site.mesh_vpn.bandwidth_limit.enabled then - config.enabled = true - end - - config.limit_ingress = site.mesh_vpn.bandwidth_limit.ingress - config.limit_egress = site.mesh_vpn.bandwidth_limit.egress - end - - uci:section('simple-tc', 'interface', 'mesh_vpn', config) + enabled = site.mesh_vpn.bandwidth_limit.enabled(false), + limit_ingress = site.mesh_vpn.bandwidth_limit.ingress(), + limit_egress = site.mesh_vpn.bandwidth_limit.egress(), + }) uci:save('simple-tc') end @@ -79,7 +69,7 @@ elseif fastd_enabled or tunneldigger_enabled then enabled = fastd_enabled == '1' or tunneldigger_enabled == '1' -- If nothing is set, use the default else - enabled = site.mesh_vpn.enabled or false + enabled = site.mesh_vpn.enabled(false) end if has_fastd then 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 126dfefb..83eff0c7 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 @@ -1,6 +1,6 @@ #!/usr/bin/lua -local site = require 'gluon.site_config' +local site = require 'gluon.site' local util = require 'gluon.util' local uci = require('simple-uci').cursor() @@ -10,8 +10,8 @@ local syslog_level = uci:get('fastd', 'mesh_vpn', 'syslog_level') or 'verbose' local methods -if site.mesh_vpn.fastd.configurable then - local has_null = util.contains(site.mesh_vpn.fastd.methods, 'null') +if site.mesh_vpn.fastd.configurable(false) then + local has_null = util.contains(site.mesh_vpn.fastd.methods(), 'null') local old_methods = uci:get('fastd', 'mesh_vpn', 'method') if old_methods then @@ -23,14 +23,14 @@ if site.mesh_vpn.fastd.configurable then table.insert(methods, 'null') end - for _, method in ipairs(site.mesh_vpn.fastd.methods) do + for _, method in ipairs(site.mesh_vpn.fastd.methods()) do if method ~= 'null' then table.insert(methods, method) end end else - methods = site.mesh_vpn.fastd.methods + methods = site.mesh_vpn.fastd.methods() end @@ -39,7 +39,7 @@ uci:section('fastd', 'fastd', 'mesh_vpn', { syslog_level = syslog_level, interface = 'mesh-vpn', mode = 'tap', - mtu = site.mesh_vpn.mtu, + mtu = site.mesh_vpn.mtu(), secure_handshakes = true, method = methods, packet_mark = 1, @@ -92,7 +92,7 @@ function add_groups(prefix, groups, parent) end end -add_groups('mesh_vpn', site.mesh_vpn.fastd.groups) +add_groups('mesh_vpn', site.mesh_vpn.fastd.groups()) uci:save('fastd') diff --git a/package/gluon-mesh-vpn-tunneldigger/luasrc/lib/gluon/upgrade/400-mesh-vpn-tunneldigger b/package/gluon-mesh-vpn-tunneldigger/luasrc/lib/gluon/upgrade/400-mesh-vpn-tunneldigger index 85d899c0..b91288a2 100755 --- a/package/gluon-mesh-vpn-tunneldigger/luasrc/lib/gluon/upgrade/400-mesh-vpn-tunneldigger +++ b/package/gluon-mesh-vpn-tunneldigger/luasrc/lib/gluon/upgrade/400-mesh-vpn-tunneldigger @@ -1,6 +1,6 @@ #!/usr/bin/lua -local site = require 'gluon.site_config' +local site = require 'gluon.site' local util = require 'gluon.util' local uci = require('simple-uci').cursor() @@ -27,7 +27,7 @@ uci:section('tunneldigger', 'broker', 'mesh_vpn', { bind_interface = 'br-wan', group = 'gluon-mesh-vpn', broker_selection = 'usage', - address = site.mesh_vpn.tunneldigger.brokers, + address = site.mesh_vpn.tunneldigger.brokers(), }) uci:save('tunneldigger') diff --git a/package/gluon-node-info/luasrc/lib/gluon/upgrade/510-node-info-role b/package/gluon-node-info/luasrc/lib/gluon/upgrade/510-node-info-role index d7a440fb..014f3f6f 100755 --- a/package/gluon-node-info/luasrc/lib/gluon/upgrade/510-node-info-role +++ b/package/gluon-node-info/luasrc/lib/gluon/upgrade/510-node-info-role @@ -1,18 +1,12 @@ #!/usr/bin/lua -local site = require 'gluon.site_config' +local site = require 'gluon.site' local uci = require('simple-uci').cursor() local config = 'gluon-node-info' local role = uci:get(config, uci:get_first(config, 'system'), 'role') -if site.roles then - default_role = site.roles.default -else - default_role = '' -end - if not role then - uci:set(config, uci:get_first(config, 'system'), 'role', default_role) - uci:save(config) + uci:set(config, uci:get_first(config, 'system'), 'role', site.roles.default('')) + uci:save(config) end diff --git a/package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S20network b/package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S20network index ef4cc4ad..19ba6221 100755 --- a/package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S20network +++ b/package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S20network @@ -46,7 +46,7 @@ init_switch() { start_service() { prepare_config init_switch - iw reg set "$(lua -e 'print(require("gluon.site_config").regdom)')" + iw reg set "$(lua -e 'print(require("gluon.site").regdom())')" procd_open_instance procd_set_param command /sbin/netifd -c /var/gluon/setup-mode/config 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 248861ee..0456a087 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,14 +1,11 @@ #!/usr/bin/lua -local site = require 'gluon.site_config' +local site = require 'gluon.site' local uci = require('simple-uci').cursor() -if site.setup_mode - and site.setup_mode.skip - 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') +if site.setup_mode.skip(false) 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-web-admin/files/lib/gluon/web/view/admin/info.html b/package/gluon-web-admin/files/lib/gluon/web/view/admin/info.html index 8714c084..6ad2855e 100644 --- a/package/gluon-web-admin/files/lib/gluon/web/view/admin/info.html +++ b/package/gluon-web-admin/files/lib/gluon/web/view/admin/info.html @@ -4,7 +4,7 @@ local lutil = require 'gluon.web.util' local pretty_hostname = require 'pretty_hostname' - local site = require 'gluon.site_config' + local site = require 'gluon.site' local sysconfig = require 'gluon.sysconfig' local platform = require 'gluon.platform' local util = require "gluon.util" @@ -26,7 +26,7 @@ model = platform.get_model(), version = util.trim(fs.readfile('/lib/gluon/gluon-version')), release = util.trim(fs.readfile('/lib/gluon/release')), - site = site.site_name, + site = site.site_name(), pubkey = 'n/a', } diff --git a/package/gluon-web-mesh-vpn-fastd/luasrc/lib/gluon/web/model/admin/mesh_vpn_fastd.lua b/package/gluon-web-mesh-vpn-fastd/luasrc/lib/gluon/web/model/admin/mesh_vpn_fastd.lua index 8b772cd3..d10bf178 100644 --- a/package/gluon-web-mesh-vpn-fastd/luasrc/lib/gluon/web/model/admin/mesh_vpn_fastd.lua +++ b/package/gluon-web-mesh-vpn-fastd/luasrc/lib/gluon/web/model/admin/mesh_vpn_fastd.lua @@ -16,14 +16,14 @@ else end function mode:write(data) - local site = require 'gluon.site_config' + local site = require 'gluon.site' local methods = {} if data == 'performance' then table.insert(methods, 'null') end - for _, method in ipairs(site.mesh_vpn.fastd.methods) do + for _, method in ipairs(site.mesh_vpn.fastd.methods()) do if method ~= 'null' then table.insert(methods, method) end diff --git a/package/gluon-web-node-role/luasrc/lib/gluon/web/model/admin/noderole.lua b/package/gluon-web-node-role/luasrc/lib/gluon/web/model/admin/noderole.lua index a686d860..5fe33459 100644 --- a/package/gluon-web-node-role/luasrc/lib/gluon/web/model/admin/noderole.lua +++ b/package/gluon-web-node-role/luasrc/lib/gluon/web/model/admin/noderole.lua @@ -1,5 +1,5 @@ local f, s, o -local site = require 'gluon.site_config' +local site = require 'gluon.site' local uci = require("simple-uci").cursor() local config = 'gluon-node-info' @@ -16,7 +16,7 @@ s = f:section(Section, nil, translate( o = s:option(ListValue, "role", translate("Role")) o.default = role -for _, role in ipairs(site.roles.list) do +for _, role in ipairs(site.roles.list()) do o:value(role, translate('gluon-web-node-role:role:' .. role)) end