Merge pull request #52 from freifunk-gluon/autoupdater-fixes
Autoupdater fixes
This commit is contained in:
commit
5baf5cdd49
|
@ -25,16 +25,16 @@ local old_version = util.trim(fs.readfile(settings.version_file) or '')
|
|||
-- the priority and even when it is disabled in uci
|
||||
local force = false
|
||||
|
||||
-- If oneshot is true the updater will perform an update only if the whole
|
||||
-- timespan given by the priority has passed
|
||||
local oneshot = false
|
||||
-- If fallback is true the updater will perform an update only if the
|
||||
-- timespan given by the priority and another 24h have passed
|
||||
local fallback = false
|
||||
|
||||
|
||||
for _, a in ipairs(arg) do
|
||||
if a == '-f' then
|
||||
force = true
|
||||
elseif a == '-o' then
|
||||
oneshot = true
|
||||
elseif a == '--fallback' then
|
||||
fallback = true
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -182,12 +182,19 @@ local function get_probability(date, priority)
|
|||
else
|
||||
-- Will give 1 when priority == 0, and lower probabilities the higher the priority value is
|
||||
-- (similar to the old static probability system)
|
||||
return 0.9^priority
|
||||
return 0.75^priority
|
||||
end
|
||||
|
||||
elseif fallback then
|
||||
if diff >= seconds + 86400 then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
end
|
||||
|
||||
elseif diff >= seconds then
|
||||
return 1
|
||||
elseif oneshot then
|
||||
return 0
|
||||
|
||||
else
|
||||
local x = diff/seconds
|
||||
-- This is the most simple polynomial with value 0 at 0, 1 at 1, and whose first derivative is 0 at both 0 and 1
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=99
|
||||
|
||||
SERVICE_NAME=gluon-autoupdater
|
||||
SERVICE_WRITE_PID=1
|
||||
SERVICE_DAEMONIZE=1
|
||||
|
||||
|
||||
start() {
|
||||
[ "$(uci get autoupdater.settings.enabled)" = 1 ] || return
|
||||
|
||||
service_start /bin/sh /lib/gluon/autoupdater/delayed_update
|
||||
}
|
||||
|
||||
stop() {
|
||||
service_stop /bin/sh
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
lock /var/gluon/autoupdater.lock
|
||||
autoupdater "$@"
|
||||
lock -u /var/gluon/autoupdater.lock
|
|
@ -1,5 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# wait for 5 minutes after boot
|
||||
sleep 300
|
||||
exec /lib/gluon/autoupdater/autoupdate -o
|
|
@ -47,7 +47,11 @@ local autoupdater_util = require 'autoupdater.util'
|
|||
autoupdater_util.randomseed()
|
||||
|
||||
|
||||
-- Perform updates at a random time between 04:00 and 05:00
|
||||
-- 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
|
||||
local minute = math.random(0, 59)
|
||||
|
||||
local f = io.open('/lib/gluon/cron/autoupdater', 'w')
|
||||
f:write(string.format('%i 4 * * * /lib/gluon/autoupdater/autoupdate\n', math.random(0, 59)))
|
||||
f:write(string.format('%i 4 * * * /usr/sbin/autoupdater\n', minute))
|
||||
f:write(string.format('%i 0-3,5-23 * * * /usr/sbin/autoupdater --fallback\n', minute))
|
||||
f:close()
|
||||
|
|
Loading…
Reference in New Issue