gluon-check-connection: create folder before writing offline-flag file
This commit is contained in:
		
							parent
							
								
									ccb5a97de0
								
							
						
					
					
						commit
						df53c7e7bf
					
				| @ -4,7 +4,8 @@ local unistd = require 'posix.unistd' | |||||||
| local util = require 'gluon.util' | local util = require 'gluon.util' | ||||||
| local site = require 'gluon.site' | 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 | local is_offline = true | ||||||
| 
 | 
 | ||||||
| -- Check reachability of pre-defined targets | -- Check reachability of pre-defined targets | ||||||
| @ -21,6 +22,10 @@ if is_offline then | |||||||
| 	if unistd.access(offline_flag_file) then | 	if unistd.access(offline_flag_file) then | ||||||
| 		os.exit(0) | 		os.exit(0) | ||||||
| 	end | 	end | ||||||
|  | 	-- check if path exists | ||||||
|  | 	if !access(offline_flag_file_path, F_OK) then | ||||||
|  | 		stat.mkdir(offline_flag_file_path) | ||||||
|  | 	end | ||||||
| 	-- Create offline flag | 	-- Create offline flag | ||||||
| 	local f = io.open(offline_flag_file, "w") | 	local f = io.open(offline_flag_file, "w") | ||||||
| 	f:write(tostring(util.get_uptime())) | 	f:write(tostring(util.get_uptime())) | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user