#!/bin/sh
# description: Esri ArcSDE auto start-stop script.
# chkconfig: 345 96 04
#
if [ -f /etc/sysconfig/arcsde_pw ]; then
        . /etc/sysconfig/arcsde_pw
fi

if [ -f /etc/sysconfig/arcsde ]; then
        . /etc/sysconfig/arcsde
fi

if [ ! -f $SDEHOME/bin/sdemon ]
then
    echo "ArcSDE startup: cannot start"
    exit
fi
case "$1" in
    start)
        # Start the ArcSDE service:
        # The following command assumes that the sde login
        # will not prompt the user for any values
        su - $SDEOWNER -c "$SDEHOME/bin/sdemon -o start -H ${SDEHOME} -p ${SDEPASSWORD}"
        ;;
    stop)
        # Stop the ArcSDE service:
        # The following command assumes that the sde login
        # will not prompt the user for any values
        su - $SDEOWNER -c "$SDEHOME/bin/sdemon -o shutdown -H ${SDEHOME} -p ${SDEPASSWORD}"
        ;;
    restart)
        $0 stop
        sleep 3s
        $0 start
        ;;
esac

