36 lines
616 B
Plaintext
36 lines
616 B
Plaintext
|
#!/bin/bash
|
||
|
#
|
||
|
# Check if ExitVPN is working
|
||
|
# 1 - OK
|
||
|
# 0 - Failed
|
||
|
#
|
||
|
|
||
|
VPNCONF=$(grep -e "^AUTOSTART=" /etc/default/openvpn)
|
||
|
INTERFACE=$(sed -e 's/^"//' -e 's/"$//' <<< ${VPNCONF#*=})
|
||
|
NATIF=$(iptables -t nat -vnL | grep MASQUERADE | awk '{$1=$1};1' | cut -d' ' -f 7)
|
||
|
TESTIP=81.7.16.37 # gate01
|
||
|
|
||
|
if [ ! `pgrep openvpn` ]; then
|
||
|
echo 0
|
||
|
exit 0
|
||
|
fi
|
||
|
|
||
|
if [ ! -d "/sys/class/net/$INTERFACE" ]; then
|
||
|
echo 0
|
||
|
exit 0
|
||
|
fi
|
||
|
|
||
|
if ! test "$NATIF" == "$INTERFACE" ; then
|
||
|
echo 0
|
||
|
exit 0
|
||
|
fi
|
||
|
|
||
|
ping -q -I $INTERFACE $TESTIP -c 3 -i 1 -W 5 >/dev/null 2>&1
|
||
|
if ! test $? -eq 0; then
|
||
|
echo 0
|
||
|
exit 0
|
||
|
fi
|
||
|
|
||
|
echo 1
|
||
|
exit 0
|