1#!/bin/sh 2# 3# CDDL HEADER START 4# 5# The contents of this file are subject to the terms of the 6# Common Development and Distribution License (the "License"). 7# You may not use this file except in compliance with the License. 8# 9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10# or http://www.opensolaris.org/os/licensing. 11# See the License for the specific language governing permissions 12# and limitations under the License. 13# 14# When distributing Covered Code, include this CDDL HEADER in each 15# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16# If applicable, add the following below this CDDL HEADER, with the 17# fields enclosed by brackets "[]" replaced with your own identifying 18# information: Portions Copyright [yyyy] [name of copyright owner] 19# 20# CDDL HEADER END 21# 22# 23# Copyright 2009 Sun Microsystems, Inc. All rights reserved. 24# Use is subject to license terms. 25# 26# i.manifest - smf(5) service manifest install class action script 27# 28 29repfile=$PKG_INSTALL_ROOT/etc/svc/repository.db 30export repfile 31 32SVCCFG=/usr/sbin/svccfg 33SVCADM=/usr/sbin/svcadm 34AWK=/usr/bin/awk 35RM=/usr/bin/rm 36CP=/usr/bin/cp 37MV=/usr/bin/mv 38CHMOD=/usr/bin/chmod 39CHOWN=/usr/bin/chown 40 41# 42# Helper function. Handle services deathrow file. 43# Arguments: $1:manifest file. 44# 45svc_deathrow() 46{ 47 TEMP=/tmp/svc_deathrow.$$ 48 DEATHROW_FILE=${PKG_INSTALL_ROOT}/etc/svc/deathrow 49 # 50 # Services deathrow file handling, file format: 51 # <fmri>< ><manifest file>< ><package name> 52 # (field separator is a space character) 53 # 54 if [ -s ${DEATHROW_FILE} ]; then 55 # 56 # Manifest file could be from another Solaris version, bypass 57 # the service bundle and validation (we only need the fmris 58 # list). Calling svccfg inventory with SVCCFG_NOVALIDATE=1 is 59 # safe because there is no access to the alternate repository. 60 # 61 ENTITIES=`SVCCFG_NOVALIDATE=1 $SVCCFG inventory $1` 62 for fmri in $ENTITIES; do 63 # 64 # If fmri matches one in deathrow file, remove the 65 # line from the file. 66 # 67 >${TEMP} 68 $AWK "(\$1==\"$fmri\") \ 69 {next}; {print}" ${DEATHROW_FILE} >>${TEMP} && \ 70 $MV ${TEMP} ${DEATHROW_FILE} 71 $RM -f ${TEMP} 72 done 73 fi 74} 75 76# 77# If the repository does not yet exist, create it from the appropriate seed. If 78# for some reason the seeds do not exist, svccfg(1M) will create the repository 79# automatically. 80# 81if [ ! -f $repfile ]; then 82 if [ -n "$SUNW_PKG_INSTALL_ZONENAME" -a \ 83 "$SUNW_PKG_INSTALL_ZONENAME" != "global" ]; then 84 [ -f $PKG_INSTALL_ROOT/lib/svc/seed/nonglobal.db ] && \ 85 $CP $PKG_INSTALL_ROOT/lib/svc/seed/nonglobal.db $repfile 86 else 87 [ -f $PKG_INSTALL_ROOT/lib/svc/seed/global.db ] && \ 88 $CP $PKG_INSTALL_ROOT/lib/svc/seed/global.db $repfile 89 fi 90 $CHMOD 0600 $repfile 91 $CHOWN root:sys $repfile 92fi 93 94if [ ! -r $PKG_INSTALL_ROOT/etc/svc/volatile/repository_door ]; then 95 # 96 # smf(5) is not presently running for the destination environment. 97 # Since we presently cannot refresh without a running svc.startd(1M), we 98 # cannot consistently handle dependent placement. Defer to next boot. 99 # 100 while read src dst; do 101 $CP -p $src $dst 102 # deathrow handling 103 svc_deathrow $dst 104 done 105else 106 # 107 # Local package install. 108 # 109 while read src dst; do 110 $CP -p $src $dst 111 112 [ "$PKG_INSTALL_ROOT" = "" -o "$PKG_INSTALL_ROOT" = "/" ] && \ 113 $SVCADM restart svc:/system/manifest-import:default 114 done 115fi 116 117exit 0 118