i.manifest revision 11838:32bb5d254240
1139749Simp#!/bin/sh 2116491Sharti# 3116491Sharti# CDDL HEADER START 4116491Sharti# 5116491Sharti# The contents of this file are subject to the terms of the 6116491Sharti# Common Development and Distribution License (the "License"). 7116491Sharti# You may not use this file except in compliance with the License. 8116491Sharti# 9116491Sharti# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10116491Sharti# or http://www.opensolaris.org/os/licensing. 11116491Sharti# See the License for the specific language governing permissions 12116491Sharti# and limitations under the License. 13116491Sharti# 14116491Sharti# When distributing Covered Code, include this CDDL HEADER in each 15116491Sharti# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16116491Sharti# If applicable, add the following below this CDDL HEADER, with the 17116491Sharti# fields enclosed by brackets "[]" replaced with your own identifying 18116491Sharti# information: Portions Copyright [yyyy] [name of copyright owner] 19116491Sharti# 20116491Sharti# CDDL HEADER END 21116491Sharti# 22116491Sharti# 23116491Sharti# Copyright 2009 Sun Microsystems, Inc. All rights reserved. 24116491Sharti# Use is subject to license terms. 25116491Sharti# 26116491Sharti# i.manifest - smf(5) service manifest install class action script 27116491Sharti# 28116491Sharti 29116491Shartirepfile=$PKG_INSTALL_ROOT/etc/svc/repository.db 30116491Shartiexport repfile 31116491Sharti 32116491ShartiSVCCFG=/usr/sbin/svccfg 33116491ShartiSVCADM=/usr/sbin/svcadm 34116491ShartiAWK=/usr/bin/awk 35116491ShartiRM=/usr/bin/rm 36116491ShartiCP=/usr/bin/cp 37116491ShartiMV=/usr/bin/mv 38116491ShartiCHMOD=/usr/bin/chmod 39116491ShartiCHOWN=/usr/bin/chown 40116491Sharti 41116491Sharti# 42116491Sharti# Helper function. Handle services deathrow file. 43116491Sharti# Arguments: $1:manifest file. 44116491Sharti# 45116491Shartisvc_deathrow() 46116491Sharti{ 47116491Sharti TEMP=/tmp/svc_deathrow.$$ 48116491Sharti DEATHROW_FILE=${PKG_INSTALL_ROOT}/etc/svc/deathrow 49116491Sharti # 50116491Sharti # Services deathrow file handling, file format: 51116491Sharti # <fmri>< ><manifest file>< ><package name> 52116491Sharti # (field separator is a space character) 53116491Sharti # 54116491Sharti if [ -s ${DEATHROW_FILE} ]; then 55116491Sharti # 56116491Sharti # Manifest file could be from another Solaris version, bypass 57116491Sharti # the service bundle and validation (we only need the fmris 58116491Sharti # list). Calling svccfg inventory with SVCCFG_NOVALIDATE=1 is 59116491Sharti # safe because there is no access to the alternate repository. 60116491Sharti # 61116491Sharti ENTITIES=`SVCCFG_NOVALIDATE=1 $SVCCFG inventory $1` 62116491Sharti for fmri in $ENTITIES; do 63116491Sharti # 64116491Sharti # If fmri matches one in deathrow file, remove the 65116491Sharti # line from the file. 66116491Sharti # 67116491Sharti >${TEMP} 68116491Sharti $AWK "(\$1==\"$fmri\") \ 69116491Sharti {next}; {print}" ${DEATHROW_FILE} >>${TEMP} && \ 70116491Sharti $MV ${TEMP} ${DEATHROW_FILE} 71116491Sharti $RM -f ${TEMP} 72116491Sharti done 73116491Sharti fi 74116491Sharti} 75116491Sharti 76116491Sharti# 77116491Sharti# If the repository does not yet exist, create it from the appropriate seed. If 78116491Sharti# for some reason the seeds do not exist, svccfg(1M) will create the repository 79116491Sharti# automatically. 80116491Sharti# 81116491Shartiif [ ! -f $repfile ]; then 82116491Sharti if [ -n "$SUNW_PKG_INSTALL_ZONENAME" -a \ 83116491Sharti "$SUNW_PKG_INSTALL_ZONENAME" != "global" ]; then 84116491Sharti [ -f $PKG_INSTALL_ROOT/lib/svc/seed/nonglobal.db ] && \ 85116491Sharti $CP $PKG_INSTALL_ROOT/lib/svc/seed/nonglobal.db $repfile 86116491Sharti else 87116491Sharti [ -f $PKG_INSTALL_ROOT/lib/svc/seed/global.db ] && \ 88116491Sharti $CP $PKG_INSTALL_ROOT/lib/svc/seed/global.db $repfile 89116491Sharti fi 90116491Sharti $CHMOD 0600 $repfile 91116491Sharti $CHOWN root:sys $repfile 92116491Shartifi 93116491Sharti 94116491Shartiif [ ! -r $PKG_INSTALL_ROOT/etc/svc/volatile/repository_door ]; then 95116491Sharti # 96116491Sharti # smf(5) is not presently running for the destination environment. 97116491Sharti # Since we presently cannot refresh without a running svc.startd(1M), we 98116491Sharti # cannot consistently handle dependent placement. Defer to next boot. 99116491Sharti # 100116491Sharti while read src dst; do 101116491Sharti $CP -p $src $dst 102116491Sharti # deathrow handling 103116491Sharti svc_deathrow $dst 104116491Sharti 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