#!/bin/sh

# start ACD

. /etc/sysconfig/rc.conf
. /bin/network-functions
. /etc/image_features

if [ -e "/tmp/featurestatus.conf" ] ; then
	. /tmp/featurestatus.conf
fi


PIDFILE=/var/run/acd.pid
LOGGER="/bin/logger -t $0"

SERVICE=acd
PROCESS_NAME=acd

SETSID=/usr/bin/setsid

do_start ()
{
	if [ "$FEATURE_DEMO" != "1" ] ; then
		if [ "$SEC_START_ACD" = "false" ] ; then
			return $?
		fi
	fi

	/etc/init.d/softdogd wait
	
	ServiceCheckRunning1

	$SETSID /telephony/acd > /dev/null 2>&1 &
	echo $! > $PIDFILE

	ServiceCheckRunning2
	return $?
}

do_stop ()
{
	if [ "$FEATURE_DEMO" != "1" ] ; then
		if [ "$SEC_START_ACD" = "false" ] ; then
			return $?
		fi
	fi

	/etc/init.d/softdogd wait
	ServiceStop

	return $?
}

do_status ()
{
	if [ "$FEATURE_DEMO" != "1" ] ; then
		if [ "$SEC_START_ACD" = "false" ] ; then
			return $?
		fi
	fi

	ServiceStatus

	return $?
}


case "$1" in
	start)
		do_start
		;;
	stop)
		do_stop
		;;
	status) 
		do_status
		;;
	restart)
		do_stop
		/bin/usleep 500
		do_start
		;;
	*)
		echo "Usage: $0 {start|stop|restart|status}"
		exit 1
esac

exit $?

