From 17e1aa4ffdf07d82a4de13bd7c9264e0c830eede Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 15 Dec 2021 22:29:04 +0100 Subject: [PATCH] gluon-core: migrate wireless configuration from hwmode to band The migration is done very early, as other upgrade scripts depend on the band setting through platform.device_uses_11a(). --- .../lib/gluon/upgrade/005-wireless-migration | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 package/gluon-core/luasrc/lib/gluon/upgrade/005-wireless-migration diff --git a/package/gluon-core/luasrc/lib/gluon/upgrade/005-wireless-migration b/package/gluon-core/luasrc/lib/gluon/upgrade/005-wireless-migration new file mode 100755 index 00000000..fc79249b --- /dev/null +++ b/package/gluon-core/luasrc/lib/gluon/upgrade/005-wireless-migration @@ -0,0 +1,20 @@ +#!/usr/bin/lua + +local uci = require('simple-uci').cursor() + +-- Migration from hwmode to band (OpenWrt 21.02) +-- Use uci:foreach(), as wireless.foreach_radio() depends on band already being set +uci:foreach('wireless', 'wifi-device', function(radio) + local radio_name = radio['.name'] + local hwmode = radio.hwmode + if not radio.band then + if hwmode == '11g' or hwmode == '11ng' then + uci:set('wireless', radio_name, 'band', '2g') + elseif hwmode == '11a' or hwmode == '11na' then + uci:set('wireless', radio_name, 'band', '5g') + end + end + uci:delete('wireless', radio_name, 'hwmode') +end) + +uci:save('wireless')