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