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 9d46acae..f374828b 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 @@ -7,14 +7,11 @@ local uci = require('simple-uci').cursor() local function is_disabled(config, name) - local disabled if uci:get('wireless', name) then - disabled = uci:get_bool('wireless', name, 'disabled') - else - disabled = config and config.disabled + return uci:get_bool('wireless', name, 'disabled') end - return disabled + return config.disabled(false) end local function configure_client(config, radio, index, suffix) @@ -23,7 +20,7 @@ local function configure_client(config, radio, index, suffix) uci:delete('wireless', name) - if not config then + if not config() then return end @@ -36,7 +33,7 @@ local function configure_client(config, radio, index, suffix) device = radio, network = 'client', mode = 'ap', - ssid = config.ssid, + ssid = config.ssid(), macaddr = macaddr, ifname = suffix and 'client' .. suffix, disabled = disabled or false, diff --git a/package/gluon-core/luasrc/lib/gluon/upgrade/200-wireless b/package/gluon-core/luasrc/lib/gluon/upgrade/200-wireless index 6afbf22a..ee9a0298 100755 --- a/package/gluon-core/luasrc/lib/gluon/upgrade/200-wireless +++ b/package/gluon-core/luasrc/lib/gluon/upgrade/200-wireless @@ -1,7 +1,7 @@ #!/usr/bin/lua local util = require 'gluon.util' -local site = require 'gluon.site_config' +local site = require 'gluon.site' local sysconfig = require 'gluon.sysconfig' local uci = require('simple-uci').cursor() @@ -12,11 +12,12 @@ if not sysconfig.gluon_version then end local function get_channel(radio, config) + local channel if uci:get_first('gluon-core', 'wireless', 'preserve_channels') then - return uci:get('wireless', radio, 'channel') or config.channel - else - return config.channel + channel = uci:get('wireless', radio, 'channel') end + + return channel or config.channel() end local function is_disabled(name) @@ -134,7 +135,7 @@ local function fixup_wan(radio, index) end local function configure_radio(radio, index, config) - if not config then + if not config() then return end @@ -149,29 +150,27 @@ local function configure_radio(radio, index, config) uci:set('wireless', radio, 'channel', channel) uci:set('wireless', radio, 'htmode', 'HT20') - uci:set('wireless', radio, 'country', site.regdom) + uci:set('wireless', radio, 'country', site.regdom()) - uci:set_list('wireless', radio, 'supported_rates', config.supported_rates) - uci:set_list('wireless', radio, 'basic_rate', config.basic_rate) + uci:set_list('wireless', radio, 'supported_rates', config.supported_rates()) + uci:set_list('wireless', radio, 'basic_rate', config.basic_rate()) local ibss_disabled = is_disabled('ibss_' .. radio) local mesh_disabled = is_disabled('mesh_' .. radio) - configure_ibss(config.ibss, radio, index, suffix, + configure_ibss(config.ibss(), radio, index, suffix, first_non_nil( ibss_disabled, mesh_disabled, - (config.ibss or {}).disabled, -- will be nil if config.ibss or config.ibss.disabled is unset - false + config.ibss.disabled(false) ) ) - configure_mesh(config.mesh, radio, index, suffix, + configure_mesh(config.mesh(), radio, index, suffix, first_non_nil( mesh_disabled, ibss_disabled, - (config.mesh or {}).disabled, -- will be nil if config.mesh or config.mesh.disabled is unset - false + config.mesh.disabled(false) ) ) 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 42524445..5ee6c376 100644 --- a/package/gluon-core/luasrc/usr/lib/lua/gluon/util.lua +++ b/package/gluon-core/luasrc/usr/lib/lua/gluon/util.lua @@ -35,7 +35,7 @@ local table = table local nixio = require 'nixio' local hash = require 'hash' local sysconfig = require 'gluon.sysconfig' -local site = require 'gluon.site_config' +local site = require 'gluon.site' local fs = require 'nixio.fs' @@ -131,7 +131,7 @@ function site_seed_bytes(key, length) -- cryptographic strength while ret:len() < 2*length do i = i + 1 - v = hash.md5(v .. key .. site.site_seed:lower() .. i) + v = hash.md5(v .. key .. site.site_seed():lower() .. i) ret = ret .. v end @@ -253,11 +253,9 @@ end function iterate_radios(uci, f) local radios = {} - uci:foreach('wireless', 'wifi-device', - function(s) + uci:foreach('wireless', 'wifi-device', function(s) table.insert(radios, s['.name']) - end - ) + end) for index, radio in ipairs(radios) do local hwmode = uci:get('wireless', radio, 'hwmode')