r.manifest revision 70cbfe41f2338b77c15f79c6625eca6e70c412f3
2d54cf04fc02db7c369592b6f91bbd1330df3387Andreas Gustafsson# CDDL HEADER START
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrence# The contents of this file are subject to the terms of the
2d54cf04fc02db7c369592b6f91bbd1330df3387Andreas Gustafsson# Common Development and Distribution License (the "License").
2d54cf04fc02db7c369592b6f91bbd1330df3387Andreas Gustafsson# You may not use this file except in compliance with the License.
2d54cf04fc02db7c369592b6f91bbd1330df3387Andreas Gustafsson# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2d54cf04fc02db7c369592b6f91bbd1330df3387Andreas Gustafsson# or http://www.opensolaris.org/os/licensing.
2d54cf04fc02db7c369592b6f91bbd1330df3387Andreas Gustafsson# See the License for the specific language governing permissions
2d54cf04fc02db7c369592b6f91bbd1330df3387Andreas Gustafsson# and limitations under the License.
36bc6a0a8312de762caf1e984efe15c8e7170d9dAndreas Gustafsson# When distributing Covered Code, include this CDDL HEADER in each
36bc6a0a8312de762caf1e984efe15c8e7170d9dAndreas Gustafsson# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
76458ec215a57c6806afdd831b9c9a30b93344b0Andreas Gustafsson# If applicable, add the following below this CDDL HEADER, with the
76458ec215a57c6806afdd831b9c9a30b93344b0Andreas Gustafsson# fields enclosed by brackets "[]" replaced with your own identifying
2d54cf04fc02db7c369592b6f91bbd1330df3387Andreas Gustafsson# information: Portions Copyright [yyyy] [name of copyright owner]
2d54cf04fc02db7c369592b6f91bbd1330df3387Andreas Gustafsson# CDDL HEADER END
76458ec215a57c6806afdd831b9c9a30b93344b0Andreas Gustafsson# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence# Use is subject to license terms.
76458ec215a57c6806afdd831b9c9a30b93344b0Andreas Gustafsson# r.manifest - smf(5) manifest remove class action script
63404af69b0b99b8fa551e92702921f01c3bbfd7Andreas Gustafsson# number of seconds to wait before killing processes
63404af69b0b99b8fa551e92702921f01c3bbfd7Andreas Gustafsson# Helper function. Delete the manifest hash value.
f7aa8ce0b3cf7f5df618a42beecf8d5517c000acAndreas Gustafsson# Arguments: $1: manifest file.
63404af69b0b99b8fa551e92702921f01c3bbfd7Andreas Gustafsson # this Solaris release doesn't have delhash command
63404af69b0b99b8fa551e92702921f01c3bbfd7Andreas Gustafsson if $SVCPROP -q -p $pg_name smf/manifest; then
3d4a70fe38769e42b943717256208b63fec05f32Andreas Gustafsson# Helper function. Handle services deathrow file.
3d4a70fe38769e42b943717256208b63fec05f32Andreas Gustafsson# Arguments: $1:manifest file, $2:package name.
3d4a70fe38769e42b943717256208b63fec05f32Andreas Gustafsson DEATHROW_FILE=${PKG_INSTALL_ROOT}/etc/svc/deathrow
3d4a70fe38769e42b943717256208b63fec05f32Andreas Gustafsson # remove alternate root from manifest path
3d4a70fe38769e42b943717256208b63fec05f32Andreas Gustafsson manifest=`echo "${PKG_INSTALL_ROOT} $1" | $AWK \
36bc6a0a8312de762caf1e984efe15c8e7170d9dAndreas Gustafsson # Services deathrow file handling, file format:
f7aa8ce0b3cf7f5df618a42beecf8d5517c000acAndreas Gustafsson # <fmri>< ><manifest file>< ><package name>
76458ec215a57c6806afdd831b9c9a30b93344b0Andreas Gustafsson # Manifest file could be from another Solaris version, bypass the
76458ec215a57c6806afdd831b9c9a30b93344b0Andreas Gustafsson # the service bundle and validation (we only need the fmris list).
f5eb48652c7ec98514256b5b6e6fd7cbc22b1916Andreas Gustafsson # Calling svccfg inventory with SVCCFG_NOVALIDATE=1 is safe because
76458ec215a57c6806afdd831b9c9a30b93344b0Andreas Gustafsson # there is no access to the alternate repository.
f7aa8ce0b3cf7f5df618a42beecf8d5517c000acAndreas Gustafsson ENTITIES=`SVCCFG_NOVALIDATE=1 $SVCCFG inventory $1`
36bc6a0a8312de762caf1e984efe15c8e7170d9dAndreas Gustafsson echo ${fmri} ${manifest} $2 >> ${DEATHROW_FILE}
f7aa8ce0b3cf7f5df618a42beecf8d5517c000acAndreas Gustafsson while [ ${nsec:=0} -lt $wait_time ]; do
36bc6a0a8312de762caf1e984efe15c8e7170d9dAndreas Gustafsson state=`$SVCPROP -p restarter/state $svcinst`
36bc6a0a8312de762caf1e984efe15c8e7170d9dAndreas Gustafsson if [ "$state" = "disabled" -o "$state" = "maintenance" ]; then
f7aa8ce0b3cf7f5df618a42beecf8d5517c000acAndreas Gustafsson nstate=`$SVCPROP -p restarter/next_state $svcinst`
2d54cf04fc02db7c369592b6f91bbd1330df3387Andreas Gustafssonif [ "$PKG_INSTALL_ROOT" != "" -a "$PKG_INSTALL_ROOT" != "/" ]; then
2d54cf04fc02db7c369592b6f91bbd1330df3387Andreas Gustafsson # We can't safely disable the service in this case.
3d4a70fe38769e42b943717256208b63fec05f32Andreas Gustafsson # We can verify if the service is disabled prior to
2d54cf04fc02db7c369592b6f91bbd1330df3387Andreas Gustafsson if [ -r /etc/svc/volatile/repository_door ]; then
76458ec215a57c6806afdd831b9c9a30b93344b0Andreas Gustafsson # Determine whether fmri refers to an instance or a service.
2d54cf04fc02db7c369592b6f91bbd1330df3387Andreas Gustafsson $SVCPROP -p restarter/state $fmri >/dev/null 2>&1
36bc6a0a8312de762caf1e984efe15c8e7170d9dAndreas Gustafsson # this is a service fmri, all instances have been deleted
2d54cf04fc02db7c369592b6f91bbd1330df3387Andreas Gustafsson # process next instance
echo "Waiting up to $STOP_DELAY seconds for $fmri to stop..."
echo "Failed to disable $fmri after $STOP_DELAY seconds"
echo "Failed to disable $fmri"
echo "Force deleting $fmri"