Skip to content

Commit

Permalink
ffac-eol-ssid: add explicit "enabled" for sites
Browse files Browse the repository at this point in the history
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 1353b64 commit 2024f24
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 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_wifi = {
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_wifi.settings.ssid instead.')
if need_boolean({'eol_wifi', 'enabled'}, false) then
need_string({'eol_wifi', 'ssid'})
end
15 changes: 5 additions & 10 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,18 +3,13 @@
local site = require 'gluon.site'
local uci = require('simple-uci').cursor()

-- Get/initialize enabled state
if site.eol_wifi_ssid() == nil then
-- Not applicable
os.exit(0)
if not site.eol_wifi.enabled(false) -- disabled for site/domain
or not uci:get_bool('eol_wifi', '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_wifi.ssid()

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

0 comments on commit 2024f24

Please sign in to comment.