#!/bin/sh
#
# Copyright (c) 1993, by Sun Microsystems, Inc.
#
#ident	"$Header: /net/projects/S2.6/cvs/os_net/src_ws/usr/src/tadcmd/locations/init.d/snmp,v 1.1 1997/10/09 10:37:07 ang Exp $"
#
#LocINFO Simple Network Management Protocol
#

procexist() {
    pid=`/usr/bin/ps -e | /usr/bin/grep " ${1}$" |
	     /usr/bin/sed -e 's/^  *//' -e 's/ .*//'`
    if [ -z "$pid" ]
    then
	return 1
    fi
    return 0
}

#
# Start/stop snmp
#

case "$1" in

'start')
    (cd $LOCDB; find etc/snmp/conf -print | cpio -pdmu / 2>/dev/null)
    ${SH} /etc/init.d/init.snmpdx $1
    ;;

'stop')
    ${SH} /etc/init.d/init.snmpdx $1
    rm -rf /etc/snmp/conf
    ;;

'create')
    if [ -d /etc/snmp/conf ]
    then
	(echo /etc/snmp; find /etc/snmp/conf -print) | cpio -pdmu $LOCDB 2>/dev/null
	exit `procexist snmpdx`
    else
	exit 1
    fi
    ;;

*)
    echo "Usage: $0 { start | stop | create }" 1>&2
    ;;
esac

exit 0
