Tunneldigger Watchdoch: refractoring and renaming of variable names with respect to coding convetions.
This commit is contained in:
parent
835a76e281
commit
3258c36f1c
@ -6,37 +6,37 @@ function restart_tunneldigger()
|
||||
end
|
||||
|
||||
function read_pid_file()
|
||||
local pidFile = io.open("/var/run/tunneldigger.mesh-vpn.pid", "r")
|
||||
if not pidFile then
|
||||
local pid_file = io.open("/var/run/tunneldigger.mesh-vpn.pid", "r")
|
||||
if not pid_file then
|
||||
return nil
|
||||
end
|
||||
returnPid = pidFile:read("*l")
|
||||
io.close(pidFile)
|
||||
return returnPid
|
||||
pid = pid_file:read("*l")
|
||||
pid_file:close()
|
||||
return pid
|
||||
end
|
||||
|
||||
function check_for_mesh_vpn_neighbours()
|
||||
local handleBatctl = io.popen("batctl o", 'r')
|
||||
if handleBatctl~=nil then
|
||||
for line in handleBatctl:lines() do
|
||||
local handle_batctl = io.popen("batctl o", 'r')
|
||||
if handle_batctl~=nil then
|
||||
for line in handle_batctl:lines() do
|
||||
if line:find('mesh%-vpn') then
|
||||
handleBatctl.close()
|
||||
handle_batctl:close()
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
handleBatctl.close()
|
||||
handle_batctl:close()
|
||||
return false
|
||||
end
|
||||
|
||||
local uci = require('simple-uci').cursor()
|
||||
if uci:get_bool('tunneldigger', 'mesh_vpn', 'enabled') then
|
||||
if io.popen("pgrep tunneldigger"):read("*l") ~= readPidFile() 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."')
|
||||
restart_tunneldigger()
|
||||
return
|
||||
end
|
||||
if check_for_mesh_vpn_neighbours() ~= true then
|
||||
if not check_for_mesh_vpn_neighbours() then
|
||||
io.popen('logger -t tunneldigger-watchdog "No vpn-mesh neighbours found."')
|
||||
restart_tunneldigger()
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user