Print this page
7818 SMF does not always cleanup services that have been removed
Reviewed by: Joshua M. Clulow <josh@sysmgr.org>


   3 # CDDL HEADER START
   4 #
   5 # The contents of this file are subject to the terms of the
   6 # Common Development and Distribution License (the "License").
   7 # You may not use this file except in compliance with the License.
   8 #
   9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10 # or http://www.opensolaris.org/os/licensing.
  11 # See the License for the specific language governing permissions
  12 # and limitations under the License.
  13 #
  14 # When distributing Covered Code, include this CDDL HEADER in each
  15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16 # If applicable, add the following below this CDDL HEADER, with the
  17 # fields enclosed by brackets "[]" replaced with your own identifying
  18 # information: Portions Copyright [yyyy] [name of copyright owner]
  19 #
  20 # CDDL HEADER END
  21 #
  22 # Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.

  23 #
  24 
  25 # 0a  Initialization.
  26 
  27 [ -f /lib/svc/share/smf_include.sh ] || exit 1
  28 
  29 . /lib/svc/share/smf_include.sh
  30 
  31 activity=false
  32 
  33 EMI_SERVICE="svc:/system/early-manifest-import:default"
  34 PROFILE_DIR_SITE="/etc/svc/profile/site"
  35 
  36 X=
  37 ALT_REPOSITORY=
  38 ALT_MFST_DIR=
  39 early=false
  40 [ "$SMF_FMRI" == "$EMI_SERVICE" ] && early=true
  41 
  42 usage()


  56                 d)      ALT_MFST_DIR=$OPTARG;;
  57                 f)      ALT_REPOSITORY=$OPTARG;;
  58                 ?)      usage;;
  59         esac
  60 done
  61 
  62 #
  63 # Both -f and -d options must be specified together or not specified at all
  64 #
  65 [ -n "$ALT_REPOSITORY" -a -z "$ALT_MFST_DIR" ] && usage
  66 [ -n "$ALT_MFST_DIR" -a -z "$ALT_REPOSITORY" ] && usage
  67 
  68 function svccfg_apply {
  69         $X /usr/sbin/svccfg apply $1
  70         if [ $? -ne 0 ]; then
  71                 echo "WARNING: svccfg apply $1 failed" | tee /dev/msglog
  72         fi
  73 }
  74 
  75 #
  76 # If the smf/manifest table has file entries that are missing
  77 # then there is work to be done by the cleanup process.
  78 #
  79 function cleanup_needwork {
  80         if [ "$early" == true ]; then
  81                 smfmfiles=`/usr/bin/svcprop smf/manifest | \
  82                     awk '(/^lib_/ && /\/manifestfile /) {print $3}'`
  83         else
  84                 smfmfiles=`/usr/bin/svcprop smf/manifest | \
  85                     awk '/\/manifestfile / {print $3}'`
  86         fi
  87 
  88         nw=`/lib/svc/bin/mfstscan $smfmfiles 2>&1 1>/dev/null`
  89         [ "$nw" ] && return 1
  90 
  91         return 0
  92 }
  93 
  94 #
  95 # Upon upgrading to early manifest import code, preserve hashes of system
  96 # profiles which lived under /var/svc/profile so that svccfg apply would
  97 # not re-apply the profiles and overwrite user customizations. Simply 
  98 # migrate manifestfile and hash values to new property groups named after
  99 # profiles under /etc/svc/profile. If the profiles don't really exist,
 100 # svccfg cleanup will remove the property groups in a later step.
 101 # 
 102 # Existing generic.xml, inetd_services.xml, and name_service.xml symlinks
 103 # need to be preserved.
 104 #
 105 # Don't process site.xml profile since it is still supported under
 106 # /var/svc/profile directory.




   3 # CDDL HEADER START
   4 #
   5 # The contents of this file are subject to the terms of the
   6 # Common Development and Distribution License (the "License").
   7 # You may not use this file except in compliance with the License.
   8 #
   9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10 # or http://www.opensolaris.org/os/licensing.
  11 # See the License for the specific language governing permissions
  12 # and limitations under the License.
  13 #
  14 # When distributing Covered Code, include this CDDL HEADER in each
  15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16 # If applicable, add the following below this CDDL HEADER, with the
  17 # fields enclosed by brackets "[]" replaced with your own identifying
  18 # information: Portions Copyright [yyyy] [name of copyright owner]
  19 #
  20 # CDDL HEADER END
  21 #
  22 # Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
  23 # Copyright 2017 RackTop Systems.
  24 #
  25 
  26 # 0a  Initialization.
  27 
  28 [ -f /lib/svc/share/smf_include.sh ] || exit 1
  29 
  30 . /lib/svc/share/smf_include.sh
  31 
  32 activity=false
  33 
  34 EMI_SERVICE="svc:/system/early-manifest-import:default"
  35 PROFILE_DIR_SITE="/etc/svc/profile/site"
  36 
  37 X=
  38 ALT_REPOSITORY=
  39 ALT_MFST_DIR=
  40 early=false
  41 [ "$SMF_FMRI" == "$EMI_SERVICE" ] && early=true
  42 
  43 usage()


  57                 d)      ALT_MFST_DIR=$OPTARG;;
  58                 f)      ALT_REPOSITORY=$OPTARG;;
  59                 ?)      usage;;
  60         esac
  61 done
  62 
  63 #
  64 # Both -f and -d options must be specified together or not specified at all
  65 #
  66 [ -n "$ALT_REPOSITORY" -a -z "$ALT_MFST_DIR" ] && usage
  67 [ -n "$ALT_MFST_DIR" -a -z "$ALT_REPOSITORY" ] && usage
  68 
  69 function svccfg_apply {
  70         $X /usr/sbin/svccfg apply $1
  71         if [ $? -ne 0 ]; then
  72                 echo "WARNING: svccfg apply $1 failed" | tee /dev/msglog
  73         fi
  74 }
  75 
  76 #
  77 # If the smf repository has file entries that are missing
  78 # then there is work to be done by the cleanup process.
  79 #
  80 function cleanup_needwork {
  81         smfmfiles=`svcprop -p manifestfiles '*' 2>/dev/null |
  82             nawk -v early="$early" '$2 == "astring" &&
  83             (early != "true" || $3 ~ "^/lib/") { print $3 }'`




  84 
  85         nw=`/lib/svc/bin/mfstscan $smfmfiles 2>&1 1>/dev/null`
  86         [ "$nw" ] && return 1
  87 
  88         return 0
  89 }
  90 
  91 #
  92 # Upon upgrading to early manifest import code, preserve hashes of system
  93 # profiles which lived under /var/svc/profile so that svccfg apply would
  94 # not re-apply the profiles and overwrite user customizations. Simply 
  95 # migrate manifestfile and hash values to new property groups named after
  96 # profiles under /etc/svc/profile. If the profiles don't really exist,
  97 # svccfg cleanup will remove the property groups in a later step.
  98 # 
  99 # Existing generic.xml, inetd_services.xml, and name_service.xml symlinks
 100 # need to be preserved.
 101 #
 102 # Don't process site.xml profile since it is still supported under
 103 # /var/svc/profile directory.