#!/usr/bin/ksh # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # bos720 src/bos/diag/diags/diagsrv.sh 1.21 # # Licensed Materials - Property of IBM # # Restricted Materials of IBM # # COPYRIGHT International Business Machines Corp. 1996,2006 # All Rights Reserved # # US Government Users Restricted Rights - Use, duplication or # disclosure restricted by GSA ADP Schedule Contract with IBM Corp. # # IBM_PROLOG_END_TAG # @(#)02 1.21 src/bos/diag/diags/diagsrv.sh, diagsup, bos720 9/27/06 10:24:37 # # COMPONENT_NAME: CMDDIAG DIAGNOSTIC SUPERVISOR # # FUNCTIONS: Diagnostic Service Pretest and Boot Script # # ORIGINS: 27 # ################################################################### # This script is executed only when booting in Service Mode, # and will only execute on systems that support AIX # diagnostics. # # The diagsrv.sh script has the following command line options: # diagsrv [-b] | [device(s)] # # -b Boot diagnostics in service mode # No other flags recognized. # device Indicates device to pretest for install. # No other flags allowed. # # All sessions that run diagnostics on a device are performed in # no console mode. # # This script returns 1 if diagnostics detects a problem testing # the resource, 0 if there is no problem. A value of 2 is returned # if usage is incorrect. # ################################################################### # INSTALL_PRETEST () # This function runs the diagnostic pre-tests on installable # disk drives. # ################################################################### install_pretest () { SHOWLEDS=0 export SHOWLEDS for i in $* do uniquetype=`/usr/bin/odmget -q"name=$i" CuDv | /usr/bin/grep PdDvLn | /usr/bin/cut -f2 -d"\""` if [ -z "$uniquetype" ] then continue fi dtype=`echo $uniquetype | /usr/bin/cut -f3 -d"/"` dsclass=`echo $uniquetype | /usr/bin/cut -f2 -d"/"` dclass=`echo $uniquetype | /usr/bin/cut -f1 -d"/"` # skip disk pre-test for os disk. if [ "$dtype" = "osdisk" ] then continue fi da=`/usr/bin/odmget -q"DType=$dtype and DSClass=$dsclass and DClass=$dclass" \ PDiagDev | /usr/bin/grep -v "EnclDaName" | /usr/bin/grep DaName | /usr/bin/cut -f2 -d"\""` if [ -z "$da" ] then da=`/usr/bin/odmget -q"Uniquetype=$uniquetype" \ PDiagRes | /usr/bin/grep -v "EnclDaName" | /usr/bin/grep DaName | /usr/bin/cut -f2 -d"\""` fi if [ -f $DADIR/$da ] then $DIAGNOSTICS/bin/dctrl -c -d $i >/dev/null 2>&1 if [ $? -eq 1 ] then exit 1 fi fi done exit 0 } ################################################################### # PREPARE_64BIT_EXERCISER () # Prepare for running the 64-bit exerciser programs. # # The diag exerciser is supported only on Disk IPL ################################################################### prepare_64bit_exerciser() { if [ $DIAG_IPL_SOURCE -eq $IPLSOURCE_DISK ] then if [ $SYSTEMBIT -eq "64" ] then # Execute method to enable 64-bit execs, i.e. # the system exerciser. /etc/methods/cfg64 > /dev/console 2>&1 fi fi } ################################################################### # BOOT () # Service IPL boot function. # ################################################################### boot() { # Set up to trap interrupts ( INT, QUIT, TERM ) trap 'RESPAWN_FLAG=0' 2 3 15 # Execute the Diagnostic Controller with any parameters passed on RESPAWN_FLAG=1 while : do $DIAGNOSTICS/bin/Dctrl $* # if rc=201 then user hit to reset terminal and restart if [ $? -eq 201 ] then # Default terminal type TRM=`/usr/bin/tty` case $TRM in /dev/con* ) : ${TERM:=dumb};; /dev/tty* ) : ${TERM:=dumb};; /dev/lft* ) : ${TERM:=lft};; * ) : ${TERM:=dumb};; esac else if [ $RESPAWN_FLAG -eq 1 ]; then $shutDown_cmd fi fi RESPAWN_FLAG=1 done } ############################################################## ############################################################## # MAIN starts here ############################################################## ############################################################## ############################################################## # Now set up basic environment variables ############################################################## DIAGNOSTICS=/usr/lpp/diagnostics DADIR=$DIAGNOSTICS/da DIAGDATA=/etc/lpp/diagnostics DIAGDATADIR=$DIAGDATA/data DIAG_UTILDIR=$DIAGNOSTICS/bin DIAGX_SLIH_DIR=$DIAGNOSTICS/slih DIAGNOSTICS_TU_LIB=$DIAGNOSTICS/lib DIAG_KEY_POS=1 export DIAGNOSTICS DADIR DIAGDATA DIAGDATADIR export DIAG_UTILDIR DIAGX_SLIH_DIR export DIAG_KEY_POS DIAGNOSTICS_TU_LIB ############################################################## # Initialize ODM Object class repository path ############################################################## : ${ODMPATH:=/etc/objrepos:/usr/lib/objrepos} export ODMPATH ############################################################## # Initialize TERM to dumb. ############################################################## : ${TERM:=dumb} export TERM ############################################################## # Search path for the catalog files ############################################################## if [ "X$LANG" = "X" -o "$LANG" = "C" ]; then LANG=en_US fi NLSPATH=$DIAGNOSTICS/catalog/%L/%N:$DIAGNOSTICS/catalog/prime/%N:$NLSPATH export LANG NLSPATH ############################################################## # Search path for the shared libraries ############################################################## LIBPATH=/usr/lib:/lib:$DIAGNOSTICS/lib export LIBPATH ############################################################## # Determine the boot environment # At present, it is either DISK or LAN. ############################################################## IPLSOURCE_DISK=0 IPLSOURCE_CDROM=1 IPLSOURCE_TAPE=2 IPLSOURCE_LAN=3 BOOTYPE=`/usr/sbin/bootinfo -t` case $BOOTYPE in 1) DIAG_IPL_SOURCE=$IPLSOURCE_DISK;; 3) DIAG_IPL_SOURCE=$IPLSOURCE_CDROM;; 4) DIAG_IPL_SOURCE=$IPLSOURCE_TAPE;; 5) DIAG_IPL_SOURCE=$IPLSOURCE_LAN;; *) ;; esac export DIAG_IPL_SOURCE ############################################################## # Read and verify command line options ############################################################## BOOT_FLAG=0 NO_FLAG=1 cmdline="$*" set -- `/usr/bin/getopt "b" $*` >/dev/null 2>&1 # Check for invalid command line options if [ $? -ne 0 ] then exit 2 fi while [ "$1" != "--" ] do case $1 in "-b") BOOT_FLAG=1 NO_FLAG=0 ;; esac shift done ############################################################## # Determine what to do in case of error ############################################################## if [ $BOOT_FLAG -eq 1 ] ; then # Determine if running in a RAM filesystem environment. # Assuming that /dev/ram is mounted over /. # If so, and if NIM Diskless, then set flag to do a Halt # intead of shutdown when finished. If NIM Dataless, then # need to do shutdown. # # Initialize shutdown cmd shutDown_cmd="/usr/sbin/shutdown -F" # Use halt if NIM boot & Diskless if [ $DIAG_IPL_SOURCE -eq $IPLSOURCE_LAN ] then /usr/bin/df | /usr/bin/grep ram > /dev/null 2>&1 test $? = 0 && shutDown_cmd="/usr/sbin/halt -q" fi fi ############################################################## # Check to see if diagnostics can be run on this platform ############################################################## /usr/sbin/bootinfo -M >/dev/null 2>&1 if [ "$?" -ne 101 -a "$?" -ne 103 ] then /usr/bin/dspmsg -s 4 diagcd.cat 1 \ "\n\nThe 'diag' command is not supported on this system.\n\n" if [ $BOOT_FLAG -eq 1 ] ; then $shutDown_cmd fi exit 0 fi ############################################################## # Determine amount of memory in system ############################################################## # NIM Diagnostics cannot run in less than 64MB memory. MEMORY_SIZE=`/usr/sbin/bootinfo -r` if [ $MEMORY_SIZE -lt 65536 -a $DIAG_IPL_SOURCE -eq $IPLSOURCE_LAN ] ; then echo "\n\nNIM Diagnostics requires a minimum of 64MB memory to run.\n\n" if [ $BOOT_FLAG -eq 1 ] ; then $shutDown_cmd fi exit 0 fi ############################################################## # Set execution environment # The environment variable DIAG_ENVIRONMENT is initially # set to EXENV_IPL which indicates to the DA's that # diagnostic pre-test mode is set. # Once pretest() has run, or no pretest was specified, # then DIAG_ENVIRONMENT is set to # Standalone Diagnostics mode. ############################################################## EXENV_IPL=1 EXENV_STD=2 DIAG_ENVIRONMENT=$EXENV_IPL export DIAG_ENVIRONMENT ############################################################## # Do not allow escape to Shell from any SMIT menus ############################################################## SMIT_SHELL=n export SMIT_SHELL ############################################################## # The environment variable DIAG_DISKETTE is set to FALSE for # compatibility with old code. This environment variable is # not used any more. ############################################################## DIAG_DISKETTE=0 export DIAG_DISKETTE ############################################################## # Perform function depending on command line # If there were no flags, then must be INSTALL TEST ############################################################## if [ $NO_FLAG -eq 1 ] then install_pretest $cmdline fi ############################################################## # Get System Bit Mode ############################################################## SYSTEMBIT=`/usr/sbin/bootinfo -y` ############################################################## # If need to boot Diagnostics, then .... ############################################################## if [ $BOOT_FLAG -eq 1 ] then DIAG_ENVIRONMENT=$EXENV_STD export DIAG_ENVIRONMENT # # Determine TERM value if possible, for IPL boot mode. # TRM=`/usr/bin/tty` case $TRM in /dev/con* ) : ${TERM:=dumb};; /dev/tty* ) : ${TERM:=dumb};; /dev/lft* ) : ${TERM:=lft};; * ) : ${TERM:=dumb};; esac export TERM prepare_64bit_exerciser boot fi exit 0