Posted June 27, 20222 yr test_address="8.8.8.8" tunnel_interfaceWAN="eth0" tunnel_interfaceVPN="tun1" init_ping_tries=2 ping_tries=init_ping_tries WANup=0 while [[ $ping_tries -lt 5] && [ $WANup -eq 0 ]] do if ping -c 1 -W 1 $test_address -I $tunnel_interfaceWAN >/dev/null then WANup=1 fi ping_tries=$((ping_tries+1)) done if $WANup -eq 0 then echo "VPN is down because Internet is down [exit 0]" exit 0 fi Im pretty new to bash programming, this script should be simple, but I cant seem to figure out why it is not working correctly. Is there something wrong with the syntax of my while loop or last if statement? Edited June 27, 20222 yr by JackNY
Create an account or sign in to comment