#!/bin/sh # # mwchkos - check up the platform conformity to MainWin requirements # Copy of $MWHOME/bin/mwcheck_platform using the -os option # ### check arguments for -host option args="" host="" release="" mwrelease="" mwrelease_default="5.0.2" uname=`uname` all_perl="sparc_sunos5 hp700_ux11 i86_linux rs6000_aix4" while [ $# -gt 0 ] ;do case "$1" in -host) if [ $# -lt 2 ] ;then echo "***Error: missing host name after '-host'" exit 1 fi host="$2" shift 2 test=`echo $@|grep "\-oscheck"` if [ "$test" != "" ];then echo "" echo "Cannot use -host option with -oscheck flag." echo "" exit 1 fi ;; -mwrel|-mwrelease) if [ $# -lt 2 ] ;then echo "***Error: missing release number after '-mwrelease'" exit 1 fi release="$2" args="$args -mwrelease $release" shift 2;; *) args="$args $1" shift;; esac done self="$0" expr "$self" : "\/" >/dev/null || self="`pwd`/$self" # calculate full name dir=`dirname $self` selfname=`basename $self` if [ $uname = "Linux" ];then wc=/usr/bin/wc else wc=/bin/wc fi ### calculate the current release number if [ $release ];then found=0 supported=`grep "Supported release" $dir/../../sms/platform_requirements.csv 2>/dev/null | sed 's/Supported release\///' | sed 's/,//g'` if [ "$supported" = "" ];then #running on remote supported=`grep "Supported release" $dir/platform_requirements.csv 2>/dev/null | sed 's/Supported release\///' | sed 's/,//g'` fi support_release=`echo $supported|sed 's/||//g'` if [ "$support_release" = "" ];then found=1 fi for num in $support_release do if [ "$release" = "$num" ];then found=1 fi done if [ $found -eq 0 ];then echo "This tools does not support release number $release." echo "Supported releases: $supported" exit 1 fi else file="$MWHOME/lib-${MWOS}_optimized/libkernel32.$DLL_SUFFIX" if [ ! -r "$file" ] ;then file="$MWHOME/lib-${MWOS}_debug/libkernel32.$DLL_SUFFIX" fi if [ -r "$file" ] ;then mwrelease=`strings "$file" | awk '/^Mainwin version / {print $3; exit}'` elif [ -r ./mwversion ] ;then mwrelease=`head -1 ./mwversion` fi if [ "$mwrelease" ] ;then args="$args -mwrelease $mwrelease" else args="$args -mwrelease $mwrelease_default" fi fi ### Running on the given remote host ##################################### get_perl_name() { platform=$1 if [ $platform = "SunOS" ];then perl="mwperl-sparc_sunos5" elif [ $platform = "HP-UX" ];then perl="mwperl-hp700_ux11" elif [ $platform = "Linux" ];then perl="mwperl-i86_linux" elif [ $platform = "AIX" ];then perl="mwperl-rs6000_aix4" else perl="not suported" fi echo $perl } broken_rsh() { echo " ***Error: Cannot execute remote commands ($rsh) on the '$host' host. Please either set up the '$host' host to accept remote commands (consult your system administrator) or run $selfname locally on the '$host' host. " rm -f $tmpl exit 1 } broken_profile() { echo " ***Error: cannot use $rsh/rcp mechanism for running remotely. The common reason for rsh/rcp failure is some output produced by your private startup file (file .cshrc or .profile) which is located in your home directory on the remote machine. Get rid of any output produced by these files in non-interactive mode. Make sure that the following test commands run silently: # $rsh $host true || echo Failed # rcp /bin/wc ${host}:/dev/null || echo Failed Consult your system administrator. " rm -f $tmpl exit 1 } if [ "$host" ] ;then PATH=/bin:/usr/bin; export PATH if [ $uname = "HP-UX" ];then ## (it is 'remsh' on HPUX) rsh=remsh else rsh=rsh fi tmpl=/tmp/mwcheckplatform$$l ## temp local file tmpr=/tmp/mwcheckplatform$$r ## temp remote dir echo "Trying to contact '$host' host ..." echo "(if it hangs more than 10 seconds, just kill it by CTRL-C)" trap broken_rsh 1 2 3 15 $rsh "$host" -n true 2>&1 > $tmpl if [ $? -ne 0 ] ;then broken_rsh fi trap 1 2 3 15 if [ -s $tmpl ] ;then broken_profile fi trap broken_rsh 1 2 3 15 rcp $wc ${host}:/dev/null 2>&1 > $tmpl if [ $? -ne 0 ] ;then broken_profile fi trap 1 2 3 15 rm -f $tmpl echo "Succesfully contacted '$host' host" trap broken_rsh 1 2 3 15 $rsh "$host" -n mkdir $tmpr trap 1 2 3 15 if [ ! -f $dir/check_system.pl ] ;then dir="$dir/../../sms" if [ ! -f $dir/check_system.pl ] ;then echo "Cannot find SmartSetup Database" exit 1 fi fi cd $dir || exit 1 setup=../mw/setup-mwuser if [ ! -f "$setup" ] ;then setup=../setup-mwuser if [ ! -f "$setup" ] ;then setup=setup-mwuser fi fi files="$self $setup exec_sms kb_patchid.txt platform_requirements.csv solution-database.csv check_system.pl system.pm kb_systemid.txt sms_sysdef.pl" for file in $files do if [ ! -f $file ] ;then echo "Missing '$file' - cannot run on remote host" exit 1 fi done echo "Copying needed files to ${host}:$tmpr ..." trap broken_rsh 1 2 3 15 rcp $files ${host}:$tmpr if [ $? -ne 0 ] ;then echo "***Error: rcp to remote host '$host' failed" exit 1 fi trap 1 2 3 15 rname=`$rsh "$host" -n uname` perl=`get_perl_name $rname` if [ $perl = "not found" ];then echo "The platform $host $rname does not supported" exit -1 fi os=`echo $perl|sed 's/mwperl-//'` if [ ! -f $perl ] ;then perl=../mw/bin-${os}/mwperl if [ ! -f $perl ] ;then perl="" fi fi if [ "$perl" ] ;then trap broken_rsh 1 2 3 15 rcp $perl ${host}:$tmpr/mwperl-${os} if [ $? -ne 0 ] ;then echo "***Error: rcp to remote host '$host' failed" exit 1 fi trap 1 2 3 15 fi echo "Running '$selfname' remotely on '$host' host ..." trap broken_rsh 1 2 3 15 $rsh "$host" -n "env MWCC= MWCCPP= MWHOME= $tmpr/$selfname $args; /bin/rm -rf $tmpr" exit 0 fi ### running locally ###################################################### if [ ! -r /bin/ksh ]; then echo " needs /bin/ksh to run, please install ksh" echo "on Linux, this is a package called 'pdksh'" exit 1 fi # # ENV interferes with some versions of ksh, get rid of ENV # if [ ${ENV:-notset} != notset ]; then unset ENV fi PATH=/usr/sbin:$PATH # # do we run under a MainWin environment ? # if [ ${MWHOME:-notset} != notset ]; then exec mwperl ${MWHOME}/../sms/check_system.pl -os $args else if [ ! -f $dir/check_system.pl ] ;then dir="$dir/../../sms" if [ ! -f $dir/check_system.pl ] ;then echo "Cannot find SmartSetup Database" exit 1 fi fi cd "$dir" || exit 1 exec ./exec_sms check_system.pl -os $args fi ### the last line ########################################################