Tunneldigger Watchdoch: refractoring and renaming of function

This commit is contained in:
Matthias P. Walther 2019-06-02 15:50:25 +02:00
parent abe319eb12
commit 82b00d8319
No known key found for this signature in database
GPG Key ID: 16BA5AB30324A4AE

View File

@ -15,18 +15,18 @@ function readPidFile()
return returnPid return returnPid
end end
function getNeighbourCount() function checkForMeshVpnNeighbours()
local handleBatctl = io.popen("batctl o", 'r') local handleBatctl = io.popen("batctl o", 'r')
if handleBatctl~=nil then if handleBatctl~=nil then
for line in handleBatctl:lines() do for line in handleBatctl:lines() do
if line:find('mesh%-vpn') then if line:find('mesh%-vpn') then
handleBatctl.close() handleBatctl.close()
return 1 return true
end end
end end
end end
handleBatctl.close() handleBatctl.close()
return nil return false
end end
local uci = require('simple-uci').cursor() local uci = require('simple-uci').cursor()
@ -36,7 +36,7 @@ if uci:get_bool('tunneldigger', 'mesh_vpn', 'enabled') then
restartTunneldigger() restartTunneldigger()
return return
end end
if getNeighbourCount() ~= 1 then if checkForMeshVpnNeighbours() ~= true then
io.popen('logger -t tunneldigger-watchdog "No vpn-mesh neighbours found."') io.popen('logger -t tunneldigger-watchdog "No vpn-mesh neighbours found."')
restartTunneldigger() restartTunneldigger()
return return