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