#!/bin/sh
# chkconfig: - 55 45

# the following is the LSB init header see
# http://www.linux-foundation.org/spec//booksets/LSB-Core-generic/LSB-Core-generic.html#INITSCRCOMCONV
#
### BEGIN INIT INFO
# Provides:          vhostmd
# Required-Start:    $remote_fs $network
# Should-Start:      xend
# Default-Start:     3 5
# Required-Stop:     $remote_fs $null
# Should-Stop:       $null
# Default-Stop:      0 1 2 4 6
# Short-Description: daemon for collecting virutalization host metrics
# Description:       This is a daemon for collecting virtualization host
#                    metrics and writing them to a file-backed disk.
### END INIT INFO


VHOSTMD_BIN=/usr/sbin/vhostmd
test -x $VHOSTMD_BIN || { echo "$VHOSTMD_BIN not installed";
         if [ "$1" = "stop" ]; then exit 0;
	 else exit 5; fi; }

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

RETVAL=0
case "$1" in
    start)
        echo -n $"Starting vhostmd:"
	daemon $VHOSTMD_BIN
	RETVAL=$?
	echo 
        ;;
    stop)
        echo -n "Shutting down vhostmd: "
        killproc $VHOSTMD_BIN
	RETVAL=$?
	echo 
        ;;
    try-restart)
        $0 status >/dev/null &&  $0 restart
        ;;
    restart)
        $0 stop
        $0 start
        ;;
    reload)
        echo -n "Sending HUP to vhostmd: "
	killproc $VHOSTMD_BIN -HUP
	RETVAL=$?
	echo 
        ;;
    status)
        echo -n "Checking status of vhostmd "
        status $VHOSTMD_BIN
	RETVAL=$?
	echo 
        ;;
    *)
        echo "Usage: $0 {start|stop|restart|try-restart|reload|status}"
	RETVAL=2
        ;;
esac

exit $RETVAL
