#
# 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
usage()
{
"[-f repository-file -d manifest-directory]"
echo "\nOptions:"
echo "-n dryrun"
echo "-f and -d specify alternate repository and" \
"manifest directory for import\n"
exit 2
}
while getopts "nd:f:" opt; do
n) X=echo;;
d) ALT_MFST_DIR=$OPTARG;;
f) ALT_REPOSITORY=$OPTARG;;
?) usage;;
esac
done
#
# Both -f and -d options must be specified together or not specified at all
#
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 console_print=$2
typeset logf="/etc/svc/volatile/manifest_import.$$"
echo "Changed manifests to import:"
fi
#
# Upon boot, attempt to move the repository to tmpfs.
#
fi
#
# Import the manifests while giving a running display of imports on
# console, and a final count in the logfile.
#
dirs="$nonsite_dirs"
else
fi
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 {
typeset prefix="$1"
[ -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
#
# If the alternate repository and directory are specified, simply set
# SVCCFG_REPOSITORY env, run svccfg import on the given directory, and
# exit.
#
if [ -n "$ALT_REPOSITORY" -a -n "$ALT_MFST_DIR" ]; then
import_manifests "$ALT_MFST_DIR" false
unset SVCCFG_REPOSITORY
exit 0
fi
#
# Call import and apply profiles here
#
if [ "$early" = "true" ]; then
import_manifests "/lib/svc/manifest" true
else
#
# during late manifest-import
#
# First import the manifests
#
import_manifests "/lib/svc/manifest" true
import_manifests "/var/svc/manifest" true
#
# Apply profiles
#
#
# Run the upgrade script
#
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