#!/bin/sh
#
# xenwebmanager:        Start/stop xenwebmanager service
#
# chkconfig:    2345 25 90
# description: XenWebManager is a web-based open source clone of Xencenter.
#


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

start()
{
        echo -n $"Starting XenWebManager service:"
        daemon --user=xenwm  /usr/bin/xenwebmanager -daemon
        PID=$(/bin/ps -ef|/bin/grep frontend.py|/bin/grep -v grep|/bin/awk '{print $2}')
        echo $PID > /var/run/xenwebmanager.pid
        echo ""
}

stop()
{
        echo -n "Stopping XenWebManager service:"
        killproc -p /var/run/xenwebmanager.pid xenwebmanager 
        echo ""
}

xwmstatus()
{
        status -p /var/run/xenwebmanager.pid xenwebmanager
        echo ""
}

case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart|reload)
        stop
        start
        ;;
  condrestart)
        [ -e /var/lock/subsys/xenwebmanager ] && (stop; start)
        ;;
  status)
        xwmstatus 
        ;;
  *)
        echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
        exit 1
        ;;
esac

exit 0
