manifest-import revision adfc3118ca8c6b541b6a93d4bc24583eb4ebd73d
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# 0a Initialization.
activity=false
EMI_SERVICE="svc:/system/early-manifest-import:default"
X=
early=false
while getopts "n" opt; do
n) X=echo;;
?) echo "Usage: /lib/svc/method/manifest-import [-n]\n"
exit 2;;
esac
done
function svccfg_apply {
if [ $? -ne 0 ]; then
fi
}
#
# then there is work to be done by the cleanup process.
#
function cleanup_needwork {
else
fi
return 0
}
#
# Upon upgrading to early manifest import code, preserve hashes of system
# not re-apply the profiles and overwrite user customizations. Simply
# migrate manifestfile and hash values to new property groups named after
# svccfg cleanup will remove the property groups in a later step.
#
# Existing generic.xml, inetd_services.xml, and name_service.xml symlinks
# need to be preserved.
#
# Don't process site.xml profile since it is still supported under
#
function preserve_system_profiles {
#
# If /var is a separate fs, return and let Late Import
# preserves the hashes.
#
#
# Preserve hashes for the following profiles: generic (two
# cases) and platform (uname -i, uname -m outputs).
#
gn="var_svc_profile_generic_open_xml"
[ $? = 0 ] || gh=""
gn="etc_svc_profile_generic_open_xml"
gln="var_svc_profile_generic_limited_net_xml"
[ $? = 0 ] || glh=""
gln="etc_svc_profile_generic_limited_net_xml"
pln="var_svc_profile_platform_${pl}_xml"
[ $? = 0 ] || plh=""
pln="etc_svc_profile_platform_${pl}_xml"
plmn="var_svc_profile_platform_${plm}_xml"
[ $? = 0 ] || plmh=""
plmn="etc_svc_profile_platform_${plm}_xml"
else
plmh=""
fi
echo "Preserving generic hash ($gh)."
astring: "/etc/svc/profile/generic.xml"
}
echo "Preserving generic_limited hash ($glh)."
astring: "/etc/svc/profile/generic.xml"
}
echo "Preserving platform hash ($plh)."
}
echo "Preserving platform hash ($plmh)."
${plmn}/manifestfile = \
}
#
#
return 0
}
#
# 2. Manifest import. Application directories first, then
# site-specific manifests.
#
function import_manifests {
typeset basedir=$1
typeset logf="/etc/svc/volatile/manifest_import.$$"
echo "Changed manifests to import:"
fi
#
# Attempt of moving the repository to tmpfs. If that doesn't
# work, reset doswitch so we don't attempt switching back.
#
doswitch=$?
#
# Import the manifests while giving a running display of imports on
# console, and a final count in the logfile.
#
dirs="$nonsite_dirs $basedir/svc/manifest/site"
if [ $? -eq 0 ]; then
activity=true
fi
if [ -s $logf ]; then
failures=$?
echo "svccfg warnings:"
fi
msg="svccfg import warnings. See"
fi
fi
}
#
# 3. Profile application. We must create the platform profile upon
# first boot, as we may be a diskless client of a platform or
# architecture distinct from our NFS server.
#
# Generic and platform profiles are only supported in /etc.
#
function apply_profile {
#
# this is very likely an import after upgrade so call
# preserve_system_profiles in that case.
#
pln="etc_svc_profile_platform_${pl}_xml"
then
break
fi
done
if [ $preserve_profiles -eq 1 ]; then
preserve_system_profiles || return
fi
if [ ! -f $prefix/platform.xml ]; then
this_karch=`uname -m`
if [ -f $prefix/platform_$this_plat.xml ]; then
elif [ -f $prefix/platform_$this_karch.xml ]; then
else
fi
fi
}
#
# 4. Upgrade handling. The upgrade file generally consists of a series
# of svcadm(1M) and svccfg(1M) commands.
#
function handle_upgrade {
(
unset SVCCFG_CHECKHASH
/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
# the file cannot be renamed until now (when the file system becomes
# read-write).
#
if [ -f "${datalink_script}" ]; then
fi
)
}
#
# 5. Giving administrator the final say, apply site.xml profile and profiles
#
function apply_site_profile {
[ -f $prefix/site.xml ] && svccfg_apply $prefix/site.xml
fi
}
#
# 0b Cleanup deathrow
#
if [ "$early" = "false" ];then
if [ -s $deathrow ];then
#
# svc.startd has unconfigured the services found in deathrow,
# clean them now.
#
# Delete services and instances from the deathrow file.
# Remove deathrow manifest hash.
done < $deathrow
fi
fi
#
# 0c Clean up repository
#
if [ "$early" = "false" ]; then
then
set -- `
done
`
i=1; n=$#
while [ $# -gt 0 ]; do
)
i=`expr $i + 1`
shift
done
echo "Converted $n obsolete repository entries"
activity=true
fi
fi
#
# Call import and apply profiles here
#
if [ "$early" = "true" ]; then
import_manifests "/lib"
apply_site_profile "/etc"
else
#
# during late manifest-import
#
# First import the manifests
#
import_manifests "/lib"
import_manifests "/var"
#
# Apply profiles
#
apply_site_profile "/etc"
#
# Run the upgrade script
#
apply_site_profile "/var"
fi
#
# 6. Final actions.
#
if $activity; then
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...
#
if [ $? -eq 0 ]; then
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
else
if [ $? -ne 0 ]; then
fi
fi
exit 0