#!/bin/sh 
# domino Start/stop The Lotus Domino server 
# 
# Usage /etc/rc.d/init.d/domino start|stop 
# processname: domino
# chkconfig: 345 66 19
# description: Lotus Domino server
. /etc/init.d/functions

DOMINO_USER="notes" # User to run Domino server 
DOMINO_DATA_DIR="/local/notesdata" # location of notes.ini 
DOMINO_BIN_DIR="/opt/IBM/lotus/bin" # location of executables 

# Look if the user that runs this script is root 
if [ `id -u` != 0 ]; then 
	echo "This script must be run by root" 
	exit 1; 
fi 

case "$1" in 

start)
	echo -n "Starting Lotus Domino server: " 
	su - ${DOMINO_USER} -c "cd ${DOMINO_DATA_DIR} && 
	${DOMINO_BIN_DIR}/server" >/dev/null 2>&1 & 
        sleep 60
	RETVAL=$?
        if [ $RETVAL = 0 ]; then
                touch /var/lock/subsys/domino
                echo_success
        else
                echo_failure
        fi
        echo
;; 

stop) 
	echo -n "Stopping Lotus Domino server: " 
	su - ${DOMINO_USER} -c "cd ${DOMINO_DATA_DIR};${DOMINO_BIN_DIR}/server -q" 
        RETVAL=$?
        if [ $RETVAL = 0 ]; then
                rm -f /var/lock/subsys/domino
                echo_success
        else
                rm -f /var/lock/subsys/domino
		echo_failure
        fi
        echo
;; 

status)
        if [ ! -f /var/lock/subsys/domino ]; then
                echo "Domino is stopped"
        else
                echo "Domino is running"
        fi
;;

*) 
	echo "Usage: domino {start|stop|status}" 
	exit 1 
esac

