gluon-check-connection: create folder before writing offline-flag file

This commit is contained in:
Ruben Barkow 2020-02-03 22:09:57 +01:00
parent ccb5a97de0
commit df53c7e7bf
No known key found for this signature in database
GPG Key ID: 8BCC811299DBC5DF

View File

@ -4,7 +4,8 @@ local unistd = require 'posix.unistd'
local util = require 'gluon.util'
local site = require 'gluon.site'
local offline_flag_file = "/var/gluon/check-connection/offline"
local offline_flag_file_path = "/var/gluon/check-connection"
local offline_flag_file = offline_flag_file_path + "/offline"
local is_offline = true
-- Check reachability of pre-defined targets
@ -21,6 +22,10 @@ if is_offline then
if unistd.access(offline_flag_file) then
os.exit(0)
end
-- check if path exists
if !access(offline_flag_file_path, F_OK) then
stat.mkdir(offline_flag_file_path)
end
-- Create offline flag
local f = io.open(offline_flag_file, "w")
f:write(tostring(util.get_uptime()))