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().
main
Matthias Schiffer 2021-12-15 22:29:04 +01:00
parent c52089fcda
commit 17e1aa4ffd
No known key found for this signature in database
GPG Key ID: 16EF3F64CB201D9C
1 changed files with 20 additions and 0 deletions

View File

@ -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')