Tunneldigger-Watchdog:
- Fix quotation style - refractoring / code optimization
This commit is contained in:
parent
796d09895a
commit
f206b7c79f
@ -2,22 +2,22 @@
|
|||||||
|
|
||||||
function restart_tunneldigger()
|
function restart_tunneldigger()
|
||||||
io.popen('logger -t tunneldigger-watchdog "Restarting Tunneldigger."')
|
io.popen('logger -t tunneldigger-watchdog "Restarting Tunneldigger."')
|
||||||
os.execute("/etc/init.d/tunneldigger restart")
|
os.execute('/etc/init.d/tunneldigger restart')
|
||||||
end
|
end
|
||||||
|
|
||||||
function read_pid_file()
|
function read_pid_file()
|
||||||
local pid_file = io.open("/var/run/tunneldigger.mesh-vpn.pid", "r")
|
local pid_file = io.open('/var/run/tunneldigger.mesh-vpn.pid', 'r')
|
||||||
if not pid_file then
|
if not pid_file then
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
pid = pid_file:read("*l")
|
local pid = pid_file:read('*l')
|
||||||
pid_file:close()
|
pid_file:close()
|
||||||
return pid
|
return pid
|
||||||
end
|
end
|
||||||
|
|
||||||
function check_for_mesh_vpn_neighbours()
|
function has_mesh_vpn_neighbours()
|
||||||
local handle = io.popen("batctl o", 'r')
|
local handle = io.popen('batctl o', 'r')
|
||||||
if not handle then
|
if handle then
|
||||||
for line in handle:lines() do
|
for line in handle:lines() do
|
||||||
if line:find('mesh%-vpn') then
|
if line:find('mesh%-vpn') then
|
||||||
handle:close()
|
handle:close()
|
||||||
@ -31,12 +31,12 @@ end
|
|||||||
|
|
||||||
local uci = require('simple-uci').cursor()
|
local uci = require('simple-uci').cursor()
|
||||||
if uci:get_bool('tunneldigger', 'mesh_vpn', 'enabled') then
|
if uci:get_bool('tunneldigger', 'mesh_vpn', 'enabled') then
|
||||||
if io.popen("pgrep tunneldigger"):read("*l") ~= read_pid_file() then
|
if io.popen('pgrep tunneldigger'):read('*l') ~= read_pid_file() then
|
||||||
io.popen('logger -t tunneldigger-watchdog "Process-Pid does not match with pid-File."')
|
io.popen('logger -t tunneldigger-watchdog "Process-Pid does not match with pid-File."')
|
||||||
restart_tunneldigger()
|
restart_tunneldigger()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if not check_for_mesh_vpn_neighbours() then
|
if not has_mesh_vpn_neighbours() then
|
||||||
io.popen('logger -t tunneldigger-watchdog "No vpn-mesh neighbours found."')
|
io.popen('logger -t tunneldigger-watchdog "No vpn-mesh neighbours found."')
|
||||||
restart_tunneldigger()
|
restart_tunneldigger()
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user