From ImageStream Router Documentation
#!/bin/bash
HOST="localhost"
SLEEP="10s"
while [ 1 ] ; do
# Check to see if BGPd is running
/usr/share/init.d/zebrabgpd status | grep "bgpd is not running" >/dev/null 2>&1
BGP_RUNNING="$?"
# ping HOST for accessability
ping -c 3 ${HOST} > /dev/null 2>&1
HOST_DOWN="$?"
echo "HOST: ${HOST_DOWN}"
# If the ping failed
if [ ${HOST_DOWN} -ne 0 ] ; then
# If bgpd is running
if [ ${BGP_RUNNING} -ne 0 ] ; then
echo /usr/share/init.d/zebrabgpd stop
fi
else
# If bgpd is running
if [ ${BGP_RUNNING} -eq 0 ] ; then
echo /usr/share/init.d/zebrabgpd start
fi
fi
sleep ${SLEEP}
done