You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
809 B
Bash
38 lines
809 B
Bash
#!/bin/bash
|
|
|
|
INTERFACE=mullvad
|
|
FAILED_FILE=/tmp/mullvad.failed
|
|
fail=false
|
|
|
|
if [ ! -e /sys/class/net/$INTERFACE ]; then
|
|
echo "$INTERFACE interface does not exist"
|
|
fail=true
|
|
else
|
|
start_bytes=$(cat /sys/class/net/$INTERFACE/statistics/rx_bytes)
|
|
sleep 30
|
|
end_bytes=$(cat /sys/class/net/$INTERFACE/statistics/rx_bytes)
|
|
|
|
if [ $(($end_bytes-$start_bytes)) -lt 1000 ]; then
|
|
#echo "no traffic via $INTERFACE"
|
|
fail=true
|
|
fi
|
|
fi
|
|
|
|
if $fail; then
|
|
systemctl is-active openvpn-client@mullvad.service > /dev/null
|
|
if [ $? -ne 0 ]; then
|
|
systemctl status openvpn-client@mullvad.service
|
|
if [ -e $FAILED_FILE ]; then
|
|
echo restart openvpn-client@mullvad.service
|
|
systemctl restart openvpn-client@mullvad.service
|
|
else
|
|
touch $FAILED_FILE
|
|
fi
|
|
fi
|
|
else
|
|
if [ -e $FAILED_FILE ]; then
|
|
rm $FAILED_FILE
|
|
fi
|
|
fi
|
|
|