Skip to content

Commit

Permalink
ffac-eol-ssid: rework site configuration
Browse files Browse the repository at this point in the history
Changing "eol_wifi" to "eol_ssid", as the package is called "...-eol-ssid".

The explicit "enabled" allows toggling the feature per domain/site without
touching the uci configs.
  • Loading branch information
grische committed Nov 5, 2023
1 parent 8db76c4 commit d8d3395
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
5 changes: 4 additions & 1 deletion ffac-eol-ssid/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ Then one can add the `ffac-eol-ssid` package to the old version and leave a much
## Site Configuration

```
eol_wifi_ssid = 'erneuern.freifunk.net'
eol_ssid = {
enabled = true,
ssid = 'erneuern.freifunk.net',
}
```

## Upgrading
Expand Down
4 changes: 4 additions & 0 deletions ffac-eol-ssid/check_site.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
obsolete({'eol_wifi_ssid'}, 'Use eol_ssid.ssid instead.')
if need_boolean({'eol_ssid', 'enabled'}, false) then
need_string({'eol_ssid', 'ssid'})
end
16 changes: 5 additions & 11 deletions ffac-eol-ssid/luasrc/lib/gluon/upgrade/950-eol-ssid-nagger
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,20 @@
local site = require 'gluon.site'
local uci = require('simple-uci').cursor()

-- migrate older ffac-eol-ssid version with manual eol-wifi.ssid.disabled=1
if uci:get('eol-wifi', 'ssid') ~= nil then
local deprecated_ssid_enabled = not uci:get_bool('eol-wifi', 'ssid', 'disabled')
uci:set('eol-ssid', 'settings', 'enabled', deprecated_ssid_enabled)
uci:save('eol-ssid')
os.remove('/etc/config/eol-wifi')
end

-- Get/initialize enabled state
if site.eol_wifi_ssid() == nil then
-- Not applicable
os.exit(0)
if not site.eol_ssid.enabled(false) -- disabled for site/domain
or not uci:get_bool('eol-ssid', 'settings', 'enabled') -- disabled on router
then
os.exit(0) -- do not change SSID
end

-- eol-ssid feature disabled on device
if not uci:get_bool('eol-ssid', 'settings', 'enabled') then
os.exit(0)
end

local eol_wifi_ssid = site.eol_wifi_ssid()
local eol_wifi_ssid = site.eol_ssid.ssid()

-- Change client radio ssid
uci:set('wireless', 'client_radio0', 'ssid', eol_wifi_ssid)
Expand Down

0 comments on commit d8d3395

Please sign in to comment.