#!/bin/sh
########################################################################
# Begin $rc_base/init.d/keepalived
#
# Description : keepalive daemon initscript
#
########################################################################

. /etc/sysconfig/rc
. ${rc_functions}

[ -r "/etc/sysconfig/keepalive" ] && . /etc/sysconfig/keepalive

case "${1}" in
	start)
		# Load IPVS module
		modprobe ip_vs

		# Enable connection tracking for IPVS
		sysctl -w net.ipv4.vs.conntrack=1 &>/dev/null

		boot_mesg "Starting keepalive daemon..."
		loadproc /usr/sbin/keepalived ${KEEPALIVED_OPTIONS}
		;;

	stop)
		boot_mesg "Stopping keepalive daemon..."
		killproc /usr/sbin/keepalived
		;;

	reload)
		boot_mesg "Reloading keepalive daemon..."
		reloadproc /usr/sbin/keepalived
		;;

	restart)
		${0} stop
		sleep 1
		${0} start
		;;

	status)
		statusproc /usr/sbin/keepalived
		;;

	*)
		echo "Usage: ${0} {start|stop|reload|restart|status}"
		exit 1
		;;
esac

# End $rc_base/init.d/keepalived
