#!/bin/sh # chkconfig: 345 86 14 # description: Starts and stops the DSpace handle server # Source function library if [ -f /etc/init.d/functions ] ; then . /etc/init.d/functions elif [ -f /etc/rc.d/init.d/functions ] ; then . /etc/rc.d/init.d/functions else exit 0 fi prog="handle" exec="/usr/local/dspace/bin/start-handle-server" start () { echo -n "Starting ${prog} server: " ${exec} 2>&1 > /dev/null && success || failure RETVAL=$? echo return $RETVAL } stop () { echo -n "Stopping ${prog} server: " PID=`/bin/ps -ef | grep java | grep -E handle-....jar | grep -v 'grep' | awk '{print $2}'` if [ ! -z "$PID" ] ; then for process in ${PID} do /bin/kill $process && success || failure done RETVAL=$? echo return $RETVAL fi } restart () { stop start } status () { PID=`/bin/ps -ef | grep java | grep -E handle-....jar | grep -v 'grep' | awk '{print $2}'` if [ ! -z "$PID" ] ; then echo "Handle server is running ($PID)." else echo "Handle server is stopped." fi } case "$1" in start) start ;; stop) stop ;; restart) restart ;; status) status ;; *) echo "Usage: $0 {start|stop|restart|status}" exit 1 esac exit $?