gluon/package/gluon-scheduled-domain-switch/luasrc/lib/gluon/upgrade/950-gluon-scheduled-domain-switch
David Bauer ed3d890b1f gluon-scheduled-domain-switch: add package (#1555)
This package allows to automatically switch to another domain, either
at a given point in time or after the node was offline long enough.
2019-02-26 00:39:54 +01:00

21 lines
555 B
Lua
Executable File

#!/usr/bin/lua
local json = require 'jsonc'
local site = require 'gluon.site'
local unistd = require 'posix.unistd'
local cronfile = "/usr/lib/micron.d/gluon-scheduled-domain-switch"
-- Check if domain switch is scheduled
if site.domain_switch() == nil then
-- In case no domain switch is scheduled, remove cronfile
os.remove(cronfile)
os.exit(0)
end
-- Only in case domain switch is scheduled
local f = io.open(cronfile, "w")
f:write("* * * * * /usr/bin/gluon-check-connection\n")
f:write("*/5 * * * * /usr/bin/gluon-switch-domain\n")
f:close()