From 3258c36f1c2f4341469ae1a4cba9c280f2a6a4c6 Mon Sep 17 00:00:00 2001 From: "Matthias P. Walther" Date: Sun, 2 Jun 2019 16:55:49 +0200 Subject: [PATCH] Tunneldigger Watchdoch: refractoring and renaming of variable names with respect to coding convetions. --- .../files/usr/bin/tunneldigger-watchdog | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/package/gluon-mesh-vpn-tunneldigger/files/usr/bin/tunneldigger-watchdog b/package/gluon-mesh-vpn-tunneldigger/files/usr/bin/tunneldigger-watchdog index a861dafe..1e3022e0 100755 --- a/package/gluon-mesh-vpn-tunneldigger/files/usr/bin/tunneldigger-watchdog +++ b/package/gluon-mesh-vpn-tunneldigger/files/usr/bin/tunneldigger-watchdog @@ -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