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 2008 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 29 repfile=$PKG_INSTALL_ROOT/etc/svc/repository.db 30 export repfile 31 32 SVCCFG=/usr/sbin/svccfg 33 AWK=/usr/bin/awk 34 RM=/usr/bin/rm 35 CP=/usr/bin/cp 36 MV=/usr/bin/mv 37 CHMOD=/usr/bin/chmod 38 CHOWN=/usr/bin/chown 39 40 # 41 # Helper function. Handle services deathrow file. 42 # Arguments: $1:manifest file. 43 # 44 svc_deathrow() 45 { 46 TEMP=/tmp/svc_deathrow.$$ 47 DEATHROW_FILE=${PKG_INSTALL_ROOT}/etc/svc/deathrow 48 # 49 # Services deathrow file handling, file format: 50 # <fmri>< ><manifest file>< ><package name> 51 # (field separator is a space character) 52 # 53 if [ -s ${DEATHROW_FILE} ]; then 54 # 55 # Manifest file could be from another Solaris version, bypass 56 # the service bundle and validation (we only need the fmris 57 # list). Calling svccfg inventory with SVCCFG_NOVALIDATE=1 is 58 # safe because there is no access to the alternate repository. 59 # 60 ENTITIES=`SVCCFG_NOVALIDATE=1 $SVCCFG inventory $1` 61 for fmri in $ENTITIES; do 62 # 63 # If fmri matches one in deathrow file, remove the 64 # line from the file. 65 # 66 >${TEMP} 67 $AWK "(\$1==\"$fmri\") \ 68 {next}; {print}" ${DEATHROW_FILE} >>${TEMP} && \ 69 $MV ${TEMP} ${DEATHROW_FILE} 70 $RM -f ${TEMP} 71 done 72 fi 73 } 74 75 # 76 # If the repository does not yet exist, create it from the appropriate seed. If 77 # for some reason the seeds do not exist, svccfg(1M) will create the repository 78 # automatically. 79 # 80 if [ ! -f $repfile ]; then 81 if [ -n "$SUNW_PKG_INSTALL_ZONENAME" -a \ 82 "$SUNW_PKG_INSTALL_ZONENAME" != "global" ]; then 83 [ -f $PKG_INSTALL_ROOT/lib/svc/seed/nonglobal.db ] && \ 84 $CP $PKG_INSTALL_ROOT/lib/svc/seed/nonglobal.db $repfile 85 else 86 [ -f $PKG_INSTALL_ROOT/lib/svc/seed/global.db ] && \ 87 $CP $PKG_INSTALL_ROOT/lib/svc/seed/global.db $repfile 88 fi 89 $CHMOD 0600 $repfile 90 $CHOWN root:sys $repfile 91 fi 92 93 if [ ! -r $PKG_INSTALL_ROOT/etc/svc/volatile/repository_door ]; then 94 # 95 # smf(5) is not presently running for the destination environment. 96 # Since we presently cannot refresh without a running svc.startd(1M), we 97 # cannot consistently handle dependent placement. Defer to next boot. 98 # 99 while read src dst; do 100 $CP -p $src $dst 101 # deathrow handling 102 svc_deathrow $dst 103 done 104 else 105 # 106 # Local package install. 107 # 108 while read src dst; do 109 $CP -p $src $dst 110 111 [ "$PKG_INSTALL_ROOT" = "" -o "$PKG_INSTALL_ROOT" = "/" ] && \ 112 SVCCFG_CHECKHASH=1 $SVCCFG import $dst 113 done 114 fi 115 116 exit 0 117