Commit 90977f4a authored by Julian Schuh's avatar Julian Schuh

update update stabilizer to check if selected branch is valid before updating

parent a6894595
......@@ -10,12 +10,14 @@ function Set (list)
return set
end
-- check if the autoupdater is set to a branch from which it should be migrated
local from_branches = Set(site.update_stabilizer.from_branches())
local current_branch = uci:get('autoupdater', 'settings', 'branch')
if not from_branches[current_branch] then
return
end
-- check if the device if one of the models that should be migrated
local model = platform_info.get_image_name()
local new_models = Set(site.update_stabilizer.models())
if not new_models[model] then
......@@ -25,6 +27,22 @@ end
print('[+] device matches criteria (current branch ' .. current_branch .. ', model ' .. model .. ') for change of autoupdater branch')
local to_branch = site.update_stabilizer.to_branch()
if not to_branch then
return
end
-- get list of all configured autoupdater branches
local valid_branches = {}
uci:foreach('autoupdater', 'branch', function(branch)
valid_branches[branch['.name']] = true
end)
-- check if the configured branch name is valid and exists
if not valid_branches[to_branch] then
return
end
-- do update branch
uci:set('autoupdater', 'settings', 'branch', to_branch)
uci:save('autoupdater')
uci:commit('autoupdater')
print('[+] autoupdater branch set to ' .. to_branch)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment