#!/bin/bash

. /bin/network-functions

PIDFILE=/var/run/pmsmng.pid

SERVICE=pmsmng
PROCESS_NAME=pmsmng

do_start ()
{
	if ! ServiceCheckRunning1 ; then
		return $?
	fi

	# check if config is there or not empty... if not.. copy it from default-conf
	if [ ! -f /etc/fiad-conf/telephony/pmsmng.cfg ] || [ ! -s /etc/fiad-conf/telephony/pmsmng.cfg ]; then
		cp -f /etc/default-conf/telephony/pmsmng.cfg /etc/fiad-conf/telephony/
	fi

	echo -n $"Starting pmsmng service: "
	/bin/setsid /telephony/$PROCESS_NAME > /dev/null 2>&1 &
	echo $! > $PIDFILE

	ServiceCheckRunning2
	return $?
}

do_stop ()
{
	/etc/init.d/softdogd wait
	echo -n $"Shut down pmsmng service: "
	ServiceStop
	return $?
}

do_status ()
{
	ServiceStatus
	return $?
}

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

exit $?
