#!/bin/sh
#
# vrrpd         This shell script takes care of starting and stopping
#               vrrpd.
#
# chkconfig: 345 65 35
# description: Virtual Router Redundancy Protocol Daemon

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

[ -x /usr/sbin/vrrpd -a  -f /etc/sysconfig/vrrpd ] || exit 0
. /etc/sysconfig/vrrpd
RETVAL=0

# See how we were called.
case "$1" in
  start)
        # Start daemon.
    	echo -n "Starting vrrpd: "
	daemon vrrpd-wrapper start
	RETVAL=$?
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/vrrpd
        echo
	;;
  stop)
        # Stop daemon.
        echo -n "Shutting down vrrpd: "
        killproc vrrpd
		#vrrpd-wrapper stop
        RETVAL=$?
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/vrrpd
        echo
	;;
  restart)
	$0 stop
    	$0 start
    	RETVAL=$?
	;;
  reload)
        $0 stop
        $0 start
        RETVAL=$?  
	;;
  status)
	status vrrpd
        RETVAL=$?
;;
  *)
	echo "Usage: $0 {start|stop|restart|status}"
	RETVAL=1
esac

exit $RETVAL
