:
#
# Copyrighted as an unpublished work.
# (c) Copyright 1989 INTERACTIVE Systems Corporation
# All rights reserved.
#

#      @(#)snmp	2.2 INTERACTIVE SNMP  source


#
# SNMP start/stop script
#

PATH=/etc:/bin:/usr/bin
#
# PROCS contains a list of processes to kill when SNMP is stopped.
# Edit as appropriate.
#
PROCS="snmpd"

# figure out which kernel we're running
if [ -x /bin/ps ] ; then
    /bin/su root -c "/bin/ps -e" > /tmp/ps.err$$ 2>&1
    if grep "not the booted" /tmp/ps.err$$ > /dev/null ; then
	PS="/bin/ps -n /unix.old"
    else
        PS="/bin/ps"
    fi
    rm -f /tmp/ps.err$$
else
    echo "$0: Can't find ps"
    exit 1
fi

case "$1" in
'start')
	/bin/su root -c "$PS -e" 2>/dev/null | \
		/usr/bin/fgrep snmpd > /dev/null 2>&1
	if [ $? -eq 0 ]
	then
		echo "SNMP already running.  SNMP start aborted."
		exit 0
	fi

	echo "SNMP Startup:\c"

	echo " snmpd\c"
	snmpd

	echo ""
	;;

'stop')
	echo "SNMP Shutdown: \c"

	PX=""
	OR=""
	for P in $PROCS
	do
		PX="$PX$OR$P"
		OR="|"
	done
	PX="/$PX/"
	/bin/su root -c "$PS -e" 2>/dev/null | \
		/usr/bin/awk "$PX { print \"kill \" \$1 }" | /bin/sh

	echo "done"
	;;

*)
	echo "Usage: $0 [ start | stop ]"
	exit 1
	;;
esac

exit 0
