#!/bin/sh
#
# hypervkvpd	provides info to the host
#
# chkconfig: - 90 10
# description:	Start hypervkvpd to allow the host to query this guest
# processname: hypervkvpd
# pidfile: /var/run/hypervkvpd.pid
#
### BEGIN INIT INFO
# Provides:          hypervkvpd
# Required-Start:    $null
# Should-Start:      $syslog $remote_fs $time
# Required-Stop:     $null
# Should-Stop:       $syslog $remote_fs $time
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: hypervkvpd provides info to the host
# Description:       Start hypervkvpd to allow the host to query this guest
### END INIT INFO

# Do not load RH compatibility interface.
WITHOUT_RC_COMPAT=1

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

LOCKFILE=/var/lock/subsys/hypervkvpd
RETVAL=0

start()
{
	start_daemon --lockfile "$LOCKFILE" --expect-user root -- hypervkvpd
	RETVAL=$?
	return $RETVAL
}

stop()
{
	stop_daemon --lockfile "$LOCKFILE" --expect-user root -- hypervkvpd
	RETVAL=$?
	return $RETVAL
}

restart()
{
	stop
	start
}

reload()
{
	msg_reloading hypervkvpd
	stop_daemon --expect-user root -HUP -- hypervkvpd
	RETVAL=$?
	return $RETVAL
}

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

exit $RETVAL
