#!/bin/sh # # Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. # # # r.manifest - smf(5) manifest remove class action script # MFSTSCAN=/lib/svc/bin/mfstscan SVCCFG=/usr/sbin/svccfg SVCPROP=/usr/bin/svcprop SVCADM=/usr/sbin/svcadm AWK=/usr/bin/awk CP=/usr/bin/cp RM=/usr/bin/rm . /lib/svc/share/smf_include.sh # number of seconds to wait before killing processes STOP_DELAY=60 # # Helper function. Delete the manifest hash value. # Arguments: $1: manifest file. # svc_delhash() { $SVCCFG delhash $1 >/dev/null 2>&1 if [ "$?" != "0" ];then # this Solaris release doesn't have delhash command pg_name=`$MFSTSCAN -t $1` if $SVCPROP -q -p $pg_name smf/manifest; then $SVCCFG -s smf/manifest delpg $pg_name fi fi } # # Helper function. Handle services deathrow file. # # Arguments: # $1: manifest file (absolute path) # $2: manifest file (path relative to $PKG_INSTALL_ROOT) # $3: package name. # svc_deathrow() { DEATHROW_FILE=${PKG_INSTALL_ROOT}/etc/svc/deathrow # # Services deathrow file handling, file format: # < >< > # (field separator is a space character) # # Manifest file could be from another Solaris version, bypass the # the service bundle and validation (we only need the fmris list). # Calling svccfg inventory with SVCCFG_NOVALIDATE=1 is safe because # there is no access to the alternate repository. # ENTITIES=`SVCCFG_NOVALIDATE=1 $SVCCFG inventory $1` for fmri in $ENTITIES; do # add to services deathrow file echo ${fmri} $2 $3 >> ${DEATHROW_FILE} done } alternate_root="no" if [ "$PKG_INSTALL_ROOT" != "" -a "$PKG_INSTALL_ROOT" != "/" ]; then alternate_root="yes" fi smf_alive="no" if [ -r ${PKG_INSTALL_ROOT}${SMF_SYSVOL_FS}/repository_door -a \ "${alternate_root}" = "no" ]; then smf_alive="yes" fi while read mfst; do manifest=${mfst#${PKG_INSTALL_ROOT}} standard_location=`echo $manifest | $AWK \ '/^\/(var|lib)\/svc\/manifest\// { print "true" } \ { next; }'` if [ "${standard_location}" != "true" ]; then svc_deathrow $mfst $manifest $PKGINST fi $RM -f $mfst done # # Restarting manifest-import takes care of standard location manifests # AND cleans up death row services from nonstandard locations. This # is done implicitly on reboot into an alternate root, or explicitly # on a live system. # if [ "${smf_alive}" = "yes" ]; then $SVCADM restart svc:/system/manifest-import:default fi exit 0