Home | History | Annotate | Download | only in ext-sources
      1 #!/bin/sh
      2 #
      3 # CDDL HEADER START
      4 #
      5 # The contents of this file are subject to the terms of the
      6 # Common Development and Distribution License, Version 1.0 only
      7 # (the "License").  You may not use this file except in compliance
      8 # with the License.
      9 #
     10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
     11 # or http://www.opensolaris.org/os/licensing.
     12 # See the License for the specific language governing permissions
     13 # and limitations under the License.
     14 #
     15 # When distributing Covered Code, include this CDDL HEADER in each
     16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     17 # If applicable, add the following below this CDDL HEADER, with the
     18 # fields enclosed by brackets "[]" replaced with your own identifying
     19 # information: Portions Copyright [yyyy] [name of copyright owner]
     20 #
     21 # CDDL HEADER END
     22 #
     23 #
     24 # Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
     25 # Use is subject to license terms.
     26 #
     27 #ident	"@(#)r.manifest	1.4	05/06/08 SMI"
     28 #
     29 # r.manifest - smf(5) manifest remove class action script
     30 #
     31 
     32 if [ "$PKG_INSTALL_ROOT" != "" -a "$PKG_INSTALL_ROOT" != "/" ]; then
     33 	#
     34 	# We can't safely disable the service in this case.
     35 	#
     36 	smf_alive=no
     37 else
     38 	#
     39 	# We can verify if the service is disabled prior to
     40 	# removal.
     41 	#
     42 	if [ -r /etc/svc/volatile/repository_door ]; then
     43 		smf_alive=yes
     44 	fi
     45 fi
     46 
     47 MFSTSCAN=/lib/svc/bin/mfstscan
     48 SVCCFG=/usr/sbin/svccfg
     49 SVCPROP=/usr/bin/svcprop
     50 
     51 while read mfst; do
     52 	if [ "$smf_alive" = "yes" ]; then
     53 		ENTITIES=`$SVCCFG inventory $mfst`
     54 
     55 		for fmri in $ENTITIES; do
     56 			#
     57 			# Determine whether any of our instances are
     58 			# enabled.
     59 			#
     60 			en_p=`$SVCPROP -C -p general/enabled $fmri 2>/dev/null`
     61 			en_o=`$SVCPROP -C -p general_ovr/enabled $fmri 2>/dev/null`
     62 
     63 			if [ "$en_p" = "true" -o "$en_o" = "true" ]; then
     64 				echo "$fmri remains enabled; aborting"
     65 				exit 1
     66 			fi
     67 
     68 			$SVCCFG delete $fmri
     69 		done
     70 
     71 		#
     72 		# Delete the manifest hash value.
     73 		#
     74 		pg_name=`$MFSTSCAN -t $mfst`
     75 		if $SVCPROP -q -p $pg_name smf/manifest; then
     76 			$SVCCFG -s smf/manifest delpg $pg_name
     77 		fi
     78 	fi
     79 
     80 	/usr/bin/rm $mfst
     81 done
     82 
     83 exit 0
     84