gluon-core: provide migration for preserve_channels

The preserve_channels configuration option was moved to the gluon UCI
package without adding a proper migration.

Signed-off-by: David Bauer <mail@david-bauer.net>
This commit is contained in:
David Bauer 2022-08-12 05:09:42 +02:00
parent 357aa96c91
commit d9070eb41a

View File

@ -0,0 +1,23 @@
#!/usr/bin/lua
local wireless = require 'gluon.wireless'
local uci = require('simple-uci').cursor()
local preserve_channels = wireless.preserve_channels(uci)
-- Migrate preserve channels from pre-2022.01
local core_wireless = uci:get_first('gluon-core', 'wireless')
if core_wireless ~= nil then
local preserve_legacy = uci:get_bool('gluon-core', core_wireless, 'preserve_channels')
if preserve_legacy then
preserve_channels = true
end
uci:delete('gluon-core', core_wireless)
uci:save('gluon-core')
end
uci:section('gluon', 'wireless', 'wireless', {
preserve_channels = preserve_channels or false,
})
uci:save('gluon')