#!/bin/bash
#
# UNICORE Virtual Organizations Server
#
# chkconfig: 235 97 03
# description:  UNICORE Virtual Organizations Server

UNICORE_USER="unicore"
UNICORE_UVOS=/usr/sbin

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

#. /etc/sysconfig/unicore

DIR="$UNICORE_UVOS"
NAME="UVOS"

#This must be equal to the file name
SERVICE=unicore-uvos-server

start() {
        echo -n "Starting $NAME: "
        daemon --user $UNICORE_USER "$DIR/unicore-uvos-server-start"
        RETVAL=$?
        [ $RETVAL -eq 0 ] && touch "/var/lock/subsys/$SERVICE"
        echo
        return $RETVAL
}
stop() {
	echo -n $"Stopping $NAME: "
	runuser -s /bin/sh -c "$DIR/unicore-uvos-server-stop" $UNICORE_USER 
    rm -f "/var/lock/subsys/$SERVICE"
	echo
}

# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  status)
        status -p "/var/run/unicore/uvos-server.pid" "$SERVICE"
	RETVAL=$?
	;;
  restart)
	stop
	start
	;;
  reload)
	echo "Reloading is not supported for this service. Use restart, if the modified configuration files are not automatically reloaded." 
	;;
  *)
	echo $"Usage: $0 {start|stop|status|restart|help}"
	exit 1
esac

exit $RETVAL
