Browse Source

ffho-web-autoupdater: introduce minute value

Karsten Böddeker 6 years ago
parent
commit
056b797cf3

+ 14 - 0
ffho/ffho-web-autoupdater/i18n/de.po

@@ -19,5 +19,19 @@ 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."
+
 msgid "Wifi fallback updates"
 msgstr "Wifi-Fallback Updates"

+ 10 - 0
ffho/ffho-web-autoupdater/i18n/ffho-web-autoupdater.pot

@@ -10,5 +10,15 @@ 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 ""
+
 msgid "Wifi fallback updates"
 msgstr ""

+ 26 - 0
ffho/ffho-web-autoupdater/luasrc/lib/gluon/web/model/admin/autoupdater.lua

@@ -34,6 +34,31 @@ 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
+
 local s = f:section(Section, translate('Wifi fallback updates'))
 
 o = s:option(Flag, 'enabled', translate('Enable'))
@@ -45,6 +70,7 @@ end
 
 function f:write()
 	uci:commit('autoupdater')
+	uci:commit("gluon")
 end
 
 return f