소스 검색

gluon-autoupdater: introduce uci value gluon.autoupdater.minute

kb-light 7 년 전
부모
커밋
7d53aeab39
1개의 변경된 파일10개의 추가작업 그리고 5개의 파일을 삭제
  1. 10 5
      package/gluon-autoupdater/luasrc/lib/gluon/upgrade/500-autoupdater

+ 10 - 5
package/gluon-autoupdater/luasrc/lib/gluon/upgrade/500-autoupdater

@@ -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))