From 2024f241f2644bf1ccf03433e218fc373bbb070a Mon Sep 17 00:00:00 2001 From: Grische <2787581+grische@users.noreply.github.com> Date: Sun, 5 Nov 2023 15:12:55 +0100 Subject: [PATCH] ffac-eol-ssid: add explicit "enabled" for sites The explicit "enabled" allows toggling the feature per domain/site without touching the uci configs. --- ffac-eol-ssid/README.md | 5 ++++- ffac-eol-ssid/check_site.lua | 4 ++++ .../luasrc/lib/gluon/upgrade/950-eol-ssid-nagger | 15 +++++---------- 3 files changed, 13 insertions(+), 11 deletions(-) create mode 100644 ffac-eol-ssid/check_site.lua diff --git a/ffac-eol-ssid/README.md b/ffac-eol-ssid/README.md index 8f8b33d7..e8d24094 100644 --- a/ffac-eol-ssid/README.md +++ b/ffac-eol-ssid/README.md @@ -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 diff --git a/ffac-eol-ssid/check_site.lua b/ffac-eol-ssid/check_site.lua new file mode 100644 index 00000000..314da07b --- /dev/null +++ b/ffac-eol-ssid/check_site.lua @@ -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 diff --git a/ffac-eol-ssid/luasrc/lib/gluon/upgrade/950-eol-ssid-nagger b/ffac-eol-ssid/luasrc/lib/gluon/upgrade/950-eol-ssid-nagger index e81ffb1a..37edee4a 100755 --- a/ffac-eol-ssid/luasrc/lib/gluon/upgrade/950-eol-ssid-nagger +++ b/ffac-eol-ssid/luasrc/lib/gluon/upgrade/950-eol-ssid-nagger @@ -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)