# HG changeset patch # User kucharsk # Date 1189867783 25200 # Node ID 61acf2c76fd615e8663783766f8f49decbc538ec # Parent 7a15930aae3c1a90f38ac21fac16aab2d4248f8e 6604295 BrandZ installer log messages may not be as clear as needed in error legs diff -r 7a15930aae3c -r 61acf2c76fd6 usr/src/lib/brand/lx/zone/lx_distro_install.ksh --- a/usr/src/lib/brand/lx/zone/lx_distro_install.ksh Fri Sep 14 18:14:13 2007 -0700 +++ b/usr/src/lib/brand/lx/zone/lx_distro_install.ksh Sat Sep 15 07:49:43 2007 -0700 @@ -106,9 +106,8 @@ mini_bootfail=$(gettext "Attempt to boot miniroot for zone '%s' FAILED.") mini_copyfail=$(gettext "Attempt to copy miniroot for zone '%s' FAILED.") mini_initfail=$(gettext "Attempt to initialize miniroot for zone '%s' FAILED.") -mini_instfail=$(gettext "Attempt to install miniroot for zone '%s' FAILED.") +mini_instfail=$(gettext "Attempt to install RPM '%s' to miniroot FAILED.") mini_mediafail=$(gettext "Install of zone '%s' miniroot from\n %s FAILED.") -mini_rpmfail=$(gettext "Miniroot install of RPM '%s' FAILED.") mini_setfail=$(gettext "Attempt to setup miniroot for zone '%s' FAILED.") mini_mntfsfail=\ @@ -176,8 +175,6 @@ install_dist=$(gettext "Installing distribution '%s'...") install_zonefail=$(gettext "Attempt to install zone '%s' FAILED.") -log_wrfail=$(gettext "Error: cannot write to log file '%s'.") - no_distropath=$(gettext "ERROR: Distribution path '%s' doesn't exist.") install_done=$(gettext "Installation of %s to zone\n '%s' completed %s.") @@ -901,7 +898,7 @@ { unset miniroot_booted - if ! "$cwd/lx_init_zone" "$rootdir" "$logfile" mini; then + if ! "$cwd/lx_init_zone" "$rootdir" mini; then screenlog "$mini_initfail" "$zonename" return 1 fi @@ -1010,7 +1007,7 @@ rmdir -ps "$media_mntdir" - if ! "$cwd/lx_init_zone" "$rootdir" "$logfile"; then + if ! "$cwd/lx_init_zone" "$rootdir"; then screenlog "$zone_initrootfail" "$zonename" return 1 fi @@ -2078,7 +2075,7 @@ typeset filename="$1" lofi_dev=$(lofiadm "$filename" 2>/dev/null) && return 0 - lofi_dev=$(lofiadm -a "$filename" 2>/dev/null) && return 0 + lofi_dev=$(lofiadm -a "$filename") && return 0 screenlog "$lofi_failed" "$filename" return 1 @@ -2657,17 +2654,12 @@ media_mntdir="$rootdir/media" -# Redirect stderr to the log file if it is specified and is writable if [[ -n $logfile ]]; then - if ! echo "\nInstallation started `date`" >> "$logfile" \ - 2>/dev/null; then - screenlog "$log_wrfail" "$logfile" - exit $ZONE_SUBPROC_NOTCOMPLETE - fi - - exec 2>>"$logfile" + # If a log file was specified, log information regarding the install + log "\nInstallation started `date`" log "Installing from path \"$distro_path\"" else + # Redirect stderr to /dev/null if silent mode is specified. [[ -n $silent_mode ]] && exec 2>/dev/null fi diff -r 7a15930aae3c -r 61acf2c76fd6 usr/src/lib/brand/lx/zone/lx_init_zone.ksh --- a/usr/src/lib/brand/lx/zone/lx_init_zone.ksh Fri Sep 14 18:14:13 2007 -0700 +++ b/usr/src/lib/brand/lx/zone/lx_init_zone.ksh Sat Sep 15 07:49:43 2007 -0700 @@ -19,7 +19,7 @@ # # CDDL HEADER END # -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # ident "%Z%%M% %I% %E% SMI" @@ -47,11 +47,14 @@ export PATH # -# Sends output to log file if "$logfile" is set +# Sends output to a log file via redirection of stderr. +# +# This script assumes its caller has already performed the redirection to the +# logfile. # log() { - [[ -n $logfile ]] && echo "$@" >&2 + echo "$@" >&2 } # @@ -70,7 +73,7 @@ mkdir_fail=$(gettext "Unable to create the directory '%s'") mod_failed=$(gettext -n "Attempt to modify entries in '%s' failed!") -usage=$(gettext "usage: %s []") +usage=$(gettext "usage: %s [mini]") # # Output an internationalized string followed by a carriage return @@ -144,7 +147,7 @@ log " Installing \"$target\"" - [[ -a "$target" ]] && mv -f "$target" "$target.$tag" + mv -f "$target" "$target.$tag" 2>/dev/null if ! ln -s "$source" "$target"; then log "" @@ -238,35 +241,28 @@ # # The syntax is: # -# lx_init_zone [mini] +# lx_init_zone [mini] # # Where: # is the root of the zone directory to be modified # -# is the name of the log file to which error messages should -# be appended -# -# [mini] is an optional third argument that signifies whether this is +# [mini] is an optional second argument that signifies whether this is # to be a miniroot install; if it is, NFS services are not enabled # in the processed zone # unset is_miniroot unset install_root -unset logfile install_root="$1" -logfile="$2" tag="lxsave_$(date +%m.%d.%Y@%T)" -if (($# < 2 || $# > 3)); then +if (($# < 1 || $# > 2)); then i18n_echo "$usage" "$0" exit 1 fi -(($# == 3)) && is_miniroot=1 - -exec 2>>"$logfile" +(($# == 2)) && is_miniroot=1 if [[ ! -d "$install_root" ]]; then i18n_echo "$install_noroot" "$install_root" @@ -351,7 +347,7 @@ log "" log "Modifying \"$install_root/etc/fstab\"..." -[[ -a etc/fstab ]] && mv -f etc/fstab etc/fstab.$tag +mv -f etc/fstab etc/fstab.$tag 2>/dev/null cat > etc/fstab <<- EOF none / ufs defaults 1 1 @@ -403,7 +399,7 @@ # Attempt to save off the original inittab # before moving over the modified version. # - mv -f etc/inittab etc/inittab.$tag + mv -f etc/inittab etc/inittab.$tag 2>/dev/null mv -f $tmpfile etc/inittab @@ -447,8 +443,7 @@ log "" log "Modifying: \"$install_root/etc/sysconfig/network\"..." -[[ -a etc/sysconfig/network ]] && - mv -f etc/sysconfig/network etc/sysconfig/network.$tag +mv -f etc/sysconfig/network etc/sysconfig/network.$tag 2>/dev/null cat > etc/sysconfig/network <<- EOF NETWORKING="no" @@ -495,7 +490,7 @@ # Attempt to save off the original syslog before moving over # the modified version. # - mv -f etc/sysconfig/syslog etc/sysconfig/syslog.$tag + mv -f etc/sysconfig/syslog etc/sysconfig/syslog.$tag 2>/dev/null if ! mv -f $tmpfile etc/sysconfig/syslog; then log "mv of \"$tmpfile\" to" \ @@ -527,16 +522,14 @@ # /etc/rc.d/init.d/keytable tries to load a physical keyboard map, which won't # work in a zone. If we remove etc/sysconfig/keyboard, it won't try this at all. # -[[ -a etc/sysconfig/keyboard ]] && - mv -f etc/sysconfig/keyboard etc/sysconfig/keyboard.$tag +mv -f etc/sysconfig/keyboard etc/sysconfig/keyboard.$tag 2>/dev/null # # /etc/rc.d/init.d/gpm tries to configure the console mouse for cut-and-paste # text operations, which we don't support. Removing this file disables the # mouse configuration. # -[[ -a etc/sysconfig/mouse ]] && - mv -f etc/sysconfig/mouse etc/sysconfig/mouse.$tag +mv -f etc/sysconfig/mouse etc/sysconfig/mouse.$tag 2>/dev/null # # The following scripts attempt to start services or otherwise configure @@ -609,7 +602,7 @@ /./ {print skip $0}' etc/rc.d/init.d/halt > /tmp/halt.$$ if [[ $? -eq 0 ]]; then - mv -f etc/rc.d/init.d/halt etc/rc.d/init.d/halt.$tag + mv -f etc/rc.d/init.d/halt etc/rc.d/init.d/halt.$tag 2>/dev/null mv -f /tmp/halt.$$ etc/rc.d/init.d/halt chmod 755 etc/rc.d/init.d/halt else @@ -661,7 +654,7 @@ # Attempt to save off the original rc.sysinit # before moving over the modified version. # - mv -f etc/rc.d/rc.sysinit etc/rc.d/rc.sysinit.$tag + mv -f etc/rc.d/rc.sysinit etc/rc.d/rc.sysinit.$tag 2>/dev/null if ! mv -f $tmpfile etc/rc.d/rc.sysinit; then log "mv of \"$tmpfile\" to" \ diff -r 7a15930aae3c -r 61acf2c76fd6 usr/src/lib/brand/lx/zone/lx_install.ksh --- a/usr/src/lib/brand/lx/zone/lx_install.ksh Fri Sep 14 18:14:13 2007 -0700 +++ b/usr/src/lib/brand/lx/zone/lx_install.ksh Sat Sep 15 07:49:43 2007 -0700 @@ -84,6 +84,7 @@ no_install=$(gettext "Could not create install directory '%s'") no_log=$(gettext "Could not create log directory '%s'") +no_logfile=$(gettext "Could not create log file '%s'") install_zone=$(gettext "Installing zone '%s' at root directory '%s'") install_from=$(gettext "from archive '%s'") @@ -117,7 +118,7 @@ { typeset rootdir="$1" - if ! $branddir/lx_init_zone "$rootdir" "$logfile"; then + if ! $branddir/lx_init_zone "$rootdir"; then screenlog "$zone_initfail" "$zonename" return 1 fi @@ -467,7 +468,13 @@ logfile="${logdir}/$zonename.install.$$.log" -exec 2>"$logfile" +if ! > $logfile; then + screenlog "$no_logfile" "$logfile" + exit $int_code +fi + +# Redirect stderr to the log file to automatically log any error messages +exec 2>>"$logfile" # # From here on out, an unspecified exit or interrupt should exit with @@ -488,15 +495,23 @@ echo $(gettext "This process may take several minutes.") echo - ( cd "$install_root" && gtar "$gtaropts" "$install_src" && - $branddir/lx_init_zone "$install_root" "$logfile" && - init_tarzone "$install_root" ) + if ! ( cd "$install_root" && gtar "$gtaropts" "$install_src" ) ; then + log "Error: extraction from tar archive failed." + else + if ! [[ -d "${install_root}/bin" && + -d "${install_root}/sbin" ]]; then + log "Error: improper or incomplete tar archive." + else + $branddir/lx_init_zone "$install_root" && + init_tarzone "$install_root" - # - # Emit the same code from here whether we're interrupted or exiting - # normally. - # - int_code=$? + # + # Emit the same code from here whether we're + # interrupted or exiting normally. + # + int_code=$? + fi + fi if [[ $int_code -eq ZONE_SUBPROC_OK ]]; then log "Tar install completed for zone '$zonename' `date`."