Viitor_openvpn/usr/sbin/tunneltest
kueller 7548d668c0 V961 Tree Umbau
git-svn-id: svn://svn.compuextreme.de/Viitor/V961/Viitor_openvpn@4297 504e572c-2e33-0410-9681-be2bf7408885
2008-05-03 16:59:04 +00:00

35 lines
854 B
Bash
Executable File

#!/bin/bash
if [ $1 ]; then
DEVICE=$1
else
DEVICE=tun0
fi
TUN_IP=`grep ifconfig /etc/sysconfig/net/openvpn/$DEVICE.config | awk '{ print $3; };' `
if [ -f /var/run/tunneltest.pid ]; then
ps -ef | grep `cat /var/run/tunneltest.pid` || rm /var/run/tunneltest.pid
fi
if [ ! -f /var/run/tunneltest.pid ]; then
ping -c 1 -i 1 -w 1 $TUN_IP >/dev/null 2>/dev/null
if [ $? != 0 ]; then
PID=`ps -ef | grep tun1 | grep -v grep | awk '{ print $2; }'`
if [ $PID ]; then
kill -1 $PID
fi
sleep 5s
ping -c 1 -i 1 -w 1 $TUN_IP >/dev/null 2>/dev/null
if [ $? != 0 ]; then
PID=`ps -ef | grep tun1 | grep -v grep | awk '{ print $2; }'`
if [ $PID ]; then
kill -9 $PID
fi
sleep 5s
/usr/sbin/openvpn --config /etc/sysconfig/net/openvpn/$DEVICE.config >/dev/null 2>/dev/null &
fi
fi
fi