From e32ed70896e08839f856c22d8108cd6beb4fec44 Mon Sep 17 00:00:00 2001 From: kb-light Date: Wed, 22 Nov 2017 21:31:59 +0100 Subject: [PATCH] gluon-autoupdater: introduce uci value gluon.autoupdater.minute --- .../luasrc/lib/gluon/upgrade/500-autoupdater | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/package/gluon-autoupdater/luasrc/lib/gluon/upgrade/500-autoupdater b/package/gluon-autoupdater/luasrc/lib/gluon/upgrade/500-autoupdater index 88214a86..f12fcdff 100755 --- a/package/gluon-autoupdater/luasrc/lib/gluon/upgrade/500-autoupdater +++ b/package/gluon-autoupdater/luasrc/lib/gluon/upgrade/500-autoupdater @@ -41,11 +41,16 @@ local seed1, seed2 = urandom:read(2):byte(1, 2) math.randomseed(seed1*0x100 + seed2) urandom:close() --- 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))