My university has a special wireless network that requires you to use a VPN to get into the internet. So I have little script that connects me to the VPN once I get into the wireless:
/etc/NetworkManager/dispatcher.d/99bonnet
:
if [[ "$1" != "wlan0" ]]
then
return
fi
# Kill vpnc if it is still active
if pgrep vpnc
then
vpnc-disconnect
fi
# Exit if we are not connected to bonnet
if ! iwconfig wlan0 | grep bonnet
then
return 0
fi
# Handle the action
if [[ "$2" == up ]]
then
vpnc "$vpn_config_file"
else
vpnc-disconnect
fi
This works like a charm and connects and disconnects the VPN with the wifi. The problem is that vpnc has a tendency to die on me. Is there some way to respawn the vpnc if it dies? There is a nice wiki about process management, but it seems that I cannot really use inittab for my purpose here, or at least not straight forward.
What would be a non hack way to respawn vpnc if it dies while I am connected to the certain wireless?