# Copyright 1994 Sun Microsystems, Inc. All Rights Reserved.
#
# Copyright (c) 1992 by Sun Microsystems, Inc.
#
# Postinstall script for SNM snmp daemon package
#
 
#ident  "@(#)postinstall 1.23     94/07/07"

#
# Return pid of named process in variable "pid"
#
pidproc() {
        pid=`/usr/bin/ps -e |
                /usr/bin/grep $1 |
                /usr/bin/sed -e 's/^  *//' -e 's/ .*//'`
}

#
# Update the snmpd.conf file with community strings provided by the user
# during the request script
#
if [ ! -d /etc/opt ]; then
     mkdir -m 777 /etc/opt
fi
if [ ! -d /etc/opt/SUNWconn ]; then
     mkdir -m 777 /etc/opt/SUNWconn
fi
if [ ! -d /etc/opt/SUNWconn/snm ]; then
	if [ -d /etc/opt/snm ]; then
		mv /etc/opt/snm /etc/opt/SUNWconn/snm
		cd /etc/opt
		ln -s SUNWconn/snm snm
	fi
fi
if [ ! -h /etc/opt/snm ]; then
	cd /etc/opt
	ln -s SUNWconn/snm snm
fi
pidproc snmpd
if [ "$pid" != "" ]; then
        echo 'Killing snmpd'
        kill -9 $pid
fi

#$BASEDIR/SUNWconn/snm/agents/snmpd -c /etc/opt/SUNWconn/snm/snmpd.conf
#echo 'Starting snmpd.'
/etc/init.d/init.snmpd start
exit 0
