gluon-autoupdater: revert to default branch when configured branch is invalid
An invalid branch may be set for various reasons: - Previous firmware had an invalid default branch - Branch list has changed and old UCI branch config was removed by a site-specific upgrade script - Manual UCI configuration
This commit is contained in:
parent
2c65f0834b
commit
53cf8796c7
@ -32,20 +32,24 @@ local function default_branch()
|
|||||||
return site.autoupdater.branch(min_branch)
|
return site.autoupdater.branch(min_branch)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local enabled, branch
|
||||||
if not uci:get('autoupdater', 'settings') then
|
if not uci:get('autoupdater', 'settings') then
|
||||||
local enabled = unistd.access('/lib/gluon/autoupdater/default_enabled') ~= nil
|
enabled = unistd.access('/lib/gluon/autoupdater/default_enabled') ~= nil
|
||||||
|
end
|
||||||
|
|
||||||
local branch = default_branch()
|
local old_branch = uci:get('autoupdater', 'settings', 'branch')
|
||||||
|
if not old_branch or not uci:get('autoupdater', old_branch) then
|
||||||
|
branch = default_branch()
|
||||||
if not branch then
|
if not branch then
|
||||||
enabled = false
|
enabled = false
|
||||||
end
|
end
|
||||||
|
|
||||||
uci:section('autoupdater', 'autoupdater', 'settings', {
|
|
||||||
enabled = enabled,
|
|
||||||
branch = branch,
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
uci:section('autoupdater', 'autoupdater', 'settings', {
|
||||||
|
enabled = enabled,
|
||||||
|
branch = branch,
|
||||||
|
})
|
||||||
|
|
||||||
uci:set('autoupdater', 'settings', 'version_file', '/lib/gluon/release')
|
uci:set('autoupdater', 'settings', 'version_file', '/lib/gluon/release')
|
||||||
|
|
||||||
uci:save('autoupdater')
|
uci:save('autoupdater')
|
||||||
|
Loading…
Reference in New Issue
Block a user