From c0afb9cc397e1199e50417bc8766dede23d52150 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 3 Jan 2022 02:41:33 +0100 Subject: [PATCH 1/9] contrib: lsupgrade: do not search the OpenWrt "packages" feed Iterating over all the package directories in the OpenWrt feed takes a while, even though it doesn't contain any upgrade scripts. Skip the whole directory. --- contrib/lsupgrade.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/lsupgrade.sh b/contrib/lsupgrade.sh index f8e28f9a..25d10415 100755 --- a/contrib/lsupgrade.sh +++ b/contrib/lsupgrade.sh @@ -28,7 +28,7 @@ fi pushd "$(dirname "$0")/.." >/dev/null -find ./package packages -name Makefile | while read -r makefile; do +find ./package packages -name Makefile | grep -v '^packages/packages/' | while read -r makefile; do dir="$(dirname "$makefile")" pushd "$dir" >/dev/null From c7e38fdc2c29672944ccd00b504ddd86c00bfa41 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 3 Jan 2022 02:46:05 +0100 Subject: [PATCH 2/9] contrib: lsupgrade: optimize output - Use printf instead of echo for better portability - Print whole path without reordering components - Deduplicate code --- contrib/lsupgrade.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/contrib/lsupgrade.sh b/contrib/lsupgrade.sh index 25d10415..284fe44b 100755 --- a/contrib/lsupgrade.sh +++ b/contrib/lsupgrade.sh @@ -37,13 +37,12 @@ find ./package packages -name Makefile | grep -v '^packages/packages/' | while r dirname="$(dirname "$dir" | cut -d/ -f 3-)" package="$(basename "$dir")" - for file in "${SUFFIX1}"/*; do - echo "${GREEN}$(basename "${file}")${RESET}" "(${BLUE}${repo}${RESET}/${dirname}${dirname:+/}${RED}${package}${RESET}/${SUFFIX1})" - done - for file in "${SUFFIX2}"/*; do - echo "${GREEN}$(basename "${file}")${RESET}" "(${BLUE}${repo}${RESET}/${dirname}${dirname:+/}${RED}${package}${RESET}/${SUFFIX2})" + for file in "${SUFFIX1}"/* "${SUFFIX2}"/*; do + basename="$(basename "${file}")" + suffix="$(dirname "${file}")" + printf "%s\t%s\n" "${basename}" "${BLUE}${repo}${RESET}/${dirname}${dirname:+/}${RED}${package}${RESET}/${suffix}/${GREEN}${basename}${RESET}" done popd >/dev/null -done | sort +done | sort | cut -f2- popd >/dev/null From 84f4c164f46725da4d2355fc3186acdc9b08449c Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 2 Jan 2022 22:23:46 +0100 Subject: [PATCH 3/9] gluon-setup-mode: remove obsolete migration --- .../lib/gluon/upgrade/310-setup-mode-migrate | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100755 package/gluon-setup-mode/luasrc/lib/gluon/upgrade/310-setup-mode-migrate diff --git a/package/gluon-setup-mode/luasrc/lib/gluon/upgrade/310-setup-mode-migrate b/package/gluon-setup-mode/luasrc/lib/gluon/upgrade/310-setup-mode-migrate deleted file mode 100755 index ecaa07f9..00000000 --- a/package/gluon-setup-mode/luasrc/lib/gluon/upgrade/310-setup-mode-migrate +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/lua - -local uci = require('simple-uci').cursor() - - -local old = uci:get_first('gluon-config-mode', 'wizard', 'configured') -if old == '1' then - local setup_mode = uci:get_first('gluon-setup-mode', 'setup_mode') - uci:set('gluon-setup-mode', setup_mode, 'configured', true) - - uci:save('gluon-setup-mode') -end - -os.remove('/etc/config/gluon-config-mode') From c530070e962e4bae2bc58e51e0556a866d473908 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 2 Jan 2022 22:28:08 +0100 Subject: [PATCH 4/9] gluon-mesh-vpn-tunneldigger: remove obsolete migration --- .../lib/gluon/upgrade/400-mesh-vpn-tunneldigger | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/package/gluon-mesh-vpn-tunneldigger/luasrc/lib/gluon/upgrade/400-mesh-vpn-tunneldigger b/package/gluon-mesh-vpn-tunneldigger/luasrc/lib/gluon/upgrade/400-mesh-vpn-tunneldigger index b37bb476..9888d87e 100755 --- a/package/gluon-mesh-vpn-tunneldigger/luasrc/lib/gluon/upgrade/400-mesh-vpn-tunneldigger +++ b/package/gluon-mesh-vpn-tunneldigger/luasrc/lib/gluon/upgrade/400-mesh-vpn-tunneldigger @@ -7,22 +7,7 @@ local vpn_core = require 'gluon.mesh-vpn' local uci = require('simple-uci').cursor() -local enabled - --- Delete old broker config section (remove in 2019) -if not uci:get('tunneldigger', 'mesh_vpn') then - if uci:get_first('tunneldigger', 'broker', 'interface') == 'mesh-vpn' then - enabled = uci:get_first('tunneldigger', 'broker', 'enabled') - end - - -- In the usual case (no migration from old tunneldigger package), the - -- enabled state is set in the 500-mesh-vpn script - - uci:delete_all('tunneldigger', 'broker') -end - uci:section('tunneldigger', 'broker', 'mesh_vpn', { - enabled = enabled, uuid = util.node_id(), interface = vpn_core.get_interface(), bind_interface = 'br-wan', From 225e8692bd7b1916aabd2ad633289b8094ab2d28 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 2 Jan 2022 22:29:51 +0100 Subject: [PATCH 5/9] gluon-radvd: remove obsolete migration --- .../luasrc/lib/gluon/upgrade/500-radvd-remove-user | 5 ----- 1 file changed, 5 deletions(-) delete mode 100755 package/gluon-radvd/luasrc/lib/gluon/upgrade/500-radvd-remove-user diff --git a/package/gluon-radvd/luasrc/lib/gluon/upgrade/500-radvd-remove-user b/package/gluon-radvd/luasrc/lib/gluon/upgrade/500-radvd-remove-user deleted file mode 100755 index 036406af..00000000 --- a/package/gluon-radvd/luasrc/lib/gluon/upgrade/500-radvd-remove-user +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/lua - -local users = require 'gluon.users' - -users.remove_user('gluon-radvd') From d8f6ed2406ba061faa50ae005879c59f750dd322 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 2 Jan 2022 22:20:01 +0100 Subject: [PATCH 6/9] gluon-node-info: remove obsolete migration/fixup --- .../gluon/upgrade/520-node-info-whitespace-fix | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100755 package/gluon-node-info/luasrc/lib/gluon/upgrade/520-node-info-whitespace-fix diff --git a/package/gluon-node-info/luasrc/lib/gluon/upgrade/520-node-info-whitespace-fix b/package/gluon-node-info/luasrc/lib/gluon/upgrade/520-node-info-whitespace-fix deleted file mode 100755 index 62cd4beb..00000000 --- a/package/gluon-node-info/luasrc/lib/gluon/upgrade/520-node-info-whitespace-fix +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/lua -local uci = require('simple-uci').cursor() -local util = require 'gluon.util' - -local sname = uci:get_first('gluon-node-info', 'location') -if sname then - local options = {'longitude', 'latitude', 'altitude'} - for _, option in ipairs(options) do - local value = uci:get('gluon-node-info', sname, option) - if value then - uci:set('gluon-node-info', sname, option, util.trim(value)) - end - end - uci:save('gluon-node-info') -end From b68a07e9303840bb26763fd7b3c44dbcebc7b1ea Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 1 Jan 2022 23:06:03 +0100 Subject: [PATCH 7/9] gluon-mesh-vpn-fastd: merge secret generation setup into main upgrade script There wasn't really a reason to have a separate script to set a single value. In addition, the old script was using the identifier 'c' instead of 'uci' for the UCI cursor. Following the convention of the other scripts is helpful so it is easy to grep for all uses of a certain config file/ option. --- .../luasrc/lib/gluon/upgrade/400-mesh-vpn-fastd | 6 ++++++ .../gluon/upgrade/410-mesh-vpn-fastd-generate-secret | 12 ------------ 2 files changed, 6 insertions(+), 12 deletions(-) delete mode 100755 package/gluon-mesh-vpn-fastd/luasrc/lib/gluon/upgrade/410-mesh-vpn-fastd-generate-secret diff --git a/package/gluon-mesh-vpn-fastd/luasrc/lib/gluon/upgrade/400-mesh-vpn-fastd b/package/gluon-mesh-vpn-fastd/luasrc/lib/gluon/upgrade/400-mesh-vpn-fastd index 4d56be2a..5fed1e8c 100755 --- a/package/gluon-mesh-vpn-fastd/luasrc/lib/gluon/upgrade/400-mesh-vpn-fastd +++ b/package/gluon-mesh-vpn-fastd/luasrc/lib/gluon/upgrade/400-mesh-vpn-fastd @@ -9,6 +9,11 @@ local uci = require('simple-uci').cursor() local syslog_level = uci:get('fastd', 'mesh_vpn', 'syslog_level') or 'verbose' +local secret = uci:get('fastd', 'mesh_vpn', 'secret') +if not secret or not secret:match(('%x'):rep(64)) then + secret = 'generate' +end + local methods if site.mesh_vpn.fastd.configurable(false) then @@ -38,6 +43,7 @@ end uci:section('fastd', 'fastd', 'mesh_vpn', { group = 'gluon-mesh-vpn', syslog_level = syslog_level, + secret = secret, interface = vpn_core.get_interface(), mode = 'tap', mtu = site.mesh_vpn.mtu(), diff --git a/package/gluon-mesh-vpn-fastd/luasrc/lib/gluon/upgrade/410-mesh-vpn-fastd-generate-secret b/package/gluon-mesh-vpn-fastd/luasrc/lib/gluon/upgrade/410-mesh-vpn-fastd-generate-secret deleted file mode 100755 index f43e8b1f..00000000 --- a/package/gluon-mesh-vpn-fastd/luasrc/lib/gluon/upgrade/410-mesh-vpn-fastd-generate-secret +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/lua - -local uci = require 'simple-uci' - -local c = uci.cursor() - -local secret = c:get("fastd", "mesh_vpn", "secret") - -if not secret or not secret:match(("%x"):rep(64)) then - c:set("fastd", "mesh_vpn", "secret", "generate") - c:save("fastd") -end From 12127813c556d4ad1df69495a1184fd71a3275c4 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 5 Jan 2022 18:41:05 +0100 Subject: [PATCH 8/9] gluon-core: move preserve_channels setting to /etc/config/gluon /etc/config/gluon-core is used for nothing else. As /etc/config/gluon uses a named wireless section, also change the get_first() to get(). --- package/gluon-core/luasrc/usr/lib/lua/gluon/wireless.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/gluon-core/luasrc/usr/lib/lua/gluon/wireless.lua b/package/gluon-core/luasrc/usr/lib/lua/gluon/wireless.lua index 3e0696aa..62fe3228 100644 --- a/package/gluon-core/luasrc/usr/lib/lua/gluon/wireless.lua +++ b/package/gluon-core/luasrc/usr/lib/lua/gluon/wireless.lua @@ -123,7 +123,7 @@ function M.foreach_radio(uci, f) end function M.preserve_channels(uci) - return uci:get_first('gluon-core', 'wireless', 'preserve_channels') + return uci:get('gluon', 'wireless', 'preserve_channels') end function M.device_supports_wpa3() From 578daf5f87d3d12d53611fc66d7565425f2a47d8 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 5 Jan 2022 18:42:52 +0100 Subject: [PATCH 9/9] gluon-core: remove obsolete config file --- package/gluon-core/Makefile | 1 - package/gluon-core/files/etc/config/gluon-core | 1 - 2 files changed, 2 deletions(-) delete mode 100644 package/gluon-core/files/etc/config/gluon-core diff --git a/package/gluon-core/Makefile b/package/gluon-core/Makefile index c56b78bb..93b2d599 100644 --- a/package/gluon-core/Makefile +++ b/package/gluon-core/Makefile @@ -31,7 +31,6 @@ endef define Package/gluon-core/conffiles /etc/config/gluon -/etc/config/gluon-core endef define Package/gluon-core/install diff --git a/package/gluon-core/files/etc/config/gluon-core b/package/gluon-core/files/etc/config/gluon-core deleted file mode 100644 index 9787ccc9..00000000 --- a/package/gluon-core/files/etc/config/gluon-core +++ /dev/null @@ -1 +0,0 @@ -config wireless