From d5a0fa8be4056c5912eaf498998580a466c21d92 Mon Sep 17 00:00:00 2001 From: Grische <2787581+grische@users.noreply.github.com> Date: Sun, 5 Nov 2023 13:41:06 +0100 Subject: [PATCH] ffac-eol-ssid: fix name of eol-ssid subsystem Before thie change, the eol-ssid uci subsystem had to be created manually and the uci settings did not show up for this package. --- ffac-eol-ssid/Makefile | 4 ++++ ffac-eol-ssid/README.md | 9 ++++++++- ffac-eol-ssid/check_site.lua | 3 +++ ffac-eol-ssid/files/etc/config/eol-ssid | 2 ++ .../lib/gluon/upgrade/500-eol-ssid-config | 11 +++++++++++ .../lib/gluon/upgrade/950-eol-ssid-nagger | 17 ++++++++--------- 6 files changed, 36 insertions(+), 10 deletions(-) create mode 100644 ffac-eol-ssid/check_site.lua create mode 100644 ffac-eol-ssid/files/etc/config/eol-ssid create mode 100644 ffac-eol-ssid/luasrc/lib/gluon/upgrade/500-eol-ssid-config diff --git a/ffac-eol-ssid/Makefile b/ffac-eol-ssid/Makefile index 508b0014..6dda6b7b 100644 --- a/ffac-eol-ssid/Makefile +++ b/ffac-eol-ssid/Makefile @@ -12,4 +12,8 @@ define Package/$(PKG_NAME) DEPENDS:=+gluon-core endef +define Package/ffac-eol-ssid/conffiles +/etc/config/eol-ssid +endef + $(eval $(call BuildPackageGluon,ffac-eol-ssid)) diff --git a/ffac-eol-ssid/README.md b/ffac-eol-ssid/README.md index 0bcd0d75..258cda5c 100644 --- a/ffac-eol-ssid/README.md +++ b/ffac-eol-ssid/README.md @@ -13,9 +13,16 @@ 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 + +This package will migrate uci settings for previous version of this package. + ## Limitations As this package was created to migrate older devices, it does not respect 5GHz or OWE radio. diff --git a/ffac-eol-ssid/check_site.lua b/ffac-eol-ssid/check_site.lua new file mode 100644 index 00000000..5f99700b --- /dev/null +++ b/ffac-eol-ssid/check_site.lua @@ -0,0 +1,3 @@ +if need_boolean({'eol_wifi', 'enabled'}, false) then + need_string(in_site({'eol_wifi', 'ssid'})) +end diff --git a/ffac-eol-ssid/files/etc/config/eol-ssid b/ffac-eol-ssid/files/etc/config/eol-ssid new file mode 100644 index 00000000..7bf83a19 --- /dev/null +++ b/ffac-eol-ssid/files/etc/config/eol-ssid @@ -0,0 +1,2 @@ +config settings + option enabled '1' diff --git a/ffac-eol-ssid/luasrc/lib/gluon/upgrade/500-eol-ssid-config b/ffac-eol-ssid/luasrc/lib/gluon/upgrade/500-eol-ssid-config new file mode 100644 index 00000000..3582f394 --- /dev/null +++ b/ffac-eol-ssid/luasrc/lib/gluon/upgrade/500-eol-ssid-config @@ -0,0 +1,11 @@ +#!/usr/bin/lua + +local uci = require('simple-uci').cursor() + +-- migrate older versions +if uci:get('eol-wifi', 'ssid') then + local deprecated_ssid_enabled = uci:get_bool('eol-wifi', 'ssid', 'disabled') + uci:set('eol-ssid', 'settings', 'enabled', deprecated_ssid_enabled) + uci:delete('eol-wifi', 'ssid') + uci:save('eol-wifi') +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 fccff643..e81ffb1a 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 @@ -9,14 +9,13 @@ if site.eol_wifi_ssid() == nil then os.exit(0) 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() -if not uci:get_bool('eol-wifi', 'ssid', 'disabled') then - uci:section('eol-wifi', 'ssid', 'ssid', { - disabled = false, - }) - uci:save('eol-wifi') - -- Change client radio ssid - uci:set('wireless', 'client_radio0', 'ssid', eol_wifi_ssid) - uci:save('wireless') -end +-- Change client radio ssid +uci:set('wireless', 'client_radio0', 'ssid', eol_wifi_ssid) +uci:save('wireless')