i.manifest revision ead1f93ee620d7580f7e53350fe5a884fc4f158a
883N/A#!/bin/sh
883N/A#
883N/A# CDDL HEADER START
883N/A#
883N/A# The contents of this file are subject to the terms of the
883N/A# Common Development and Distribution License (the "License").
883N/A# You may not use this file except in compliance with the License.
883N/A#
883N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
883N/A# or http://www.opensolaris.org/os/licensing.
883N/A# See the License for the specific language governing permissions
883N/A# and limitations under the License.
883N/A#
883N/A# When distributing Covered Code, include this CDDL HEADER in each
883N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
883N/A# If applicable, add the following below this CDDL HEADER, with the
883N/A# fields enclosed by brackets "[]" replaced with your own identifying
883N/A# information: Portions Copyright [yyyy] [name of copyright owner]
883N/A#
883N/A# CDDL HEADER END
883N/A#
883N/A#
883N/A# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
883N/A# Use is subject to license terms.
883N/A#
883N/A# i.manifest - smf(5) service manifest install class action script
883N/A#
883N/A
883N/Arepfile=$PKG_INSTALL_ROOT/etc/svc/repository.db
883N/Aexport repfile
883N/A
883N/ASVCCFG=/usr/sbin/svccfg
883N/ASVCADM=/usr/sbin/svcadm
883N/AAWK=/usr/bin/awk
883N/ARM=/usr/bin/rm
883N/ACP=/usr/bin/cp
883N/AMV=/usr/bin/mv
883N/ACHMOD=/usr/bin/chmod
883N/ACHOWN=/usr/bin/chown
883N/A
883N/A#
883N/A# Helper function. Handle services deathrow file.
883N/A# Arguments: $1:manifest file.
883N/A#
883N/Asvc_deathrow()
883N/A{
883N/A TEMP=/tmp/svc_deathrow.$$
883N/A DEATHROW_FILE=${PKG_INSTALL_ROOT}/etc/svc/deathrow
883N/A #
883N/A # Services deathrow file handling, file format:
883N/A # <fmri>< ><manifest file>< ><package name>
883N/A # (field separator is a space character)
883N/A #
883N/A if [ -s ${DEATHROW_FILE} ]; then
883N/A #
883N/A # Manifest file could be from another Solaris version, bypass
883N/A # the service bundle and validation (we only need the fmris
883N/A # list). Calling svccfg inventory with SVCCFG_NOVALIDATE=1 is
883N/A # safe because there is no access to the alternate repository.
883N/A #
883N/A ENTITIES=`SVCCFG_NOVALIDATE=1 $SVCCFG inventory $1`
883N/A for fmri in $ENTITIES; do
883N/A #
883N/A # If fmri matches one in deathrow file, remove the
883N/A # line from the file.
883N/A #
883N/A >${TEMP}
883N/A $AWK "(\$1==\"$fmri\") \
883N/A {next}; {print}" ${DEATHROW_FILE} >>${TEMP} && \
883N/A $MV ${TEMP} ${DEATHROW_FILE}
883N/A $RM -f ${TEMP}
883N/A done
883N/A fi
883N/A}
883N/A
883N/A#
883N/A# If the repository does not yet exist, create it from the appropriate seed. If
883N/A# for some reason the seeds do not exist, svccfg(1M) will create the repository
883N/A# automatically.
883N/A#
883N/Aif [ ! -f $repfile ]; then
883N/A if [ -n "$SUNW_PKG_INSTALL_ZONENAME" -a \
"$SUNW_PKG_INSTALL_ZONENAME" != "global" ]; then
[ -f $PKG_INSTALL_ROOT/lib/svc/seed/nonglobal.db ] && \
$CP $PKG_INSTALL_ROOT/lib/svc/seed/nonglobal.db $repfile
else
[ -f $PKG_INSTALL_ROOT/lib/svc/seed/global.db ] && \
$CP $PKG_INSTALL_ROOT/lib/svc/seed/global.db $repfile
fi
$CHMOD 0600 $repfile
$CHOWN root:sys $repfile
fi
if [ ! -r $PKG_INSTALL_ROOT/etc/svc/volatile/repository_door ]; then
#
# smf(5) is not presently running for the destination environment.
# Since we presently cannot refresh without a running svc.startd(1M), we
# cannot consistently handle dependent placement. Defer to next boot.
#
while read src dst; do
$CP -p $src $dst
# deathrow handling
svc_deathrow $dst
done
else
#
# Local package install.
#
while read src dst; do
$CP -p $src $dst
[ "$PKG_INSTALL_ROOT" = "" -o "$PKG_INSTALL_ROOT" = "/" ] && \
$SVCADM restart svc:/system/manifest-import:default
done
fi
exit 0