Skip to content
Snippets Groups Projects
Unverified Commit 53cf8796 authored by Matthias Schiffer's avatar Matthias Schiffer
Browse files

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
parent 2c65f083
No related branches found
No related tags found
No related merge requests found
......@@ -32,20 +32,24 @@ local function default_branch()
return site.autoupdater.branch(min_branch)
end
local enabled, branch
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
enabled = false
end
uci:section('autoupdater', 'autoupdater', 'settings', {
enabled = enabled,
branch = branch,
})
end
uci:section('autoupdater', 'autoupdater', 'settings', {
enabled = enabled,
branch = branch,
})
uci:set('autoupdater', 'settings', 'version_file', '/lib/gluon/release')
uci:save('autoupdater')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment