Init script for DSEE 6.3 on RHEL 5.3

Here’s a simple init script I came up with to start/stop my DSEE 6.3 on RHEL 5.3 services:

#!/bin/bash
# Sun DSEE init script
# /etc/rc.d/init.d/dsee
#
# chkconfig: 345 98 29
# description: Starts/Stops Sun DSEE
#
DH=/opt/sun/dirsrv6
JAVA_HOME=/usr/java/default
CATALINA_HOME=$DH/tomcat5
CATALINA_BASE=$CATALINA_HOME
PATH=$JAVA_HOME/bin:$PATH
INST=ds-m1
DSUSR=sunds
	
case "$1" in
'start')
        echo -n "Sun DSEE $INST starting..."
        $DH/ds6/bin/dsadm start $DH/var/$INST
	echo -n "Sun DSEE Admin services starting..."
	su - $DSUSR <<EOS
	$DH/dsee6/cacao_2/cacao/bin/cacaoadm start
	$DH/ds6/bin/dsadm start $DH/var/dscc6/dcc/ads
	$DSHOME/tomcat5/bin/startup.sh
EOS
        ;;
'stop')
        echo -n "Sun DSEE $INST stopping..."
        $DH/ds6/bin/dsadm stop $DH/var/$INST
	echo -n "Sun DSEE Admin services stopping ..."
	su - $DSUSR <<EOS
	$DH/tomcat5/bin/shutdown.sh
	$DH/ds6/bin/dsadm stop $DSHOME/var/dscc6/dcc/ads
	$DH/dsee6/cacao_2/cacao/bin/cacaoadm stop
EOS
        ;;
*)
        echo "Usage: $0 { start | stop }"
        exit 1
        ;;
esac

Note that I’ve su’d to my non-privileged user for starting and stopping the admin services pieces, but use root for the directory server instance(s). Going about things this way gets around the limitation of non-privileged users launching apps that listen on ports below 1000, while still retaining a least privilege security model. If your directory server instance was created correctly it should run as the designated non-privileged user once started.