123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- #!/usr/bin/lua
- local site = require 'gluon.site_config'
- local uci = require('simple-uci').cursor()
- for name, config in pairs(site.autoupdater.branches) do
- uci:delete('autoupdater', name)
- uci:section('autoupdater', 'branch', name, {
- name = config.name,
- mirror = config.mirrors,
- good_signatures = config.good_signatures,
- pubkey = config.pubkeys,
- })
- end
- if not uci:get('autoupdater', 'settings') then
- local enabled = false
- local branch = site.autoupdater.branch
- local f = io.open('/lib/gluon/autoupdater/default_branch')
- if f then
- enabled = true
- branch = f:read('*line')
- f:close()
- end
- uci:section('autoupdater', 'autoupdater', 'settings', {
- enabled = enabled,
- branch = branch,
- })
- end
- uci:set('autoupdater', 'settings', 'version_file', '/lib/gluon/release')
- uci:save('autoupdater')
- local autoupdater_util = require 'autoupdater.util'
- autoupdater_util.randomseed()
- -- 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))
- f:write(string.format('%i 0-3,5-23 * * * /usr/sbin/autoupdater --fallback\n', minute))
- f:close()
|