manifest-import revision adfc3118ca8c6b541b6a93d4bc24583eb4ebd73d
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater#!/bin/ksh
dcfda24abf565c442d058cbf81b2180d847a1b3eAutomatic Updater#
3e02c9e33656dcd9c364633d42dd785d3e6fdd66Automatic Updater# CDDL HEADER START
3e02c9e33656dcd9c364633d42dd785d3e6fdd66Automatic Updater#
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.
3e02c9e33656dcd9c364633d42dd785d3e6fdd66Automatic Updater#
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#
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#
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater# CDDL HEADER END
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater#
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater#
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater# 0a Initialization.
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater[ -f /lib/svc/share/smf_include.sh ] || exit 1
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater. /lib/svc/share/smf_include.sh
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updateractivity=false
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic UpdaterEMI_SERVICE="svc:/system/early-manifest-import:default"
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic UpdaterPROFILE_DIR_SITE="/etc/svc/profile/site"
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic UpdaterX=
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updaterearly=false
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater[ "$SMF_FMRI" == "$EMI_SERVICE" ] && early=true
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updaterwhile getopts "n" opt; do
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater case $opt in
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater n) X=echo;;
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater ?) echo "Usage: /lib/svc/method/manifest-import [-n]\n"
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater exit 2;;
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater esac
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updaterdone
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updaterfunction svccfg_apply {
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater $X /usr/sbin/svccfg apply $1
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater if [ $? -ne 0 ]; then
8ec3c085233cedb22b05da36e2773c8f357a7e45Automatic Updater echo "WARNING: svccfg apply $1 failed" | tee /dev/msglog
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater fi
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater}
dcfda24abf565c442d058cbf81b2180d847a1b3eAutomatic Updater
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater#
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.
f8e3e03cacd16ffb923a9603fca23a9e1a1fee07Automatic Updater#
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updaterfunction cleanup_needwork {
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater if [ "$early" == true ]; then
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater smfmfiles=`/usr/bin/svcprop smf/manifest | \
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater awk '(/^lib_/ && /\/manifestfile /) {print $3}'`
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater else
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater smfmfiles=`/usr/bin/svcprop smf/manifest | \
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater awk '/\/manifestfile / {print $3}'`
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater fi
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater nw=`/lib/svc/bin/mfstscan $smfmfiles 2>&1 1>/dev/null`
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater [ "$nw" ] && return 1
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater return 0
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater}
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater#
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#
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater# Existing generic.xml, inetd_services.xml, and name_service.xml symlinks
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater# need to be preserved.
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater#
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater# Don't process site.xml profile since it is still supported under
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater# /var/svc/profile directory.
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater#
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updaterfunction preserve_system_profiles {
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater #
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater # If /var is a separate fs, return and let Late Import
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater # preserves the hashes.
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater #
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater [ -d "/var/svc/profile" ] || return 1
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater #
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater # Preserve hashes for the following profiles: generic (two
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater # cases) and platform (uname -i, uname -m outputs).
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater #
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater gn="var_svc_profile_generic_open_xml"
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater gh=`/usr/bin/svcprop -p ${gn}/md5sum smf/manifest 2>/dev/null`
8ec3c085233cedb22b05da36e2773c8f357a7e45Automatic Updater [ $? = 0 ] || gh=""
8ec3c085233cedb22b05da36e2773c8f357a7e45Automatic Updater gn="etc_svc_profile_generic_open_xml"
8ec3c085233cedb22b05da36e2773c8f357a7e45Automatic Updater
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 [ $? = 0 ] || glh=""
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater gln="etc_svc_profile_generic_limited_net_xml"
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater
dcfda24abf565c442d058cbf81b2180d847a1b3eAutomatic Updater LC_ALL=C pl=`/usr/bin/uname -i | /usr/bin/tr , _`
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater pln="var_svc_profile_platform_${pl}_xml"
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater plh=`/usr/bin/svcprop -p ${pln}/md5sum smf/manifest 2>/dev/null`
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater [ $? = 0 ] || plh=""
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater pln="etc_svc_profile_platform_${pl}_xml"
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater
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 2>/dev/null`
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater [ $? = 0 ] || plmh=""
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater plmn="etc_svc_profile_platform_${plm}_xml"
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater else
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater plmh=""
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater fi
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater [ -n "$gh" ] && {
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater echo "Preserving generic hash ($gh)."
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater /usr/sbin/svccfg -s smf/manifest addpg ${gn} framework
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater /usr/sbin/svccfg -s smf/manifest setprop ${gn}/md5sum = \
5a24d24c8fba3480d707c0c902379ddb36501e12Automatic Updater opaque: $gh
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater /usr/sbin/svccfg -s smf/manifest setprop ${gn}/manifestfile = \
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater astring: "/etc/svc/profile/generic.xml"
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater }
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater [ -n "$glh" ] && {
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 = \
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater opaque: $glh
f8e3e03cacd16ffb923a9603fca23a9e1a1fee07Automatic Updater /usr/sbin/svccfg -s smf/manifest setprop ${gln}/manifestfile = \
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater astring: "/etc/svc/profile/generic.xml"
f8e3e03cacd16ffb923a9603fca23a9e1a1fee07Automatic Updater }
f8e3e03cacd16ffb923a9603fca23a9e1a1fee07Automatic Updater [ -n "$plh" ] && {
f8e3e03cacd16ffb923a9603fca23a9e1a1fee07Automatic Updater echo "Preserving platform hash ($plh)."
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater /usr/sbin/svccfg -s smf/manifest addpg $pln framework
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater /usr/sbin/svccfg -s smf/manifest setprop $pln/md5sum = \
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater opaque: $plh
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater /usr/sbin/svccfg -s smf/manifest setprop ${pln}/manifestfile = \
f8e3e03cacd16ffb923a9603fca23a9e1a1fee07Automatic Updater astring: "/etc/svc/profile/platform_${pl}_xml"
f8e3e03cacd16ffb923a9603fca23a9e1a1fee07Automatic Updater }
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater [ -n "$plmh" ] && {
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updater echo "Preserving platform hash ($plmh)."
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updater /usr/sbin/svccfg -s smf/manifest addpg $plmn framework
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updater /usr/sbin/svccfg -s smf/manifest setprop $plmn/md5sum = \
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updater opaque: $plmh
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updater /usr/sbin/svccfg -s smf/manifest setprop \
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updater ${plmn}/manifestfile = \
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updater astring: "/etc/svc/profile/platform_${plm}_xml"
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updater }
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updater
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updater #
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updater # Move symlinks from /var/svc/profile to /etc/svc/profile
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updater #
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
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updater return 0
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updater}
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updater
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updater#
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updater# 2. Manifest import. Application directories first, then
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updater# site-specific manifests.
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updater#
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updaterfunction import_manifests {
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updater typeset basedir=$1
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updater typeset logf="/etc/svc/volatile/manifest_import.$$"
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updater
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updater rm -f $logf
3acf5eb97cebc2ba868e6ac4a4e01e6d1be0c892Automatic Updater
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater nonsite_dirs=`/usr/bin/find $basedir/svc/manifest/* -name site \
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater -prune -o -type d -print -prune`
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater
dcfda24abf565c442d058cbf81b2180d847a1b3eAutomatic Updater if [ -n "$_MFST_DEBUG" ]; then
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater nonsite_manifests=`/lib/svc/bin/mfstscan $nonsite_dirs`
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater site_manifests=`/lib/svc/bin/mfstscan $basedir/svc/manifest/site`
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater manifests="$nonsite_manifests $site_manifests"
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater echo "Changed manifests to import:"
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater for m in $manifests; do echo " $m"; done
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater fi
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater
83f43b00a50c9c932c81691a3828041643a0d6f6Automatic Updater #
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 #
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater /usr/sbin/svcadm _smf_repository_switch fast
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater doswitch=$?
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater #
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 #
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
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater grep "Loaded .*. smf(5) service descriptions" $logf > /dev/null 2>&1
2895f101b5585a19015ac2c2c1e1812ac467fa12Automatic Updater if [ $? -eq 0 ]; then
dcfda24abf565c442d058cbf81b2180d847a1b3eAutomatic Updater activity=true
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater fi
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater if [ -s $logf ]; then
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater grep "smf(5) service descriptions failed to load" $logf > /dev/null 2>&1
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater failures=$?
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater if [ $failures -eq 0 ]; then
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater echo "svccfg warnings:"
dcfda24abf565c442d058cbf81b2180d847a1b3eAutomatic Updater fi
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater cat $logf
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater if [ $failures -eq 0 ]; then
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater msg="svccfg import warnings. See"
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater msg="$msg /var/svc/log/system-manifest-import:default.log ."
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater echo $msg > /dev/msglog
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater fi
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater fi
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater rm -f $logf
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater}
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater#
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#
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater# Generic and platform profiles are only supported in /etc.
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater#
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updaterfunction apply_profile {
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater #
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 # preserve_system_profiles in that case.
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater #
590c12cfe3b9a179ab2faa1be791a069c81882e0Automatic Updater LC_ALL=C pl=`/usr/bin/uname -i | /usr/bin/tr , _`
pln="etc_svc_profile_platform_${pl}_xml"
LC_ALL=C plm=`/usr/bin/uname -m | /usr/bin/tr , _`
[ $plm != $pl ] && plmn="etc_svc_profile_platform_${plm}_xml"
preserve_profiles=1
for prof in $pln $plmn etc_svc_profile_platform_none_xml \
etc_svc_profile_generic_limited_net_xml \
etc_svc_profile_generic_open_xml; do
if /usr/bin/svcprop -p $prof smf/manifest >/dev/null 2>&1
then
preserve_profiles=0
break
fi
done
if [ $preserve_profiles -eq 1 ]; then
echo "/etc/svc system profiles not found: upgrade system profiles"
preserve_system_profiles || return
fi
typeset prefix="/etc/svc/profile"
svccfg_apply $prefix/generic.xml
if [ ! -f $prefix/platform.xml ]; then
this_karch=`uname -m`
this_plat=`uname -i`
if [ -f $prefix/platform_$this_plat.xml ]; then
platform_profile=platform_$this_plat.xml
elif [ -f $prefix/platform_$this_karch.xml ]; then
platform_profile=platform_$this_karch.xml
else
platform_profile=platform_none.xml
fi
ln -s $platform_profile $prefix/platform.xml
fi
svccfg_apply $prefix/platform.xml
}
#
# 4. Upgrade handling. The upgrade file generally consists of a series
# of svcadm(1M) and svccfg(1M) commands.
#
function handle_upgrade {
[ -f /var/svc/profile/upgrade ] && activity=true
(
unset SVCCFG_CHECKHASH
if [ -f /var/svc/profile/upgrade ]; then
. /var/svc/profile/upgrade
/usr/bin/mv /var/svc/profile/upgrade \
/var/svc/profile/upgrade.app.`date +\%Y\%m\%d\%H\%M\%S`
fi
#
# Rename the datalink upgrade script file. This script is used in the
# network/physical service to upgrade datalink configuration, but
# the file cannot be renamed until now (when the file system becomes
# read-write).
#
datalink_script=/var/svc/profile/upgrade_datalink
if [ -f "${datalink_script}" ]; then
/usr/bin/mv "${datalink_script}" \
"${datalink_script}".app.`date +\%Y\%m\%d\%H\%M\%S`
fi
)
}
#
# 5. Giving administrator the final say, apply site.xml profile and profiles
# under /etc/svc/profile/site directory.
#
function apply_site_profile {
typeset prefix="$1/svc/profile"
[ -f $prefix/site.xml ] && svccfg_apply $prefix/site.xml
if [ -d $PROFILE_DIR_SITE -a "$1" = "/etc" ]; then
svccfg_apply $PROFILE_DIR_SITE
fi
}
#
# 0b Cleanup deathrow
#
if [ "$early" = "false" ];then
deathrow=/etc/svc/deathrow
if [ -s $deathrow ];then
#
# svc.startd has unconfigured the services found in deathrow,
# clean them now.
#
while read fmri mfst pkgname; do
# Delete services and instances from the deathrow file.
/usr/sbin/svccfg delete -f $fmri >/dev/null 2>&1
# Remove deathrow manifest hash.
/usr/sbin/svccfg delhash -d $mfst >/dev/null 2>&1
done < $deathrow
/usr/bin/mv $deathrow $deathrow.old
fi
fi
SVCCFG_CHECKHASH=1 export SVCCFG_CHECKHASH
#
# 0c Clean up repository
#
if [ "$early" = "false" ]; then
if [ -z "$X" ] && /usr/bin/svcprop smf/manifest 2>/dev/null |
/usr/bin/grep '^ar_svc_[^/]*/md5sum opaque ' >/dev/null
then
set -- `
/usr/bin/svcprop smf/manifest 2>/dev/null |
/usr/bin/grep '^ar_svc[^/]*/md5sum opaque ' |
/usr/bin/tr '/' ' ' |
while read pg prop type value; do
echo "$pg/$value"
done
`
backup=`echo "$#/$#" | sed 's/.//g'`
fwidth=`echo "$#\c" | wc -c`
echo "Converting obsolete repository entries: \c" > /dev/msglog
i=1; n=$#
while [ $# -gt 0 ]; do
printf "%${fwidth}s/%${fwidth}s" $i $n > /dev/msglog
echo $1 | sed 's:/: :' | (
read pg value
(echo "select /smf/manifest"; echo "delpg v$pg") |
/usr/sbin/svccfg 2>/dev/null >/dev/null
(echo "select /smf/manifest"; echo "delpg $pg") |
/usr/sbin/svccfg 2>/dev/null >/dev/null
(echo "select /smf/manifest";
echo "addpg v$pg framework") |
/usr/sbin/svccfg 2>/dev/null >/dev/null
(echo "select /smf/manifest";
echo "setprop v$pg/md5sum = opaque: $value") |
/usr/sbin/svccfg 2>/dev/null >/dev/null
)
i=`expr $i + 1`
shift
echo "$backup\c" > /dev/msglog
done
echo > /dev/msglog
echo "Converted $n obsolete repository entries"
activity=true
fi
fi
#
# Call import and apply profiles here
#
if [ "$early" = "true" ]; then
import_manifests "/lib"
apply_profile
apply_site_profile "/etc"
else
#
# Process both /lib/svc and /var/svc
# during late manifest-import
#
# First import the manifests
#
import_manifests "/lib"
import_manifests "/var"
#
# Apply profiles
#
apply_profile
apply_site_profile "/etc"
#
# Run the upgrade script
#
handle_upgrade
apply_site_profile "/var"
fi
#
# 6. Final actions.
#
if $activity; then
/usr/sbin/svcadm _smf_backup "manifest_import" || true
fi
#
# If the filesystem is NOT read only then move the repo back to perm
# There is no care wether the switch was made or not, but just want
# to move it. If it is already perm this does not affect anything
# at least on the surface. REALLY want to improve on this...
#
touch /etc/svc/smf_rwtest.$$ > /dev/null 2>&1
if [ $? -eq 0 ]; then
rm -f /etc/svc/smf_rwtest.$$
/usr/sbin/svcadm _smf_repository_switch perm || { \
echo "Repository switch back operation failed, \c"
echo "please check the system log for the"
echo "possible fatal error messages."
exit $SMF_EXIT_ERR_FATAL
}
fi
if $activity; then
/usr/sbin/svccfg cleanup | /usr/bin/tee /dev/msglog
else
cleanup_needwork
if [ $? -ne 0 ]; then
/usr/sbin/svccfg cleanup -a | /usr/bin/tee /dev/msglog
fi
fi
exit 0