Description: cleanup. Requires rewrite. Index: manifest-import/usr/src/cmd/svc/milestone/manifest-import =================================================================== --- manifest-import.orig/usr/src/cmd/svc/milestone/manifest-import 2012-10-08 00:25:33.000000000 +0000 +++ manifest-import/usr/src/cmd/svc/milestone/manifest-import 2013-01-23 08:06:37.981528144 +0000 @@ -66,10 +66,12 @@ [ -n "$ALT_MFST_DIR" -a -z "$ALT_REPOSITORY" ] && usage function svccfg_apply { - $X /usr/sbin/svccfg apply $1 - if [ $? -ne 0 ]; then - echo "WARNING: svccfg apply $1 failed" | tee /dev/msglog - fi + if [ -e $1 ]; then + $X /usr/sbin/svccfg apply $1 + if [ $? -ne 0 ]; then + echo "WARNING: svccfg apply $1 failed" | tee /dev/msglog + fi + fi } # @@ -92,108 +94,6 @@ } # -# Upon upgrading to early manifest import code, preserve hashes of system -# profiles which lived under /var/svc/profile so that svccfg apply would -# not re-apply the profiles and overwrite user customizations. Simply -# migrate manifestfile and hash values to new property groups named after -# profiles under /etc/svc/profile. If the profiles don't really exist, -# 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 -# /var/svc/profile directory. -# -function preserve_system_profiles { - - # - # If /var is a separate fs, return and let Late Import - # preserves the hashes. - # - [ -d "/var/svc/profile" ] || return 1 - - # - # Preserve hashes for the following profiles: generic (two - # cases) and platform (uname -i, uname -m outputs). - # - gn="var_svc_profile_generic_open_xml" - gh=`/usr/bin/svcprop -p ${gn}/md5sum smf/manifest 2>/dev/null` - [ $? = 0 ] || gh="" - gn="etc_svc_profile_generic_open_xml" - - gln="var_svc_profile_generic_limited_net_xml" - glh=`/usr/bin/svcprop -p ${gln}/md5sum smf/manifest 2>/dev/null` - [ $? = 0 ] || glh="" - gln="etc_svc_profile_generic_limited_net_xml" - - LC_ALL=C pl=`/usr/bin/uname -i | /usr/bin/tr , _` - pln="var_svc_profile_platform_${pl}_xml" - plh=`/usr/bin/svcprop -p ${pln}/md5sum smf/manifest 2>/dev/null` - [ $? = 0 ] || plh="" - pln="etc_svc_profile_platform_${pl}_xml" - - LC_ALL=C plm=`/usr/bin/uname -m | /usr/bin/tr , _` - if [ $plm != $pl ]; then - plmn="var_svc_profile_platform_${plm}_xml" - plmh=`/usr/bin/svcprop -p ${plmn}/md5sum smf/manifest \ - 2>/dev/null` - [ $? = 0 ] || plmh="" - plmn="etc_svc_profile_platform_${plm}_xml" - else - plmh="" - fi - - [ -n "$gh" ] && { - echo "Preserving generic hash ($gh)." - /usr/sbin/svccfg -s smf/manifest addpg ${gn} framework - /usr/sbin/svccfg -s smf/manifest setprop ${gn}/md5sum = \ - opaque: $gh - /usr/sbin/svccfg -s smf/manifest setprop ${gn}/manifestfile = \ - astring: "/etc/svc/profile/generic.xml" - } - [ -n "$glh" ] && { - echo "Preserving generic_limited hash ($glh)." - /usr/sbin/svccfg -s smf/manifest addpg ${gln} framework - /usr/sbin/svccfg -s smf/manifest setprop ${gln}/md5sum = \ - opaque: $glh - /usr/sbin/svccfg -s smf/manifest setprop ${gln}/manifestfile = \ - astring: "/etc/svc/profile/generic.xml" - } - [ -n "$plh" ] && { - echo "Preserving platform hash ($plh)." - /usr/sbin/svccfg -s smf/manifest addpg $pln framework - /usr/sbin/svccfg -s smf/manifest setprop $pln/md5sum = \ - opaque: $plh - /usr/sbin/svccfg -s smf/manifest setprop ${pln}/manifestfile = \ - astring: "/etc/svc/profile/platform_${pl}_xml" - } - [ -n "$plmh" ] && { - echo "Preserving platform hash ($plmh)." - /usr/sbin/svccfg -s smf/manifest addpg $plmn framework - /usr/sbin/svccfg -s smf/manifest setprop $plmn/md5sum = \ - opaque: $plmh - /usr/sbin/svccfg -s smf/manifest setprop \ - ${plmn}/manifestfile = \ - astring: "/etc/svc/profile/platform_${plm}_xml" - } - - # - # Move symlinks from /var/svc/profile to /etc/svc/profile - # - generic_prof="/var/svc/profile/generic.xml" - ns_prof="/var/svc/profile/name_service.xml" - inetd_prof="/var/svc/profile/inetd_services.xml" - platform_prof="/var/svc/profile/platform.xml" - [ -L "$generic_prof" ] && mv $generic_prof /etc/svc/profile/ - [ -L "$ns_prof" ] && mv $ns_prof /etc/svc/profile/ - [ -L "$inetd_prof" ] && mv $inetd_prof /etc/svc/profile/ - [ -L "$platform_prof" ] && mv $platform_prof /etc/svc/profile/ - - return 0 -} - -# # 2. Manifest import. Application directories first, then # site-specific manifests. # @@ -202,6 +102,8 @@ typeset console_print=$2 typeset logf="/etc/svc/volatile/manifest_import.$$" + [ -d "$basedir" ] || return 0; + rm -f $logf nonsite_dirs=`/usr/bin/find $basedir/* -name site \ @@ -260,106 +162,6 @@ } # -# 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 { - # - # If smf/manifest doesn't have any profile under /etc/var/profile, - # this is very likely an import after upgrade so call - # preserve_system_profiles in that case. - # - 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" - [ -f $prefix/site.xml ] && svccfg_apply $prefix/site.xml - - if [ -d $PROFILE_DIR_SITE -a "$1" = "/etc/svc/profile" ]; then - svccfg_apply $PROFILE_DIR_SITE - fi -} - -# # 0b Cleanup deathrow # if [ "$early" = "false" ];then @@ -382,53 +184,6 @@ 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 - -# # If the alternate repository and directory are specified, simply set # SVCCFG_REPOSITORY env, run svccfg import on the given directory, and # exit. @@ -443,33 +198,7 @@ # # Call import and apply profiles here # -if [ "$early" = "true" ]; then - import_manifests "/lib/svc/manifest" true - apply_profile - apply_site_profile "/etc/svc/profile" -else - # - # Process both /lib/svc/manifest and /var/svc/manifest - # during late manifest-import - # - # First import the manifests - # - import_manifests "/lib/svc/manifest" true - import_manifests "/var/svc/manifest" true - - # - # Apply profiles - # - apply_profile - apply_site_profile "/etc/svc/profile" - - # - # Run the upgrade script - # - handle_upgrade - apply_site_profile "/var/svc/profile" -fi - +import_manifests "/lib/svc/manifest" true # # 6. Final actions.