From 463f87284477ed98d1dc4ff65030fc8968bc01af Mon Sep 17 00:00:00 2001 From: Jan-Philipp Litza Date: Fri, 24 Feb 2017 11:46:43 +0100 Subject: [PATCH] autoupdater: add possibility to specify mirrors on commandline (#123) --- admin/autoupdater/files/usr/sbin/autoupdater | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/admin/autoupdater/files/usr/sbin/autoupdater b/admin/autoupdater/files/usr/sbin/autoupdater index 3b17198..2102cff 100755 --- a/admin/autoupdater/files/usr/sbin/autoupdater +++ b/admin/autoupdater/files/usr/sbin/autoupdater @@ -35,6 +35,7 @@ local force = false -- timespan given by the priority and another 24h have passed local fallback = false +local mirrors = {} local function parse_args() local i = 1 @@ -52,9 +53,11 @@ local function parse_args() end branch_name = arg[i] - else + elseif arg[i]:sub(0, 1) == '-' then io.stderr:write("Error parsing command line: unexpected argument '" .. arg[i] .. "'\n") os.exit(1) + else + table.insert(mirrors, arg[i]) end i = i+1 @@ -350,10 +353,13 @@ if not lockfd:lock('tlock') then end -local mirrors = branch.mirror +if #mirrors == 0 then + while #branch.mirror > 0 do + table.insert(mirrors, table.remove(branch.mirror, math.random(#branch.mirror))) + end +end -while #mirrors > 0 do - local mirror = table.remove(mirrors, math.random(#mirrors)) +for k, mirror in ipairs(mirrors) do if autoupdate(mirror) then os.exit(0) end