manifest-import revision adfc3118ca8c6b541b6a93d4bc24583eb4ebd73d
3e02c9e33656dcd9c364633d42dd785d3e6fdd66Automatic Updater# CDDL HEADER START
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater# The contents of this file are subject to the terms of the
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater# Common Development and Distribution License (the "License").
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater# You may not use this file except in compliance with the License.
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater# or http://www.opensolaris.org/os/licensing.
3e02c9e33656dcd9c364633d42dd785d3e6fdd66Automatic Updater# See the License for the specific language governing permissions
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater# and limitations under the License.
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater# When distributing Covered Code, include this CDDL HEADER in each
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater# If applicable, add the following below this CDDL HEADER, with the
dcfda24abf565c442d058cbf81b2180d847a1b3eAutomatic Updater# fields enclosed by brackets "[]" replaced with your own identifying
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater# information: Portions Copyright [yyyy] [name of copyright owner]
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater# CDDL HEADER END
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater# 0a Initialization.
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater[ -f /lib/svc/share/smf_include.sh ] || exit 1
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic UpdaterEMI_SERVICE="svc:/system/early-manifest-import:default"
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater[ "$SMF_FMRI" == "$EMI_SERVICE" ] && early=true
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater ?) echo "Usage: /lib/svc/method/manifest-import [-n]\n"
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater if [ $? -ne 0 ]; then
8ec3c085233cedb22b05da36e2773c8f357a7e45Automatic Updater echo "WARNING: svccfg apply $1 failed" | tee /dev/msglog
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater# If the smf/manifest table has file entries that are missing
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater# then there is work to be done by the cleanup process.
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater smfmfiles=`/usr/bin/svcprop smf/manifest | \
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater awk '(/^lib_/ && /\/manifestfile /) {print $3}'`
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater smfmfiles=`/usr/bin/svcprop smf/manifest | \
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater nw=`/lib/svc/bin/mfstscan $smfmfiles 2>&1 1>/dev/null`
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater# Upon upgrading to early manifest import code, preserve hashes of system
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater# profiles which lived under /var/svc/profile so that svccfg apply would
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater# not re-apply the profiles and overwrite user customizations. Simply
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater# migrate manifestfile and hash values to new property groups named after
dcfda24abf565c442d058cbf81b2180d847a1b3eAutomatic Updater# profiles under /etc/svc/profile. If the profiles don't really exist,
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater# svccfg cleanup will remove the property groups in a later step.
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater# Existing generic.xml, inetd_services.xml, and name_service.xml symlinks
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater# need to be preserved.
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater# Don't process site.xml profile since it is still supported under
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater # If /var is a separate fs, return and let Late Import
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater # Preserve hashes for the following profiles: generic (two
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater # cases) and platform (uname -i, uname -m outputs).
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater gh=`/usr/bin/svcprop -p ${gn}/md5sum smf/manifest 2>/dev/null`
64affc54f96a2c71cbd10ed71e246ce0746259aaAutomatic Updater gln="var_svc_profile_generic_limited_net_xml"
8ec3c085233cedb22b05da36e2773c8f357a7e45Automatic Updater glh=`/usr/bin/svcprop -p ${gln}/md5sum smf/manifest 2>/dev/null`
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater gln="etc_svc_profile_generic_limited_net_xml"
dcfda24abf565c442d058cbf81b2180d847a1b3eAutomatic Updater LC_ALL=C pl=`/usr/bin/uname -i | /usr/bin/tr , _`
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater plh=`/usr/bin/svcprop -p ${pln}/md5sum smf/manifest 2>/dev/null`
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater LC_ALL=C plm=`/usr/bin/uname -m | /usr/bin/tr , _`
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater if [ $plm != $pl ]; then
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater plmn="var_svc_profile_platform_${plm}_xml"
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater plmh=`/usr/bin/svcprop -p ${plmn}/md5sum smf/manifest \
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater plmn="etc_svc_profile_platform_${plm}_xml"
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater /usr/sbin/svccfg -s smf/manifest addpg ${gn} framework
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater /usr/sbin/svccfg -s smf/manifest setprop ${gn}/md5sum = \
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater /usr/sbin/svccfg -s smf/manifest setprop ${gn}/manifestfile = \
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater echo "Preserving generic_limited hash ($glh)."
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater /usr/sbin/svccfg -s smf/manifest addpg ${gln} framework
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater /usr/sbin/svccfg -s smf/manifest setprop ${gln}/md5sum = \
f8e3e03cacd16ffb923a9603fca23a9e1a1fee07Automatic Updater /usr/sbin/svccfg -s smf/manifest setprop ${gln}/manifestfile = \
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater /usr/sbin/svccfg -s smf/manifest addpg $pln framework
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater /usr/sbin/svccfg -s smf/manifest setprop $pln/md5sum = \
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater /usr/sbin/svccfg -s smf/manifest setprop ${pln}/manifestfile = \
f8e3e03cacd16ffb923a9603fca23a9e1a1fee07Automatic Updater astring: "/etc/svc/profile/platform_${pl}_xml"
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updater /usr/sbin/svccfg -s smf/manifest addpg $plmn framework
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updater /usr/sbin/svccfg -s smf/manifest setprop $plmn/md5sum = \
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updater /usr/sbin/svccfg -s smf/manifest setprop \
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updater astring: "/etc/svc/profile/platform_${plm}_xml"
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updater # Move symlinks from /var/svc/profile to /etc/svc/profile
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updater generic_prof="/var/svc/profile/generic.xml"
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updater ns_prof="/var/svc/profile/name_service.xml"
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updater inetd_prof="/var/svc/profile/inetd_services.xml"
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updater platform_prof="/var/svc/profile/platform.xml"
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updater [ -L "$generic_prof" ] && mv $generic_prof /etc/svc/profile/
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updater [ -L "$ns_prof" ] && mv $ns_prof /etc/svc/profile/
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updater [ -L "$inetd_prof" ] && mv $inetd_prof /etc/svc/profile/
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updater [ -L "$platform_prof" ] && mv $platform_prof /etc/svc/profile/
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updater# 2. Manifest import. Application directories first, then
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updater# site-specific manifests.
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updater typeset logf="/etc/svc/volatile/manifest_import.$$"
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater nonsite_dirs=`/usr/bin/find $basedir/svc/manifest/* -name site \
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater -prune -o -type d -print -prune`
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater nonsite_manifests=`/lib/svc/bin/mfstscan $nonsite_dirs`
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater site_manifests=`/lib/svc/bin/mfstscan $basedir/svc/manifest/site`
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater manifests="$nonsite_manifests $site_manifests"
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater # Attempt of moving the repository to tmpfs. If that doesn't
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater # work, reset doswitch so we don't attempt switching back.
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater /usr/sbin/svcadm _smf_repository_switch fast
44d0f0256fbdce130a18655023c3b06bacacbd61Automatic Updater # Import the manifests while giving a running display of imports on
83f43b00a50c9c932c81691a3828041643a0d6f6Automatic Updater # console, and a final count in the logfile.
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater dirs="$nonsite_dirs $basedir/svc/manifest/site"
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater $X /usr/sbin/svccfg import -p /dev/msglog $dirs > $logf 2>&1
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater grep "Loaded .*. smf(5) service descriptions" $logf > /dev/null 2>&1
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater if [ $? -eq 0 ]; then
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater if [ -s $logf ]; then
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater grep "smf(5) service descriptions failed to load" $logf > /dev/null 2>&1
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater if [ $failures -eq 0 ]; then
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater if [ $failures -eq 0 ]; then
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater msg="$msg /var/svc/log/system-manifest-import:default.log ."
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater# 3. Profile application. We must create the platform profile upon
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater# first boot, as we may be a diskless client of a platform or
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater# architecture distinct from our NFS server.
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater# Generic and platform profiles are only supported in /etc.
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater # If smf/manifest doesn't have any profile under /etc/var/profile,
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater # this is very likely an import after upgrade so call
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater LC_ALL=C pl=`/usr/bin/uname -i | /usr/bin/tr , _`
if [ $preserve_profiles -eq 1 ]; then
preserve_system_profiles || return
if [ ! -f $prefix/platform.xml ]; then
if [ -f $prefix/platform_$this_plat.xml ]; then
elif [ -f $prefix/platform_$this_karch.xml ]; then
unset SVCCFG_CHECKHASH
# 5. Giving administrator the final say, apply site.xml profile and profiles
[ -f $prefix/site.xml ] && svccfg_apply $prefix/site.xml
if [ -s $deathrow ];then
# svc.startd has unconfigured the services found in deathrow,
done < $deathrow
i=`expr $i + 1`
activity=true
if $activity; then
exit $SMF_EXIT_ERR_FATAL
if $activity; then