#!/bin/sh

. /etc/sysconfig/rc.conf
. /bin/network-functions

SETSID=/usr/bin/setsid
PIDFILE=/var/run/keepalived.pid
SERVICE=keepalived
PROCESS_NAME=keepalived
CONF_FILE=/etc/keepalived.conf

do_start ()
{
	if ! ServiceCheckRunning1 ; then
		return $?
	fi

	/etc/init.d/softdogd wait
	$SETSID /bin/$PROCESS_NAME -D -f $CONF_FILE

	ServiceCheckRunning2

	return
}

do_stop ()
{
	ServiceStop

	return $?
}

do_status ()
{
	ServiceStatus

	return $?
}

case "$1" in
	start)
		do_start
		;;
	stop)
		do_stop
		;;
	status)
		do_status
		;;
	*)
		echo "Usage: $0 {start|status}"
		exit 1
esac

exit $?
