im trying to figure out, b/c sometimes pings will work but thats b/c its just reg. ICMP but when real traffic tries to go through the tunnel it wont work b/c there are 2-3 tunnels up. I want to do an IF $tunnels > 1 AND $tunnels == 0 to do the below of restarting IPSec.
not that easy
#!/bin/bash
echo begin ping
ping -c 3 -w 3 -t 2 192.168.1.4 &> /dev/null ;
service ipsec status | awk 'NR==3' | cut -d" " -f1 $tunnels
if
[ $? == 0 ]
then
echo "Connection is up" >> /root/restart_ipsec.log
else
echo "Connection is down" >> /root/restart_ipsec.log
date >> /root/restart_ipsec.log;
/sbin/service crond stop >> /root/restart_ipsec.log;
/sbin/service ipsec stop >> /root/restart_ipsec.log;
sleep 120;
/sbin/service ipsec start >> /root/restart_ipsec.log;
/sbin/service crond start >> /root/restart_ipsec.log;
fi
i tried this BUT it keeps using the first if no matter what. even if i say the amount of tunnels is greater then 1 or 0 it still uses that statement. What gives!?
tunnels=$(service ipsec status | awk 'NR==3' | cut -d" " -f1 | sed -e 's/^[ ]*//')
a=0
if
(( $tunnels > $a));
then
echo "To many tunnels =" $tunnels >> /root/restart_ipsec2.log;
echo $a;
elif
[ $tunnels == 0 ]
then
echo "To many tunnelss =" $tunnels >> /root/restart_ipsec2.log
elif
echo "luis3";
[ $? == 0 ]
then
echo "Connection is up" >> /root/restart_ipsec2.log
else
echo "Connection is down" >> /root/restart_ipsec2.log
fi