#!/usr/bin/ksh -p
# 
# @HP_COPYRIGHT@
#
# HISTORY
# $NOHISTORY:$
# $EndNOHISTORY$
# 
# @(#)$RCSfile: upgrade_check,v $ $Revision: 1.12 $ (HP) $Date: 2004/04/21 19:38:37 $
#

# Make sure the locale is C so that the various regexps
# within the tests work as expected.
OLD_LC_ALL=$LC_ALL
OLD_LANG=$LC_LANG
LC_ALL=C
LANG=C
export LC_ALL LANG

# We'll override the default dbcheck log file.
# Use our own default, or a user supplied one.
if [ $# -eq 0 ] ; then

  # Default log file for upgrade_check
  logfile=/var/sra/adm/log/InstallSC/upgrade_check.log

elif [ $# -eq 1 ] && [ $1 != "-help" ] ; then

  # User supplied log file name
  logfile=$1

else

  # Anything else is an error.
  print -u2 "Usage: $0 [logfile]"
  exit 1

fi

# Make sure we're running as root.
if [ $USER != root ] ; then
  print -u2 "Must be run by root"

  exit 2
fi

# Check if we're running on a management server.
# It may be a node acting as an MS.  That's OK.
# It may be a cluster.  That's OK.
MS=`rcmgr get SC_MS`
if [ "x$MS" = "x" ] ; then

  print -u2 "SC_MS not found by rcmgr.  This variable must be set to the name"
  print -u2 "of the management server."
  exit 3

elif [ `hostname` != $MS ] ; then

  # Hostname is not the same as MS name.
  # Check the cluster alias.
  CLU_ALIAS=`clu_get_info -raw 2> /dev/null | awk -F : '/^C/ {print $2}'`

  if [ "x$CLU_ALIAS" != "x$MS" ] ; then

    print -u2 "We don't seem to be on a management server."
    print -u2 "Is the rcmgr variable SC_MS set correctly?"
    exit 3

  fi
fi


# Check for the test and description directories.
# This test may not work if the directory where the script lives is
# in the path and the script is run like a command (without absolute
# or relative path).

dir=`dirname $0`
if ! [[ -d ${dir}/preinst_check  &&  -d ${dir}/preinst_desc ]] ; then
  print -u2 "Could not find required directories."
  print -u2 "Place this script in the same directory as preinst_check/"
  print -u2 "and preinst_desc/ and run from there."

  exit 4
fi

print "This script will run some tests to see if your AlphaServer SC system"
print "is ready to be upgraded.  It must be run by root from the management"
print "server, or from node 0, if no management server is available."
print ""
print "The tests cover a wide range of system configuration and status"
print "conditions that are likely to cause problems in the upgrade process,"
print "but it cannot test for all possible errors.  Please see section"
print "4.2 of the HP AlphaServer SC Installation Guide for information on"
print "what this script will test for and what you must still check manually,"
print "and on the conditions necessary before you can upgrade your system."
print ""
print "Results of the tests are written to standard out.  In addition, a log"
print "of what upgrade_check does when performing the tests is written to "
print "$logfile."
print ""
print "The following tests will be run:"
print "Test #1:  Check for ADVFS-UTILS license"
print "Test #2:  Check that the root file domain uses the UNIX disk"
print "Test #3:  Check that /, /usr, and /var have 50% or greater capacity "
print "Test #4:  Check that all nodes are booted to multiuser mode"
print "Test #5:  Check that scfs and pfs file systems are offline"
print "Test #6:  Check that the root password is the same on all nodes"
read  foo?"--more--"
print "Test #7:  Check for the RIS-RSH problem"
print "Test #8:  Check for ethernet MAC addresses in MS's /etc/bootptab "
print "Test #9:  Check that the generic boot disk is not used in any AdvFS domain"
print "Test #10: Check that WEBES is not installed"
print "Test #11: Check for default routes"
print "Test #12: Check for typical inetd services"
print "Test #13: Check the database version"
print "Test #14: Check that EVM is running properly"
print "Test #15: Check that /etc/sia is not a CDSL"
print "Test #16: Check that the database is visible to all nodes"
print "Test #17: Check the node and expected votes of all domains"
print "Test #18: Check the OS version"
print "Test #19: Check clu_upgrade check setup returns success"
print "Test #20: Check the UNIX disk"
print "Test #21: Check whether RIS is installed on the MS"
print "Test #22: Check for SC-specific UNIX accounting"
print "Test #23: Check that /sys/BINARY and /usr/sys/BINARY are directories"
print "Test #24: Check all AdvFS domains for multiple volumes"
print "Test #25: Check that all external network interfaces are in the databsae"
print "Test #26: Check that all management adapters have a mode of FastFD"
print "Test #27: Check that CLUA_PASSIVE, CLUAMRG_ROUTE_ARGS, and GATED_FLAGS"
print "          have not been set in the rc.config file"
print "Test #28: Check if any World Wide Language Support subsets have"
print "          been installed"

print ""
read foo?"Press <Enter> to start the tests."
print ""

print "Starting tests.  This may take a while."
print ""

${dir}/dbcheck/dbcheck -tdir ${dir}/preinst_check \
	       -ddir ${dir}/preinst_desc \
	       -edir ${dir}/dbcheck \
               -log $logfile | \
    sed -e '/^fix:.*$/d' -e 's/^other:/additional info:/'

# Put things back the way we found them
LC_ALL=$OLD_LC_ALL
LC_LANG=$OLD_LANG
export LC_ALL LANG





