#!/sbin/sh
#
# mrouted
#
#           Copyright (C) 1993, 1994 Hewlett-Packard Company
#
# NOTE:    This script is not configurable!  Any changes made to this
#          script will be overwritten when you upgrade to the next
#          release of HP-UX.
#

PATH=/sbin:/usr/sbin:/usr/bin
export PATH

rval=0
set_return() {
        x=$?
        if [ $x -ne 0 ]; then
                echo "EXIT CODE: $x"
                rval=1  # always 1 so that 2 can be used for other reasons
        fi
}


case $1 in
start_msg)
	echo "Start multicast routing daemon"
	;;

stop_msg)
	echo "Stopping multicast routing daemon"
	;;
'start')
        if [ -f /etc/rc.config ] ; then
		. /etc/rc.config
	else
		echo "ERROR: /etc/rc.config defaults file MISSING"
	fi


	if [ "$MROUTED" -eq 1 -a -x /usr/sbin/mrouted ] ; then
		/usr/sbin/mrouted $MROUTED_ARGS && echo "mrouted"
		set_return
	else
		rval=2
	fi	
	;;

'stop')
	if [ -f /etc/rc.config ] ; then
		. /etc/rc.config
	else
		echo "ERROR: /etc/rc.config defaults file MISSING"
	fi

	#
	# Determine PID of process(es) to stop
	#
	if [ "$MROUTED" -ne 1 ] ; then
	    rval=2
        else
            if [ -r /var/run/mrouted.pid ]; then
                if kill -TERM `cat /var/run/mrouted.pid`; then
			echo "mrouted stopped"
		else
			rval=1
			echo "Unable to stop mrouted"
		fi
	    else
		rval=1
		echo "Unable to stop mrouted (no pid file)"
	    fi
	fi
        ;;

*)
	echo "usage: $0 {start|stop}"
	rval=1
	;;
esac

exit $rval


