#!/bin/bash
#
# XUUDB
#
# chkconfig: 235 96 04
# description: UNICORE XUUDB 

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

UNICORE_USER=unicore
NAME="UNICORE XUUDB"
START="/usr/sbin/unicore-xuudb-start"
STOP="/usr/sbin/unicore-xuudb-stop"
PID="/var/run/unicore/xuudb.pid"

#This must be equal to this file name
SERVICE=unicore-xuudb

[ -f /etc/sysconfig/$SERVICE ] && . /etc/sysconfig/$SERVICE

start() {
	echo -n "Starting $NAME: "
	daemon --user $UNICORE_USER "$START"
	RETVAL=$?
	[ $RETVAL -eq 0 ] && touch "/var/lock/subsys/$SERVICE"
	echo
	return $RETVAL
}
stop() {
	echo -n $"Stopping $NAME: "
	/sbin/runuser -s /bin/sh -c "$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 "$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
