#!/bin/sh
#
# easyvzd	Summary of the service.
#
# chkconfig: - 98 87
# description:	EasyVZ-server is a server for menage OpenVZ
# processname: easyvzd
# pidfile: /var/run/easyvzd.pid

# Do not load RH compatibility interface.
WITHOUT_RC_COMPAT=1

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

PIDFILE=/var/run/easyvzd.pid
RETVAL=0
easyvzd=/usr/sbin/easyvzd

start()
{
	start_daemon --pidfile "$PIDFILE" --expect-user root --displayname easyvz -- "$easyvzd"
	RETVAL=$?
	return $RETVAL
}

stop()
{
	msg_stopping "easyvz"
	"$easyvzd" --stop
	RETVAL=$?
	if [ $RETVAL = 0 ]; then
	    success
	else
	    failure
	fi
	echo
	return $RETVAL
}

restart()
{
	stop
	start
}


# See how we were called.
case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	reload)
		restart
		;;
	restart)
		restart
		;;
	condstop)
		if [ -e "$PIDFILE" ]; then
			stop
		fi
		;;
	condrestart)
		if [ -e "$PIDFILE" ]; then
			restart
		fi
		;;
	condreload)
		if [ -e "$PIDFILE" ]; then
			restart
		fi
		;;
	status)
		status --pidfile "$PIDFILE" --expect-user root --displayname easyvz -- python
		RETVAL=$?
		;;
	*)
		msg_usage "${0##*/} {start|stop|reload|restart|condstop|condrestart|condreload|status}"
		RETVAL=1
esac

exit $RETVAL
