OpenSolaris_b135/pkgdefs/SUNWsacom/postinstall

#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
# ident	"%Z%%M%	%I%	%E% SMI"

#
# pkgdefs/SUNWsacom/postinstall
#

#
# Retain original SNMPD configuration file they might have from an
# earlier SunNet Manager installation.
#

if [ -f $BASEDIR/etc/opt/SUNWconn/snm/snmpd.conf ] ; then
    cp $BASEDIR/etc/snmp/conf/snmpd.conf $BASEDIR/etc/snmp/conf/snmpd.conf.original
    echo 'Copying $BASEDIR/etc/opt/SUNWconn/snm/snmpd.conf (existing SNMPD configuration file)'
    echo 'to $BASEDIR/etc/snmp/conf/snmpd.conf'
    cp $BASEDIR/etc/opt/SUNWconn/snm/snmpd.conf $BASEDIR/etc/snmp/conf/snmpd.conf
fi

def_read="public"
def_write="private"
def_desc="Sun SNMP Agent, Company Property Number 123456"
def_cont="System administrator"
def_loc="System administrators office"

READSTR=$def_read
WRITESTR=$def_write

        desc=`/etc/prtconf |/usr/bin/head -5|/usr/bin/grep SUNW |awk -F, '{print $2}'`
	if [ "$desc" = "" ]; then
		desc=`/etc/prtconf |/usr/bin/head -5|/usr/bin/grep SUNW |awk '{print $1}'`
	fi
        def_desc="Sun SNMP Agent, $desc"

DESCSTR=$def_desc
CONTSTR=$def_cont
LOCSTR=$def_loc
export READSTR WRITESTR DESCSTR CONTSTR LOCSTR

# main ()

#
# Update the snmpd.conf file with the default community strings
# for the system on which this is installed.
#

/usr/bin/ed -s $BASEDIR/etc/snmp/conf/snmpd.conf <<SNMPEOF>/dev/null
1,\$s!ALLDESC!$DESCSTR!g
1,\$s!ALLCONT!$CONTSTR!g
1,\$s!ALLLOC!$LOCSTR!g
w
q
SNMPEOF

installf -f $PKGINST

#
# check if snmpdx should be enabled (snmpdx.tmp was set in preinstall)
if [ -f $BASEDIR/var/snmpdx.tmp ]; then
	cat >> $BASEDIR/var/svc/profile/upgrade <<\_SNMPDX
if [ `/sbin/zonename` = global ]; then
	/usr/sbin/svcadm enable svc:/application/management/snmpdx:default
fi
_SNMPDX
	rm -f $BASEDIR/var/snmpdx.tmp
fi

exit 0