treewide: use new gluon.site Lua library

Some files have received some additional refactoring.
This commit is contained in:
Matthias Schiffer 2017-08-11 20:47:35 +02:00
parent fd36bcce07
commit ee6afaced9
No known key found for this signature in database
GPG Key ID: 16EF3F64CB201D9C
29 changed files with 134 additions and 147 deletions

View File

@ -1,6 +1,6 @@
#!/usr/bin/lua #!/usr/bin/lua
local site = require 'gluon.site_config' local site = require 'gluon.site'
local file = '/etc/dropbear/authorized_keys' local file = '/etc/dropbear/authorized_keys'
local keys = {} local keys = {}
@ -14,7 +14,7 @@ end
pcall(load_keys) pcall(load_keys)
local f = io.open(file, 'a') 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 if not keys[key] then
f:write(key .. '\n') f:write(key .. '\n')
end end

View File

@ -1,10 +1,10 @@
#!/usr/bin/lua #!/usr/bin/lua
local site = require 'gluon.site_config' local site = require 'gluon.site'
local uci = require('simple-uci').cursor() 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:delete('autoupdater', name)
uci:section('autoupdater', 'branch', name, { uci:section('autoupdater', 'branch', name, {
name = config.name, name = config.name,
@ -16,7 +16,7 @@ end
if not uci:get('autoupdater', 'settings') then if not uci:get('autoupdater', 'settings') then
local enabled = false 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

View File

@ -1,6 +1,5 @@
#!/usr/bin/lua #!/usr/bin/lua
local site = require 'gluon.site_config'
local util = require 'gluon.util' local util = require 'gluon.util'
local uci = require('simple-uci').cursor() local uci = require('simple-uci').cursor()

View File

@ -1,4 +1,4 @@
local site = require 'gluon.site_config' local site = require 'gluon.site'
local sysconfig = require 'gluon.sysconfig' local sysconfig = require 'gluon.sysconfig'
local pretty_hostname = require 'pretty_hostname' local pretty_hostname = require 'pretty_hostname'

View File

@ -2,14 +2,13 @@ local uci = require("simple-uci").cursor()
local lutil = require "gluon.web.util" local lutil = require "gluon.web.util"
local fs = require "nixio.fs" local fs = require "nixio.fs"
local site = require 'gluon.site_config' local site = require 'gluon.site'
local sysconfig = require 'gluon.sysconfig' local sysconfig = require 'gluon.sysconfig'
local util = require "gluon.util" local util = require "gluon.util"
local pretty_hostname = require 'pretty_hostname' local pretty_hostname = require 'pretty_hostname'
local has_fastd = fs.access('/lib/gluon/mesh-vpn/fastd') local has_fastd = fs.access('/lib/gluon/mesh-vpn/fastd')
local has_tunneldigger = fs.access('/lib/gluon/mesh-vpn/tunneldigger') local has_tunneldigger = fs.access('/lib/gluon/mesh-vpn/tunneldigger')

View File

@ -10,7 +10,7 @@ end
local util = require 'gluon.util' local util = require 'gluon.util'
local platform = require 'gluon.platform' local platform = require 'gluon.platform'
local site = require 'gluon.site_config' local site = require 'gluon.site'
local fs = require 'nixio.fs' local fs = require 'nixio.fs'
local uci = require('simple-uci').cursor() local uci = require('simple-uci').cursor()
@ -50,7 +50,7 @@ if wan_ifname and lan_ifname then
sysconfig.lan_ifname = lan_ifname sysconfig.lan_ifname = lan_ifname
else else
local single_ifname = lan_ifname or wan_ifname 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 sysconfig.lan_ifname = single_ifname
else else
sysconfig.wan_ifname = single_ifname sysconfig.wan_ifname = single_ifname

View File

@ -1,18 +1,21 @@
#!/usr/bin/lua #!/usr/bin/lua
local pretty_hostname = require 'pretty_hostname'
local sysconfig = require 'gluon.sysconfig' local sysconfig = require 'gluon.sysconfig'
-- Initial -- Initial
if not sysconfig.gluon_version then if sysconfig.gluon_version then
local site = require 'gluon.site_config' os.exit(0)
end
local site = require 'gluon.site'
local util = require 'gluon.util' local util = require 'gluon.util'
local uci = require('simple-uci').cursor() local uci = require('simple-uci').cursor()
local pretty_hostname = require 'pretty_hostname'
local system = uci:get_first('system', 'system') local system = uci:get_first('system', 'system')
pretty_hostname.set(uci, (site.hostname_prefix or '') .. util.node_id()) pretty_hostname.set(uci, site.hostname_prefix('') .. util.node_id())
uci:set('system', system, 'timezone', site.timezone) uci:set('system', system, 'timezone', site.timezone())
uci:save('system') uci:save('system')
end

View File

@ -1,13 +1,13 @@
#!/usr/bin/lua #!/usr/bin/lua
local site = require 'gluon.site_config' local site = require 'gluon.site'
local uci = require 'simple-uci'
if not site.ntp_servers or #site.ntp_servers == 0 then if #site.ntp_servers({}) == 0 then
os.exit(0) os.exit(0)
end end
local c = uci.cursor()
c:delete('system', 'ntp', 'server') local uci = require('simple-uci').cursor()
c:set_list('system', 'ntp', 'server', site.ntp_servers) uci:delete('system', 'ntp', 'server')
c:save('system') uci:set_list('system', 'ntp', 'server', site.ntp_servers({}))
uci:save('system')

View File

@ -1,6 +1,5 @@
#!/usr/bin/lua #!/usr/bin/lua
local site = require 'gluon.site_config'
local uci = require('simple-uci').cursor() local uci = require('simple-uci').cursor()

View File

@ -1,13 +1,16 @@
#!/usr/bin/lua #!/usr/bin/lua
local sysconfig = require 'gluon.sysconfig' local sysconfig = require 'gluon.sysconfig'
local site = require 'gluon.site_config' local site = require 'gluon.site'
if sysconfig.gluon_version or not site.poe_passthrough(false) then
os.exit(0)
end
if (not sysconfig.gluon_version) and site.poe_passthrough then
local uci = require('simple-uci').cursor() local uci = require('simple-uci').cursor()
if uci:get('system', 'poe_passthrough') then if uci:get('system', 'poe_passthrough') then
uci:set('system', 'poe_passthrough', 'value', true) uci:set('system', 'poe_passthrough', 'value', true)
uci:save('system') uci:save('system')
end end
end

View File

@ -1,6 +1,6 @@
#!/usr/bin/lua #!/usr/bin/lua
local site = require 'gluon.site_config' local site = require 'gluon.site'
local uci = require('simple-uci').cursor() local uci = require('simple-uci').cursor()
local old_proto = uci:get('network', 'mesh_wan', 'proto') 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 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 end
if uci:get('network', 'mesh_wan', 'transitive') == nil then if uci:get('network', 'mesh_wan', 'transitive') == nil then
uci:set('network', 'mesh_wan', 'transitive', true) uci:set('network', 'mesh_wan', 'transitive', true)

View File

@ -1,6 +1,6 @@
#!/usr/bin/lua #!/usr/bin/lua
local site = require 'gluon.site_config' local site = require 'gluon.site'
local util = require 'gluon.util' local util = require 'gluon.util'
local sysconfig = require 'gluon.sysconfig' local sysconfig = require 'gluon.sysconfig'
@ -22,7 +22,7 @@ uci:section('network', 'interface', 'mesh_lan', {
}) })
if uci:get('network', 'mesh_lan', 'auto') == nil then 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 if enable then
local interfaces = uci:get_list('network', 'client', 'ifname') local interfaces = uci:get_list('network', 'client', 'ifname')
@ -37,7 +37,7 @@ if uci:get('network', 'mesh_lan', 'auto') == nil then
end end
end end
uci:set('network', 'mesh_lan', 'auto', enable or false) uci:set('network', 'mesh_lan', 'auto', enable)
end end
if uci:get('network', 'mesh_lan', 'transitive') == nil then if uci:get('network', 'mesh_lan', 'transitive') == nil then

View File

@ -1,7 +1,13 @@
#!/usr/bin/lua #!/usr/bin/lua
local fs = require 'nixio.fs' 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' local util = require 'gluon.util'
@ -15,11 +21,14 @@ subst['%%S'] = f:read()
subst['%%A'] = f:read() subst['%%A'] = f:read()
f:close() f:close()
subst['%%GS'] = site.site_code subst['%%GS'] = site.site_code()
subst['%%GV'] = util.trim(fs.readfile('/lib/gluon/gluon-version')) subst['%%GV'] = util.trim(fs.readfile('/lib/gluon/gluon-version'))
subst['%%GR'] = util.trim(fs.readfile('/lib/gluon/release')) 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 for k, v in pairs(subst) do
url = url:gsub(k, v) url = url:gsub(k, v)
end end
@ -28,9 +37,10 @@ function replace_patterns(url)
end 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 = {} local distfeeds = {}
for line in io.lines('/etc/opkg/distfeeds.conf') do for line in io.lines('/etc/opkg/distfeeds.conf') do
table.insert(distfeeds, line) table.insert(distfeeds, line)
@ -42,8 +52,8 @@ if fs.access('/etc/opkg/distfeeds.conf') then
local name = line:match('^src/gz%s' .. prefix .. '(%S+)%s') local name = line:match('^src/gz%s' .. prefix .. '(%S+)%s')
if name == 'core' then if name == 'core' then
f:write('# ' .. line .. '\n') f:write('# ' .. line .. '\n')
elseif name and site.opkg and site.opkg.lede then elseif name and lede then
f:write(string.format('src/gz %s %s/%s\n', prefix .. name, replace_patterns(site.opkg.lede), name)) f:write(string.format('src/gz %s %s/%s\n', prefix .. name, replace_patterns(lede), name))
else else
f:write(line .. '\n') f:write(line .. '\n')
end end
@ -51,10 +61,10 @@ if fs.access('/etc/opkg/distfeeds.conf') then
f:close() f:close()
if site.opkg and site.opkg.extra and next(site.opkg.extra) then if next(extra) then
local f = io.open('/etc/opkg/gluon.conf', 'w') local f = io.open('/etc/opkg/gluon.conf', 'w')
for k, v in pairs(site.opkg.extra) do for k, v in pairs(extra) do
f:write(string.format('src/gz %s %s\n', k, replace_patterns(v))) f:write(string.format('src/gz %s %s\n', k, replace_patterns(v)))
end end
@ -63,4 +73,3 @@ if fs.access('/etc/opkg/distfeeds.conf') then
else else
os.remove('/etc/opkg/gluon.conf') os.remove('/etc/opkg/gluon.conf')
end end
end

View File

@ -1,4 +1,4 @@
prefix4 = require('gluon.site_config').prefix4 local prefix4 = require('gluon.site').prefix4()
if prefix4 then if prefix4 then
rule('LOCAL_FORWARD -p ARP --arp-ip-src ' .. prefix4 .. ' --arp-ip-dst ' .. prefix4 .. ' -j RETURN') rule('LOCAL_FORWARD -p ARP --arp-ip-src ' .. prefix4 .. ' --arp-ip-dst ' .. prefix4 .. ' -j RETURN')

View File

@ -1,4 +1,4 @@
prefix4 = require('gluon.site_config').prefix4 local prefix4 = require('gluon.site').prefix4()
if prefix4 then if prefix4 then
rule('LOCAL_FORWARD -p IPv4 --ip-protocol udp --ip-destination-port 67 -j RETURN') rule('LOCAL_FORWARD -p IPv4 --ip-protocol udp --ip-destination-port 67 -j RETURN')

View File

@ -12,7 +12,7 @@ start_service () {
procd_set_param respawn ${respawn_threshold:-3660} ${respawn_timeout:-5} ${respawn_retry:-0} 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; 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") [ "$(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 procd_close_instance
} }
@ -24,4 +24,3 @@ service_triggers() {
procd_add_raw_trigger "interface.*" 0 "/etc/init.d/$name" reload procd_add_raw_trigger "interface.*" 0 "/etc/init.d/$name" reload
procd_close_trigger procd_close_trigger
} }

View File

@ -1,7 +1,7 @@
#!/usr/bin/lua #!/usr/bin/lua
local uci = require('simple-uci').cursor() local uci = require('simple-uci').cursor()
local site = require 'gluon.site_config' local site = require 'gluon.site'
uci:delete('network', 'l3roam') uci:delete('network', 'l3roam')
uci:section('network', 'interface', 'l3roam', { uci:section('network', 'interface', 'l3roam', {
@ -12,7 +12,7 @@ uci:section('network', 'interface', 'l3roam', {
uci:delete('network', 'l3roamd_client') uci:delete('network', 'l3roamd_client')
uci:section('network', 'route6', 'l3roamd_client', { uci:section('network', 'route6', 'l3roamd_client', {
interface = 'l3roam', interface = 'l3roam',
target = site.prefix6, target = site.prefix6(),
gateway = '::', gateway = '::',
table = '10', table = '10',
}) })

View File

@ -1,9 +1,9 @@
#!/usr/bin/lua #!/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 if site.dns.servers() and site.next_node.ip6() then
io.write(" --rdnss " .. site.next_node.ip6) io.write(" --rdnss " .. site.next_node.ip6())
end end

View File

@ -1,20 +1,15 @@
#!/usr/bin/lua #!/usr/bin/lua
local sysconfig = require 'gluon.sysconfig' local sysconfig = require 'gluon.sysconfig'
local site = require 'gluon.site_config' local site = require 'gluon.site'
local util = require 'gluon.util' local util = require 'gluon.util'
local uci = require('simple-uci').cursor() local uci = require('simple-uci').cursor()
local gw_mode, gw_sel_class, routing_algo local gw_mode = uci:get('batman-adv', 'bat0', 'gw_mode') or 'client'
local gw_sel_class = site.mesh.batman_adv.gw_sel_class()
gw_mode = uci:get('batman-adv', 'bat0', 'gw_mode') or 'client' local routing_algo = site.mesh.batman_adv.routing_algo()
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
uci:delete('batman-adv', 'bat0') uci:delete('batman-adv', 'bat0')

View File

@ -4,7 +4,7 @@
-- it overrides parts of network.client -- it overrides parts of network.client
local site = require 'gluon.site_config' local site = require 'gluon.site'
local sysconfig = require 'gluon.sysconfig' local sysconfig = require 'gluon.sysconfig'
local sysctl = require 'gluon.sysctl' local sysctl = require 'gluon.sysctl'
@ -15,7 +15,7 @@ uci:section('network', 'interface', 'client', {
ipv6 = true, ipv6 = true,
proto = 'dhcpv6', proto = 'dhcpv6',
reqprefix = 'no', reqprefix = 'no',
peerdns = not (site.dns and site.dns.servers), peerdns = not site.dns.servers(),
sourcefilter = false, sourcefilter = false,
keep_ra_dnslifetime = true, keep_ra_dnslifetime = true,
robustness = 3, robustness = 3,
@ -28,7 +28,7 @@ uci:delete('network', 'client_lan')
uci:delete('network', 'local_node_route6') uci:delete('network', 'local_node_route6')
uci:section('network', 'route6', 'local_node_route6', { uci:section('network', 'route6', 'local_node_route6', {
interface = 'client', interface = 'client',
target = site.prefix6, target = site.prefix6(),
gateway = '::', gateway = '::',
}) })

View File

@ -1,6 +1,6 @@
#!/usr/bin/lua #!/usr/bin/lua
local site = require 'gluon.site_config' local site = require 'gluon.site'
local users = require 'gluon.users' local users = require 'gluon.users'
local util = require 'gluon.util' local util = require 'gluon.util'
local fs = require 'nixio.fs' local fs = require 'nixio.fs'
@ -14,7 +14,7 @@ uci:section('network', 'interface', 'mesh_vpn', {
transitive = true, transitive = true,
fixed_mtu = true, fixed_mtu = true,
macaddr = util.generate_mac(7), macaddr = util.generate_mac(7),
mtu = site.mesh_vpn.mtu, mtu = site.mesh_vpn.mtu(),
}) })
uci:save('network') uci:save('network')
@ -25,22 +25,12 @@ if fs.access('/etc/config/gluon-simple-tc') then
end end
if not uci:get('simple-tc', 'mesh_vpn') then if not uci:get('simple-tc', 'mesh_vpn') then
local config = { uci:section('simple-tc', 'interface', 'mesh_vpn', {
ifname = 'mesh-vpn', ifname = 'mesh-vpn',
enabled = false, enabled = site.mesh_vpn.bandwidth_limit.enabled(false),
} limit_ingress = site.mesh_vpn.bandwidth_limit.ingress(),
limit_egress = site.mesh_vpn.bandwidth_limit.egress(),
})
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)
uci:save('simple-tc') uci:save('simple-tc')
end end
@ -79,7 +69,7 @@ elseif fastd_enabled or tunneldigger_enabled then
enabled = fastd_enabled == '1' or tunneldigger_enabled == '1' enabled = fastd_enabled == '1' or tunneldigger_enabled == '1'
-- If nothing is set, use the default -- If nothing is set, use the default
else else
enabled = site.mesh_vpn.enabled or false enabled = site.mesh_vpn.enabled(false)
end end
if has_fastd then if has_fastd then

View File

@ -1,6 +1,6 @@
#!/usr/bin/lua #!/usr/bin/lua
local site = require 'gluon.site_config' local site = require 'gluon.site'
local util = require 'gluon.util' local util = require 'gluon.util'
local uci = require('simple-uci').cursor() local uci = require('simple-uci').cursor()
@ -10,8 +10,8 @@ local syslog_level = uci:get('fastd', 'mesh_vpn', 'syslog_level') or 'verbose'
local methods local methods
if site.mesh_vpn.fastd.configurable then if site.mesh_vpn.fastd.configurable(false) then
local has_null = util.contains(site.mesh_vpn.fastd.methods, 'null') local has_null = util.contains(site.mesh_vpn.fastd.methods(), 'null')
local old_methods = uci:get('fastd', 'mesh_vpn', 'method') local old_methods = uci:get('fastd', 'mesh_vpn', 'method')
if old_methods then if old_methods then
@ -23,14 +23,14 @@ if site.mesh_vpn.fastd.configurable then
table.insert(methods, 'null') table.insert(methods, 'null')
end 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 if method ~= 'null' then
table.insert(methods, method) table.insert(methods, method)
end end
end end
else else
methods = site.mesh_vpn.fastd.methods methods = site.mesh_vpn.fastd.methods()
end end
@ -39,7 +39,7 @@ uci:section('fastd', 'fastd', 'mesh_vpn', {
syslog_level = syslog_level, syslog_level = syslog_level,
interface = 'mesh-vpn', interface = 'mesh-vpn',
mode = 'tap', mode = 'tap',
mtu = site.mesh_vpn.mtu, mtu = site.mesh_vpn.mtu(),
secure_handshakes = true, secure_handshakes = true,
method = methods, method = methods,
packet_mark = 1, packet_mark = 1,
@ -92,7 +92,7 @@ function add_groups(prefix, groups, parent)
end end
end end
add_groups('mesh_vpn', site.mesh_vpn.fastd.groups) add_groups('mesh_vpn', site.mesh_vpn.fastd.groups())
uci:save('fastd') uci:save('fastd')

View File

@ -1,6 +1,6 @@
#!/usr/bin/lua #!/usr/bin/lua
local site = require 'gluon.site_config' local site = require 'gluon.site'
local util = require 'gluon.util' local util = require 'gluon.util'
local uci = require('simple-uci').cursor() local uci = require('simple-uci').cursor()
@ -27,7 +27,7 @@ uci:section('tunneldigger', 'broker', 'mesh_vpn', {
bind_interface = 'br-wan', bind_interface = 'br-wan',
group = 'gluon-mesh-vpn', group = 'gluon-mesh-vpn',
broker_selection = 'usage', broker_selection = 'usage',
address = site.mesh_vpn.tunneldigger.brokers, address = site.mesh_vpn.tunneldigger.brokers(),
}) })
uci:save('tunneldigger') uci:save('tunneldigger')

View File

@ -1,18 +1,12 @@
#!/usr/bin/lua #!/usr/bin/lua
local site = require 'gluon.site_config' local site = require 'gluon.site'
local uci = require('simple-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')
if site.roles then
default_role = site.roles.default
else
default_role = ''
end
if not role then if not role then
uci:set(config, uci:get_first(config, 'system'), 'role', default_role) uci:set(config, uci:get_first(config, 'system'), 'role', site.roles.default(''))
uci:save(config) uci:save(config)
end end

View File

@ -46,7 +46,7 @@ init_switch() {
start_service() { start_service() {
prepare_config prepare_config
init_switch 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_open_instance
procd_set_param command /sbin/netifd -c /var/gluon/setup-mode/config procd_set_param command /sbin/netifd -c /var/gluon/setup-mode/config

View File

@ -1,14 +1,11 @@
#!/usr/bin/lua #!/usr/bin/lua
local site = require 'gluon.site_config' local site = require 'gluon.site'
local uci = require('simple-uci').cursor() local uci = require('simple-uci').cursor()
if site.setup_mode if site.setup_mode.skip(false) and not uci:get_first('gluon-setup-mode', 'setup_mode', 'configured', false) then
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") local name = uci:get_first("gluon-setup-mode", "setup_mode")
uci:set("gluon-setup-mode", name, "configured", true) uci:set("gluon-setup-mode", name, "configured", true)
uci:save('gluon-setup-mode') uci:save('gluon-setup-mode')
end end

View File

@ -4,7 +4,7 @@
local lutil = require 'gluon.web.util' local lutil = require 'gluon.web.util'
local pretty_hostname = require 'pretty_hostname' local pretty_hostname = require 'pretty_hostname'
local site = require 'gluon.site_config' local site = require 'gluon.site'
local sysconfig = require 'gluon.sysconfig' local sysconfig = require 'gluon.sysconfig'
local platform = require 'gluon.platform' local platform = require 'gluon.platform'
local util = require "gluon.util" local util = require "gluon.util"
@ -26,7 +26,7 @@
model = platform.get_model(), model = platform.get_model(),
version = util.trim(fs.readfile('/lib/gluon/gluon-version')), version = util.trim(fs.readfile('/lib/gluon/gluon-version')),
release = util.trim(fs.readfile('/lib/gluon/release')), release = util.trim(fs.readfile('/lib/gluon/release')),
site = site.site_name, site = site.site_name(),
pubkey = 'n/a', pubkey = 'n/a',
} }

View File

@ -16,14 +16,14 @@ else
end end
function mode:write(data) function mode:write(data)
local site = require 'gluon.site_config' local site = require 'gluon.site'
local methods = {} local methods = {}
if data == 'performance' then if data == 'performance' then
table.insert(methods, 'null') table.insert(methods, 'null')
end 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 if method ~= 'null' then
table.insert(methods, method) table.insert(methods, method)
end end

View File

@ -1,5 +1,5 @@
local f, s, o local f, s, o
local site = require 'gluon.site_config' local site = require 'gluon.site'
local uci = require("simple-uci").cursor() local uci = require("simple-uci").cursor()
local config = 'gluon-node-info' local config = 'gluon-node-info'
@ -16,7 +16,7 @@ s = f:section(Section, nil, translate(
o = s:option(ListValue, "role", translate("Role")) o = s:option(ListValue, "role", translate("Role"))
o.default = 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)) o:value(role, translate('gluon-web-node-role:role:' .. role))
end end