![kueller](/assets/img/avatar_default.png)
git-svn-id: svn://svn.compuextreme.de/Viitor/V962/Viitor_openvpn@4413 504e572c-2e33-0410-9681-be2bf7408885
35 lines
854 B
Bash
Executable File
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
|