Tunneldigger Watchdog: Switch from debugfs to batctl o to check for mesh-vpn connectivity. Minor refractoring.

This commit is contained in:
Matthias P. Walther 2019-06-02 15:34:38 +02:00
parent d40fd3e535
commit 31e86c9665
No known key found for this signature in database
GPG Key ID: 16BA5AB30324A4AE

View File

@ -16,20 +16,21 @@ function readPidFile()
end
function getNeighbourCount()
local list = io.lines("/sys/kernel/debug/batman_adv/bat0/originators")
if list~=nil then
for line in list do
local handleBatctl = io.popen("batctl o", 'r')
if handleBatctl~=nil then
for line in handleBatctl:lines() do
if line:find('mesh%-vpn') then
handleBatctl.close()
return 1
end
end
end
handleBatctl.close()
return nil
end
local uci = require('simple-uci').cursor()
local tunneldiggerEnabled = uci:get_bool('tunneldigger', 'mesh_vpn', 'enabled')
if tunneldiggerEnabled then
if uci:get_bool('tunneldigger', 'mesh_vpn', 'enabled') then
if io.popen("pgrep tunneldigger"):read("*l") ~= readPidFile() then
io.popen('logger -t tunneldigger-watchdog "Process-Pid does not match with pid-File."')
restartTunneldigger()