#!/bin/sh ############################################################################### ## ## DELL INC. PROPRIETARY INFORMATION ## ## This software is supplied under the terms of a license agreement or ## nondisclosure agreement with Dell Inc. and may not be copied or disclosed ## except in accordance with the terms of that agreement. ## ## Copyright (c) 2005 Dell Inc. All Rights Reserved. ## ## Abstract/Purpose: ## ## Environment: ## Linux ## ############################################################################### # Determine if the application has been launched from an xterm or XWindows [ -z "${TERM}" ] && TERM=vt100 case ${TERM} in nutc* | xterm* | ansi* | vt100* | screen*) # Do nothing ;; dumb* | linux*) [ -n "${DISPLAY}" ] && { tty --quiet || exec xterm +ls -e ${0} ${@} || ${0} ${@} } ;; *) exec xterm +ls -e ${0} ${@} ;; esac export PATH # works around problems with subshells typeset -r _SUU_APP_NAME="Server Update Utility" typeset -r _SUU_CMD_NAME=$(basename ${0}) typeset -r _SUU_CMD_WORKDIR=$(dirname ${0}) typeset -r _CURRDIR=${PWD} # width for console text output formatting which tput > /dev/null 2>&1 && _TMP_WIDTH=$(tput cols) which tput > /dev/null 2>&1 || _TMP_WIDTH=100 typeset -ri _WIDTH="${_TMP_WIDTH}" # Global constants - readonly variables typeset -ri _TRUE=0 typeset -ri _FALSE=1 typeset -ri _EXIT_DELAY=1 # gives customers a chance to read output # on temporary terminals typeset -ri _xx=0 # Global Variables typeset -i _SUU_GUI=${_FALSE} typeset -i _SUU_X_WINDOWS=${_FALSE} typeset -i _AUTORUN=${_FALSE} PROG_AVAILABLE=false # Prints a formatted message msgFmt() { typeset opts="" [ "$(echo -e)" != "-e" ] && opts="-e" typeset line="" for arg in "${@}"; do line=${line}${arg} done echo ${opts} "${line}" | fmt -s -w ${_WIDTH} } # Prints a formatted error message to stderr then exits false msgErr() { msgFmt "${_SUU_CMD_NAME} Error: \n" "${@}" >&2 exit -1 } # Function is the interrupted exit point for the script interruptScript() { exit ${1} } # Function is the common entry point for the script enterScript() { # Make sure all the dependencies are available on the system typeset -r _DEPS="fmt basename dirname tput sleep echo expr sleep" which ${_DEPS} >/dev/null 2>&1 || msgErr "Cannot find utilities on the system to execute SUU. " \ "Make sure the following utilities are in the path:\n\t${_DEPS}" } # Function is the common exit point for the script endScript() { typeset -i iRc=${?} sleep ${_EXIT_DELAY} trap '' EXIT PATH=${_OLD_PATH} export PATH exit ${iRc} } # Function checking for Package Dependency for running jre on 64 bit Linux platform checkJREDep() { JRE_RUN=false if [ -f /usr/X11R6/lib/libX11.so.6 -o -f /usr/lib/libX11.so.6 -o -f /usr/lib64/libX11.so.6 -o -f /usr/X11R6/lib64/libX11.so.6 ]; then JRE_RUN=true; else echo "Error: /usr/X11R6/lib/libX11.so.6 or /usr/lib/libX11.so.6 is required in order to run SUU." if [ -f /etc/redhat-release ]; then LIN_VER=`cat /etc/redhat-release | /usr/bin/awk '{print $7}'` if [ $LIN_VER = "4" ]; then echo "Please install xorg-x11-libs-6.8.1-23.EL.i386.rpm and Re-Run SUU again!" elif [ $LIN_VER = "3" ]; then echo "Please install XFree86-libs-4.3.0-35.EL.i386.rpm and Re-Run SUU again!" elif [ $LIN_VER = "4.92" ]; then echo "Please install libX11-1.0.3-3.fc6.rpm and Re-Run SUU again!" else echo "Error: Supported Linux Version is Red-Hat Linux ES 4/5 or Suse Linux 9/10" fi else if [ -f /etc/SuSE-release ]; then LIN_VER=`cat /etc/SuSE-release | awk '{print $5}'` if [ $LIN_VER = "9" -o $LIN_VER = "10" -o $LIN_VER = "11"]; then echo "Please Install xorg-x11-libs-6.8.1-23.EL.i386.rpm and Re-Run SUU again!" else echo "Error: Supported Linux Version is Red-Hat Linux ES 4/5 or Suse Linux 9/10/11" fi fi fi exit -1 fi if [ -f /usr/X11R6/lib/libXp.so.6 -o -f /usr/lib/libXp.so.6 ]; then JRE_RUN=true; else JRE_RUN=false; fi if [ -f /usr/X11R6/lib/libXtst.so.6 -o -f /usr/lib/libXtst.so.6 ]; then JRE_RUN=true; else JRE_RUN=false; fi if [ -f /lib/libpam.so.0 -o -f /usr/lib/libpam.so.0 ]; then JRE_RUN=true; else JRE_RUN=false; fi if [ -f /lib/libncurses.so.5 -o -f /usr/lib/libncurses.so.5 ]; then JRE_RUN=true; else JRE_RUN=false; fi LINUX_ARCH=`arch` if [ ${LINUX_ARCH} != x86_64 ] ; then if [ $JRE_RUN != true ]; then echo "Error: Some required 32-bit libraries are not installed. Please check the readme for the list of required rpms, install them and retry to run SUU." exit -1 fi fi } checkGUI() { [ -n "${DISPLAY}" ] && _SUU_X_WINDOWS=${_TRUE} if [ "${_SUU_X_WINDOWS}" = ${_FALSE} -a ${_SUU_GUI} = ${_TRUE} ] ; then msgErr "When using the \"-g\" or \"-gui\" options, the "\ "${_SUU_APP_NAME} must be run from within X Windows." fi _SUU_XHOST=${_TRUE} xhost 2>&1 | grep -i refused 2>&1 > /dev/null && _SUU_XHOST=${_FALSE} if [ ${_SUU_XHOST} = ${_FALSE} -a ${_SUU_GUI} = ${_TRUE} ] ; then msgErr "You do not have permission to attach to the X Windows "\ "display ${DISPLAY}" fi if [ $OS_BIT = "x86_64" -a ${_SUU_GUI} = ${_TRUE} ]; then checkJREDep fi if [ ${_SUU_GUI} = ${_FALSE} ]; then unset DISPLAY fi } checkPM() { #call SUUPMDataCollector mkdir -p /var/log/dell/suu rm -f /var/log/dell/suu/PMInfo.properties PM_AVAILABLE=false if [ $PROG_AVAILABLE = "false" ]; then ./dupdisneyinstall.sh install LD_LIBRARY_PATH=/opt/dell/dup/lib:/opt/dell/dup64/lib:/tmp/suutmp:$LD_LIBRARY_PATH export LD_LIBRARY_PATH ./PM/SUUPMDataCollector.bin 6 > /var/log/dell/suu/PMInfo.properties 2>/dev/null else echo "PMStatus=ON" >/var/log/dell/suu/PMInfo.properties echo "PMBrandStatus=DEBRAND" >>/var/log/dell/suu/PMInfo.properties echo "PMBrandName=">>/var/log/dell/suu/PMInfo.properties echo "PMDefaultBrandName=">>/var/log/dell/suu/PMInfo.properties echo "PMManufacturerName=">>/var/log/dell/suu/PMInfo.properties echo "PMLicense=true">>/var/log/dell/suu/PMInfo.properties fi #read the properties file . /var/log/dell/suu/PMInfo.properties CUSTOM_LOCN=/tmp/dell/suu/customization if [ $PMBrandStatus = "DEBRAND" -o $PMBrandStatus = "STRING_REBRAND" ]; then mkdir -p $CUSTOM_LOCN cp ./lib/debranded_images.jar $CUSTOM_LOCN > /dev/null 2>&1 PM_CLASSPATH=$CUSTOM_LOCN/debranded_images.jar elif [ $PMBrandStatus = "COMPLETE_REBRAND" ]; then if [ -f $PMDataLocation/suu/SUUCtrl.xml ]; then mkdir -p $CUSTOM_LOCN/etc/images mkdir -p $CUSTOM_LOCN/images cp $PMDataLocation/suu/startupScreen.JPG $CUSTOM_LOCN/etc/images > /dev/null 2>&1 cp $PMDataLocation/suu/suu_splash.gif $CUSTOM_LOCN/etc/images > /dev/null 2>&1 cp $PMDataLocation/suu/logo.gif $CUSTOM_LOCN/images > /dev/null 2>&1 mv $PMDataLocation/suu/SUUCtrl.xml $CUSTOM_LOCN > /dev/null 2>&1 PM_CLASSPATH=$CUSTOM_LOCN/ else mkdir -p $CUSTOM_LOCN cp ./lib/debranded_images.jar $CUSTOM_LOCN > /dev/null 2>&1 PM_CLASSPATH=$CUSTOM_LOCN/debranded_images.jar fi fi } setEnv() { _LINUX_ARCH=`arch` if [ ${_LINUX_ARCH} = x86_64 -a -d ${_SUU_CMD_WORKDIR}/java/linux/x86_64 ] ; then _JAVA_PATH=${_SUU_CMD_WORKDIR}/java/linux/x86_64/bin else _JAVA_PATH=${_SUU_CMD_WORKDIR}/java/linux/i386/bin fi _SUU_ETC=${_SUU_CMD_WORKDIR}/etc _JAVA_LIB=${_SUU_CMD_WORKDIR}/lib _JAVA_APP=com.dell.suu.app.SUUMain _OLD_PATH=${PATH} _APP_NAME=-Dapp.name=DellSUU _APP_COMMAND=-Dapp.cmd=${0} _APP_AUTORUN=-Dapp.autorun=${_AUTORUN} _APP_HOME=-Dapp.home=${_SUU_CMD_WORKDIR}/ _APP_DEBUG_OPTIONS=-DdebugEnabled=false _SUU_PATH=${_SUU_CMD_WORKDIR}/bin/Linux _JAVA_LOGGING=-Djava.util.logging.config.file=suuapp.properties CLASSPATH=${PM_CLASSPATH}:${_SUU_CMD_WORKDIR}/:${_SUU_ETC}:${_SUU_ETC}/guiproperties:${_JAVA_LIB}/DellSUU.jar:${_JAVA_LIB}/xercesImpl.jar:${_JAVA_LIB}/xml-apis.jar:${_JAVA_LIB}/OMCF.jar:${_JAVA_LIB}/images.jar export CLASSPATH # Copy bc utility mkdir -p /tmp mkdir -p /tmp/suutmp cp ${_SUU_PATH}/bc /tmp/suutmp if [ -f /tmp/suutmp/libreadline.so.5 -o -f /tmp/suutmp/libreadline.so.4 ] ; then echo "" else if [ ${_LINUX_ARCH} = x86_64 -a -d ${_SUU_CMD_WORKDIR}/java/linux/x86_64 ] ; then cp ${_SUU_PATH}/libreadline.so.5 /tmp/suutmp else cp ${_SUU_PATH}/libreadline.so.4 /tmp/suutmp fi fi LD_LIBRARY_PATH=/opt/dell/dup/lib:/tmp/suutmp:$LD_LIBRARY_PATH export LD_LIBRARY_PATH PATH=${_JAVA_PATH}:${_SUU_PATH}:${PATH}:/tmp/suutmp export PATH umask 022 } appendOption(){ if [ -z "${_SUU_OPTIONS}" ] ; then _SUU_OPTIONS="${@}" else _SUU_OPTIONS="${_SUU_OPTIONS} ${@}" fi } checkCompatibility() { _LINUX_ARCH=`arch` # 64BIT SUU is not supported on 32Bit arch if [ -d ${_SUU_CMD_WORKDIR}/java/linux/x86_64 -a ${_LINUX_ARCH} != x86_64 ] ; then msgErr "SUU does not support this OS Architecture. Please run Server Update Utility which supports this Architecture." fi } ############################################################################### # Main() Script ############################################################################### # Handle Abnormal exit conditions trap "endScript" EXIT trap "interruptScript 99" HUP INT QUIT BUS SEGV PIPE TERM # 1 2 3 10 11 13 15 checkCompatibility enterScript pathlength=`echo $_CURRDIR | sed -e "s/^ //g" | sed -e "s/ $//g" | wc -c` if [ $pathlength -gt 4096 ] ; then echo "The length of the path from which SUU is running has exceeded 4096 characters which is the maximum path length allowed by your operating system. Run SUU from another location where the length of the path is less than 4096 characters." exit -1 fi #check if OS is 64 bit type for JRE Migration OS_BIT=`uname -p` while [ -n "${1}" ]; do case "${1}" in -g | -gui) _SUU_GUI=${_TRUE} appendOption "${1}" shift ;; -iprog | -inventoryprogress) PROG_AVAILABLE="true" appendOption "${1}" shift ;; -d | -directory) _SUU_LOG_OPTION="${1}" _SUU_LOG_DIR="${2}" [ -z "${_SUU_LOG_DIR}" ] && msgErr "A directory name must be specified when using the "\ "\"-d\" or \"-directory\" options." _CHECK_ROOT=`echo $_SUU_LOG_DIR | grep [^/]` [ "$_CHECK_ROOT" = "" ] && msgErr "The ROOT directory \"/\" cannot be used for logging." [ -h "${_SUU_LOG_DIR}" ] && msgFmt "Warning: Security risk, log file directory "\ "\"${_SUU_LOG_DIR}\" is a symbolic link." shift 2 ;; -autorun) _AUTORUN=${_TRUE} shift ;; *) # default appendOption "${1}" shift ;; esac done checkGUI checkPM setEnv if [ -z "${_SUU_LOG_DIR}" ] ; then if [ -f /etc/vmware-release ]; then ${_JAVA_PATH}/java -Xmx1024M ${_APP_NAME} ${_APP_HOME} ${_APP_AUTORUN} ${_APP_COMMAND} ${_APP_DEBUG_OPTIONS} ${_JAVA_LOGGING} ${_JAVA_APP}\ ${_SUU_OPTIONS} ${_SUU_LOG_OPTION} else ${_JAVA_PATH}/java ${_APP_NAME} ${_APP_HOME} ${_APP_AUTORUN} ${_APP_COMMAND} ${_APP_DEBUG_OPTIONS} ${_JAVA_LOGGING} ${_JAVA_APP}\ ${_SUU_OPTIONS} ${_SUU_LOG_OPTION} fi else if [ -f /etc/vmware-release ]; then ${_JAVA_PATH}/java -Xmx1024M ${_APP_NAME} ${_APP_HOME} ${_APP_AUTORUN} ${_APP_COMMAND} ${_APP_DEBUG_OPTIONS} ${_JAVA_LOGGING} ${_JAVA_APP}\ ${_SUU_OPTIONS} ${_SUU_LOG_OPTION} "${_SUU_LOG_DIR}" else ${_JAVA_PATH}/java ${_APP_NAME} ${_APP_HOME} ${_APP_AUTORUN} ${_APP_COMMAND} ${_APP_DEBUG_OPTIONS} ${_JAVA_LOGGING} ${_JAVA_APP}\ ${_SUU_OPTIONS} ${_SUU_LOG_OPTION} "${_SUU_LOG_DIR}" fi fi rm -f $CUSTOM_LOCN/SUUCtrl.xml if [ $PROG_AVAILABLE = "false" ]; then ./dupdisneyinstall uninstall 2>/dev/null fi PATH=${_OLD_PATH} export PATH