Merge b04e84a80d
into 99b02701cc
This commit is contained in:
commit
0f8a86dcc6
@ -40,11 +40,16 @@ local autoupdater_util = require 'autoupdater.util'
|
||||
autoupdater_util.randomseed()
|
||||
|
||||
|
||||
-- Perform updates at a random time between 04:00 and 05:00, and once an hour
|
||||
-- a fallback update (used after the regular updates haven't worked for
|
||||
-- (priority+1) days after a firmware release, for example because the node
|
||||
-- is always offline at night)
|
||||
local minute = math.random(0, 59)
|
||||
-- Perform updates at a random time between 04:00 and 05:00 in case no specific
|
||||
-- time is specified (gluon.autoupdater.minute), and once an hour a fallback
|
||||
-- update (used after the regular updates haven't worked for (priority+1) days
|
||||
-- after a firmware release, for example because the node is always offline at
|
||||
-- night)
|
||||
if not uci:get('gluon', 'autoupdater') then
|
||||
uci:section('gluon', 'autoupdater', 'autoupdater')
|
||||
uci:save('gluon')
|
||||
end
|
||||
local minute = uci:get('gluon', 'autoupdater', 'minute') or math.random(0, 59)
|
||||
|
||||
local f = io.open('/usr/lib/micron.d/autoupdater', 'w')
|
||||
f:write(string.format('%i 4 * * * /usr/sbin/autoupdater\n', minute))
|
||||
|
@ -18,3 +18,17 @@ msgstr "Branch"
|
||||
|
||||
msgid "Enable"
|
||||
msgstr "Aktivieren"
|
||||
|
||||
msgid "Minute"
|
||||
msgstr "Minute"
|
||||
|
||||
msgid ""
|
||||
"This value forces the autoupdater to check for updates at the specified "
|
||||
"minute. Normally there is no need to set this value because it is selected "
|
||||
"automatically. You may want to set this to a specific value if you have "
|
||||
"multiple nodes which should not update at the same time."
|
||||
msgstr ""
|
||||
"Dieser Wert zwingt den Autoupdater, in der festgelegten Minute nach neuen "
|
||||
"Updates zu suchen. Normalerweise muss dieser Wert nicht gesetzt werden, da "
|
||||
"er automatisch gewählt wird. Wenn du jedoch mehrere Knoten betreibst und "
|
||||
"diese nicht zur gleichen Zeit updaten dürfen, könntest du diesen Wert setzen."
|
||||
|
@ -18,3 +18,13 @@ msgstr "Branche"
|
||||
|
||||
msgid "Enable"
|
||||
msgstr "Activer"
|
||||
|
||||
msgid "Minute"
|
||||
msgstr "Minute"
|
||||
|
||||
msgid ""
|
||||
"This value forces the autoupdater to check for updates at the specified "
|
||||
"minute. Normally there is no need to set this value because it is selected "
|
||||
"automatically. You may want to set this to a specific value if you have "
|
||||
"multiple nodes which should not update at the same time."
|
||||
msgstr ""
|
||||
|
@ -9,3 +9,13 @@ msgstr ""
|
||||
|
||||
msgid "Enable"
|
||||
msgstr ""
|
||||
|
||||
msgid "Minute"
|
||||
msgstr ""
|
||||
|
||||
msgid ""
|
||||
"This value forces the autoupdater to check for updates at the specified "
|
||||
"minute. Normally there is no need to set this value because it is selected "
|
||||
"automatically. You may want to set this to a specific value if you have "
|
||||
"multiple nodes which should not update at the same time."
|
||||
msgstr ""
|
||||
|
@ -32,8 +32,34 @@ function o:write(data)
|
||||
uci:set("autoupdater", autoupdater, "branch", data)
|
||||
end
|
||||
|
||||
o = s:option(Value, "minute", translate("Minute"), translate(
|
||||
"This value forces the autoupdater to check for updates at the "
|
||||
.. "specified minute. Normally there is no need to set this value "
|
||||
.. "because it is selected automatically. You may want to set this to "
|
||||
.. "a specific value if you have multiple nodes which should not "
|
||||
.. "update at the same time."
|
||||
))
|
||||
o.datatype = "irange(0, 59)"
|
||||
o.default = uci:get("gluon", "autoupdater", "minute")
|
||||
o.optional = true
|
||||
|
||||
function o:write(data)
|
||||
if data == uci:get("gluon", "autoupdater", "minute") then
|
||||
return
|
||||
end
|
||||
uci:set("gluon", "autoupdater", "minute", data)
|
||||
|
||||
if data then
|
||||
local f = io.open("/usr/lib/micron.d/autoupdater", "w")
|
||||
f:write(string.format("%i 4 * * * /usr/sbin/autoupdater\n", data))
|
||||
f:write(string.format("%i 0-3,5-23 * * * /usr/sbin/autoupdater --fallback\n", data))
|
||||
f:close()
|
||||
end
|
||||
end
|
||||
|
||||
function f:write()
|
||||
uci:commit("autoupdater")
|
||||
uci:commit("gluon")
|
||||
end
|
||||
|
||||
return f
|
||||
|
Loading…
Reference in New Issue
Block a user