diff --git a/package/gluon-autoupdater/luasrc/lib/gluon/upgrade/500-autoupdater b/package/gluon-autoupdater/luasrc/lib/gluon/upgrade/500-autoupdater index 10f6197f..351c8e04 100755 --- a/package/gluon-autoupdater/luasrc/lib/gluon/upgrade/500-autoupdater +++ b/package/gluon-autoupdater/luasrc/lib/gluon/upgrade/500-autoupdater @@ -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')