Update HealthCheck for auto-recover TUN down (#1373)

* Update tunnelDown.sh

Add attempt to restart TUN
This commit is contained in:
RickyXwang 2020-09-28 19:51:34 -04:00 committed by GitHub
parent f45599f29f
commit 2287ee9cc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,6 +16,29 @@ STATUS=$?
if [[ ${STATUS} -ne 0 ]] if [[ ${STATUS} -ne 0 ]]
then then
echo "Network is down" echo "Network is down"
INTERFACE=$(ls /sys/class/net | grep tun)
ISINTERFACE=$?
if [[ ${ISINTERFACE} -ne 0 ]]
then
echo "TUN Interface not found"
exit 1
fi
echo "Resetting TUN"
ip link set ${INTERFACE} down
sleep 1
ip link set ${INTERFACE} up
echo "Sent kill SIGUSR1 to openvpn"
pkill -SIGUSR1 openvpn
sleep 20
fi
ping -c 1 $HOST
STATUS=$?
if [[ ${STATUS} -ne 0 ]]
then
echo "Network is still down"
exit 1 exit 1
fi fi