A script to make sure that my IPv6 Tunnel is always on

I’m using an IPv6 tunnel using http://go6.net/, and when the internet connection goes down and up after a while, the tunnel just doesn’t refresh it self.
I run it on crontab for every 5 minutes for now 🙂
My Machine is Gentoo 2008, I guess you need to do some changes for it to work on your distro.
Hope that any one will benefit from it

#!/bin/bash
function restartGW {
	/etc/init.d/gw6c restart
	date >> /var/log/checkipv
}
stat="`/etc/init.d/gw6c status | tr -d ' ' | cut -d':' -f2`"
if [ $stat == 'stopped' ]
then
	restartGW
elif [ $stat == 'started' ]
then
	IPV4connected="`echo $(nc -zv www.google.com 80 2>&1) | cut -d')' -f2 | tr -d ' '`"
	if [ $IPV4connected == "open" ]
	then
		# check ipv6 connectivity
		IPV6connected="`echo $(nc -6zv ipv6.google.com 80 2>&1) | cut -d')' -f2 | tr -d ' '`"
		if [ $IPV6connected == "open" ]
		then
			exit 0;
		else
			restartGW
		fi
	fi
fi
exit 0

Update:
This script is available at github on http://github.com/alaaibrahim/ala-scripts/.