OpenSolaris_b135/pkgdefs/SUNWpmr/postinstall

#!/bin/sh
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (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 2004 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
#pragma ident	"%Z%%M%	%I%	%E% SMI"
#
# SUNWpmr postinstall script

SHUTDOWN_PATTERN="^[ 	]*autoshutdown[ 	]"

#
# If the old format of "autoshutdown" is used, upgrade it to the new format.
#
/bin/grep -s "${SHUTDOWN_PATTERN}" $BASEDIR/etc/power.conf >/dev/null
if [ $? = 0 ] ; then
	set - `/bin/grep "${SHUTDOWN_PATTERN}" $BASEDIR/etc/power.conf`
	if [ $# -ne 5 ] ; then
		if [ ${2} -lt 0 ] ; then
			BEHAVIOR="noshutdown"
		else
			BEHAVIOR="shutdown"
		fi
		cp $BASEDIR/etc/power.conf /tmp/power.conf
		( echo "/${SHUTDOWN_PATTERN}"
		  echo "s/$/		${BEHAVIOR}/"
		  echo "."; echo "w"; echo "q"
		) | ed -s $BASEDIR/etc/power.conf > /dev/null
		if [ $? != 0 ] ; then
			echo "Updating autoshutdown entry failed."
			cp /tmp/power.conf $BASEDIR/etc/power.conf
		fi
	fi
fi

#
# adds sysidpm to the list of applications run out of sysidconfig.
#
if [ -x /usr/sbin/sysidconfig ]; then {
	/usr/sbin/sysidconfig -b "${BASEDIR}" -l | /usr/bin/grep -s sysidpm >/dev/null
	if [ $? -ne 0 ]; then
                /usr/sbin/sysidconfig -b "${BASEDIR}" -a /usr/sbin/sysidpm
        fi
} else {
        /usr/bin/grep -s sysidpm ${BASEDIR}/etc/.sysidconfig.apps >/dev/null
        if [ $? -ne 0 ]; then
                echo /usr/sbin/sysidpm >> ${BASEDIR}/etc/.sysidconfig.apps
        fi
} fi

#
# .cpr_config file is moved to /etc directory
#
if [ -f $BASEDIR/.cpr_config ] ; then
  /bin/rm -f $BASEDIR/.cpr_config
fi

exit 0