Skip to content
Snippets Groups Projects
Select Git revision
  • 3d4fb37351a574d8e4e47e3ce347a94f9688be5e
  • v2018.2.x default
  • experimental
  • master
  • v2021.1.2-ffs
  • v2021.1.1-ffs
  • nrb/gluon-master-cpe510
  • v2021.1-ffs
  • v2020.2.3-ffs
  • nrbffs/fastd-remove-delay
  • v2020.2.2-ffs
  • v2020.2.1-ffs
  • v2020.2-ffs
  • v2020.2.x
  • v2020.1.3-ffs
  • v2020.1.1-ffs
  • v2020.1-ffs
  • v2019.1.2-ffs
  • v2019.1.1-ffs
  • nrb/test-radv-filter
  • v2019.1-ffs
  • nrbffs/netgear-ex6120
  • v2021.1.2-ffs0.2
  • v2021.1.2-ffs0.1
  • v2021.1.1-ffs0.4
  • v2021.1.1-ffs0.3
  • v2021.1.1-ffs0.2
  • v2021.1.1-ffs0.1
  • v2021.1-ffs0.1
  • v2020.2.3-ffs0.3
  • v2020.2.3-ffs0.2
  • v2020.2.3-ffs0.1
  • v2020.2.2-ffs0.1
  • v2020.2.1-ffs0.1
  • v2020.2-ffs0.1
  • v2020.2
  • v2020.2.x-ffs0.1
  • v2020.1.3-ffs0.1
  • v2020.1.1-ffs0.1
  • v2020.1-ffs0.1
  • v2019.1.2-ffs0.1
  • v2019.1.1-ffs0.1
42 results

tunneldigger-watchdog

  • Forked from firmware / FFS Gluon
    Source project has a limited visibility.
    tunneldigger-watchdog 1.10 KiB
    #!/usr/bin/lua
    
    local uci = require('simple-uci').cursor()
    
    local function restart_tunneldigger()
    	os.execute('logger -t tunneldigger-watchdog "Restarting Tunneldigger."')
    	os.execute('/etc/init.d/tunneldigger restart')
    end
    
    local function read_pid_file()
    	local pid_file = io.open('/var/run/tunneldigger.mesh-vpn.pid', 'r')
    	if not pid_file then
    		return nil
    	end
    	local pid = pid_file:read('*l')
    	pid_file:close()
    	return pid
    end
    
    local function has_mesh_vpn_neighbours()
    	local handle = io.popen('batctl o', 'r')
    	if not handle then
    		return false
    	end
    	for line in handle:lines() do
    		if line:find('mesh%-vpn') then
    			handle:close()
    			return true
    		end
    	end
    	handle:close()
    	return false
    end
    
    if uci:get_bool('tunneldigger', 'mesh_vpn', 'enabled') then
    	if io.popen('pgrep tunneldigger'):read('*l') ~= read_pid_file() then
    		os.execute('logger -t tunneldigger-watchdog "Process-Pid does not match with pid-File."')
    		restart_tunneldigger()
    		return
    	end
    	if not has_mesh_vpn_neighbours() then
    		os.execute('logger -t tunneldigger-watchdog "No vpn-mesh neighbours found."')
    		restart_tunneldigger()
    		return
    	end
    end