#!/bin/sh
#-----------------------------------------------------------------------
#
# VISIT-INSTALL-CLOSED - Install the visit distributions on the closed
#                        network.
#
# Author: Eric Brugger
# Date:   February 12, 2001
#
# Usage:
#    visit-install-closed [-beta | -private | -public] -v <version>
#
#-----------------------------------------------------------------------

test=no

user=`whoami`

#
# Parse the execute line, providing default values for error checking.
#
hitit=true
sunset=true
warp=false
sc=true
tidalwave=true
white=true
emperor=true

ver=undefined
verflag=-private

#
# The loop is executed once for each symbol on the execute line.  This means
# that $1 may be blank for later executions of the loop if any "shift 2"
# commands are executed.  The variable abc is not used in the loop.
#
for abc
do
   case $1 in
      -none)
         hitit=false
         sunset=false
         warp=false
         sc=false
         tidalwave=false
         white=false
         emperor=false
         shift
         ;;
      +bdiv)
         hitit=true
         sunset=true
         shift
         ;;
      +lc)
         sc=true
         tidalwave=true
         white=true
         emperor=true
         shift
         ;;
      -hitit)
         hitit=false
         shift
         ;;
      +hitit)
         hitit=true
         shift
         ;;
      -sunset)
         sunset=false
         shift
         ;;
      +sunset)
         sunset=true
         shift
         ;;
      -warp)
         warp=false
         shift
         ;;
      +warp)
         warp=true
         shift
         ;;
      -sc)
         sc=false
         shift
         ;;
      +sc)
         sc=true
         shift
         ;;
      -tidalwave)
         tidalwave=false
         shift
         ;;
      +tidalwave)
         tidalwave=true
         shift
         ;;
      -white)
         white=false
         shift
         ;;
      +white)
         white=true
         shift
         ;;
      -emperor)
         emperor=false
         shift
         ;;
      +emperor)
         emperor=true
         shift
         ;;
      -v)
         ver=$2
         shift 2
         ;;
      -beta)
         verflag=-beta
         shift
         ;;
      -private)
         verflag=-private
         shift
         ;;
      -public)
         verflag=
         shift
         ;;
   esac
done

#
# Check that the version was provided.
#
if [ $ver = undefined ]
then
   echo "Usage: [-beta | -private | -public] [-none] [-<machine name>] -v <version>"
   exit
fi

#
# Check that the visit install script is present.
#
if [ ! -e visit-install ]
then
   echo "visit-install is missing."
   exit
fi

ver2=`echo $ver | tr "." "_"`
ver=`echo $ver2 | tr "_" "."`

#
# Create the header for the install script for the B Division network.
#
rm -f bdiv
cat <<EOF > bdiv
#!/bin/sh

rm -f resultlog
touch resultlog
EOF

#
# Install on hitit.
#
rm -f hitit
cat <<EOF > hitit

./visit-install -r -private -c closed -g visit -gw -l $ver linux /usr/gapps/visit > installlog 2>&1
echo ""                                            >> resultlog 2>&1
echo "        install of visit on hitit"           >> resultlog 2>&1
echo "       ---------------------------"          >> resultlog 2>&1
echo ""                                            >> resultlog 2>&1
df -k /usr/gapps/visit                             >> resultlog 2>&1
echo ""                                            >> resultlog 2>&1
ls -l /usr/gapps/visit/$ver/linux-intel/bin        >> resultlog 2>&1
echo ""                                            >> resultlog 2>&1
echo "number of database plugins = "\`ls /usr/gapps/visit/$ver/linux-intel/plugins/databases/libI* | wc -l\` >> resultlog 2>&1
echo "number of operator plugins = "\`ls /usr/gapps/visit/$ver/linux-intel/plugins/operators/libI* | wc -l\` >> resultlog 2>&1
echo "number of plot plugins = "\`ls /usr/gapps/visit/$ver/linux-intel/plugins/plots/libI* | wc -l\` >> resultlog 2>&1
echo ""                                            >> resultlog 2>&1
echo "The database plugins:"                       >> resultlog 2>&1
ls /usr/gapps/visit/$ver/linux-intel/plugins/databases/libI* | sed "s/\/usr\/gapps\/visit\/$ver\/linux-intel\/plugins\/databases\/libI//" | sed "s/Database.so//" >> resultlog 2>&1
EOF

if [ $hitit = true ]
then
   if [ $test = no ]
   then
      cat hitit >> bdiv

      scp -P 22 hitit:/gscratch/$user/hitit/visitbuild/visit$ver2.linux.tar.gz .
      scp -P 22 visit$ver2.linux.tar.gz sunset:
   fi
fi

#
# Install on sunset.
#
rm -f sunset
cat <<EOF > sunset

./visit-install -private -c closed -g visit -gw -l $ver sunos5 /usr/gapps/visit > installlog 2>&1
echo ""                                            >> resultlog 2>&1
echo "        install of visit on sunset"          >> resultlog 2>&1
echo "       ----------------------------"         >> resultlog 2>&1
echo ""                                            >> resultlog 2>&1
df -k /usr/gapps/visit                             >> resultlog 2>&1
echo ""                                            >> resultlog 2>&1
ls -l /usr/gapps/visit/$ver/sun4-sunos5-sparc/bin  >> resultlog 2>&1
echo ""                                            >> resultlog 2>&1
echo "number of database plugins = "\`ls /usr/gapps/visit/$ver/sun4-sunos5-sparc/plugins/databases/libI* | wc -l\` >> resultlog 2>&1
echo "number of operator plugins = "\`ls /usr/gapps/visit/$ver/sun4-sunos5-sparc/plugins/operators/libI* | wc -l\` >> resultlog 2>&1
echo "number of plot plugins = "\`ls /usr/gapps/visit/$ver/sun4-sunos5-sparc/plugins/plots/libI* | wc -l\` >> resultlog 2>&1
echo ""                                            >> resultlog 2>&1
echo "The database plugins:"                       >> resultlog 2>&1
ls /usr/gapps/visit/$ver/sun4-sunos5-sparc/plugins/databases/libI* | sed "s/\/usr\/gapps\/visit\/$ver\/sun4-sunos5-sparc\/plugins\/databases\/libI//" | sed "s/Database.so//" >> resultlog 2>&1
EOF

if [ $sunset = true ]
then
   if [ $test = no ]
   then
      cat sunset >> bdiv

      scp -P 22 sunset:/export/scratch/$user/sunset/visitbuild/visit$ver2.sunos5.tar.gz .
      scp -P 22 visit$ver2.sunos5.tar.gz sunset:
   fi
fi

#
# Install on warp.
#
rm -f warp
cat <<EOF > warp

./visit-install $verflag -c closed -g visit -gw -l $ver irix6 /usr/gapps/visit > installlog 2>&1
echo ""                                            >> resultlog 2>&1
echo "        install of visit on warp"            >> resultlog 2>&1
echo "       --------------------------"           >> resultlog 2>&1
echo ""                                            >> resultlog 2>&1
df -k /usr/gapps/visit                             >> resultlog 2>&1
echo ""                                            >> resultlog 2>&1
ls -l /usr/gapps/visit/$ver/sgi-irix6-mips2/bin    >> resultlog 2>&1
echo ""                                            >> resultlog 2>&1
echo "number of database plugins = "\`ls /usr/gapps/visit/$ver/sgi-irix6-mips2/plugins/databases/libI* | wc -l\` >> resultlog 2>&1
echo "number of operator plugins = "\`ls /usr/gapps/visit/$ver/sgi-irix6-mips2/plugins/operators/libI* | wc -l\` >> resultlog 2>&1
echo "number of plot plugins = "\`ls /usr/gapps/visit/$ver/sgi-irix6-mips2/plugins/plots/libI* | wc -l\` >> resultlog 2>&1
echo ""                                            >> resultlog 2>&1
echo "The database plugins:"                       >> resultlog 2>&1
ls /usr/gapps/visit/$ver/sgi-irix6-mips2/plugins/databases/libI* | sed "s/\/usr\/gapps\/visit\/$ver\/sgi-irix6-mips2\/plugins\/databases\/libI//" | sed "s/Database.so//" >> resultlog 2>&1
EOF

if [ $warp = true ]
then
   if [ $test = no ]
   then
      cat warp >> bdiv

      scp tidalwave:/fc/san1/$user/tidalwave/visitbuild/visit$ver2.irix6.tar.gz .
      scp -P 22 visit$ver2.irix6.tar.gz sunset:
   fi
fi

#
# Install on the B Division network.
#
if [ $test = no ]
then
   scp -P 22 visit-install sunset:
   scp -P 22 bdiv sunset:bdiv_install
   ssh -p 22 sunset "chmod 750 bdiv_install;./bdiv_install"
fi

#
# Create the header for the install script for the lc machines.
#
rm -f lc
cat <<EOF > lc
#!/bin/sh

rm -f resultlog
touch resultlog
EOF

#
# Install on sc.
#
rm -f sc
cat <<EOF > sc

./visit-install -r -private -c closed -g visit -gw -l $ver osf1 /usr/gapps/visit > installlog 2>&1
echo ""                                            >> resultlog 2>&1
echo "        install of visit on sc"              >> resultlog 2>&1
echo "       ------------------------"             >> resultlog 2>&1
echo ""                                            >> resultlog 2>&1
df -k /usr/gapps/visit                             >> resultlog 2>&1
echo ""                                            >> resultlog 2>&1
ls -l /usr/gapps/visit/$ver/dec-osf1-alpha/bin     >> resultlog 2>&1
echo ""                                            >> resultlog 2>&1
echo "number of database plugins = "\`ls /usr/gapps/visit/$ver/dec-osf1-alpha/plugins/databases/libI* | wc -l\` >> resultlog 2>&1
echo "number of operator plugins = "\`ls /usr/gapps/visit/$ver/dec-osf1-alpha/plugins/operators/libI* | wc -l\` >> resultlog 2>&1
echo "number of plot plugins = "\`ls /usr/gapps/visit/$ver/dec-osf1-alpha/plugins/plots/libI* | wc -l\` >> resultlog 2>&1
echo ""                                            >> resultlog 2>&1
echo "The database plugins:"                       >> resultlog 2>&1
ls /usr/gapps/visit/$ver/dec-osf1-alpha/plugins/databases/libI* | sed "s/\/usr\/gapps\/visit\/$ver\/dec-osf1-alpha\/plugins\/databases\/libI//" | sed "s/Database.so//" >> resultlog 2>&1
EOF

if [ $sc = true ]
then
   if [ $test = no ]
   then
      cat sc >> lc

      scp sc1:/nfs/tmp3/$user/sc/visitbuild/visit$ver2.osf1.tar.gz .
      scp visit$ver2.osf1.tar.gz sc1:
   fi
fi

#
# Install on tidalwave.
#
rm -f tidalwave
cat <<EOF > tidalwave

./visit-install -private -c closed -g visit -gw -l $ver irix6 /usr/gapps/visit > installlog 2>&1
echo ""                                            >> resultlog 2>&1
echo "        install of visit on tidalwave"       >> resultlog 2>&1
echo "       -------------------------------"      >> resultlog 2>&1
echo ""                                            >> resultlog 2>&1
df -k /usr/gapps/visit                             >> resultlog 2>&1
echo ""                                            >> resultlog 2>&1
ls -l /usr/gapps/visit/$ver/sgi-irix6-mips2/bin    >> resultlog 2>&1
echo ""                                            >> resultlog 2>&1
echo "number of database plugins = "\`ls /usr/gapps/visit/$ver/sgi-irix6-mips2/plugins/databases/libI* | wc -l\` >> resultlog 2>&1
echo "number of operator plugins = "\`ls /usr/gapps/visit/$ver/sgi-irix6-mips2/plugins/operators/libI* | wc -l\` >> resultlog 2>&1
echo "number of plot plugins = "\`ls /usr/gapps/visit/$ver/sgi-irix6-mips2/plugins/plots/libI* | wc -l\` >> resultlog 2>&1
echo ""                                            >> resultlog 2>&1
echo "The database plugins:"                       >> resultlog 2>&1
ls /usr/gapps/visit/$ver/sgi-irix6-mips2/plugins/databases/libI* | sed "s/\/usr\/gapps\/visit\/$ver\/sgi-irix6-mips2\/plugins\/databases\/libI//" | sed "s/Database.so//" >> resultlog 2>&1
EOF

if [ $tidalwave = true ]
then
   if [ $test = no ]
   then
      cat tidalwave >> lc

      scp tidalwave:/fc/san1/$user/tidalwave/visitbuild/visit$ver2.irix6.tar.gz .
      scp visit$ver2.irix6.tar.gz sc1:
   fi
fi

#
# Install on white.
#
rm -f white
cat <<EOF > white

./visit-install -private -c closed -g visit -gw -l $ver aix /usr/gapps/visit > installlog 2>&1
echo ""                                            >> resultlog 2>&1
echo "        install of visit on white"           >> resultlog 2>&1
echo "       ---------------------------"          >> resultlog 2>&1
echo ""                                            >> resultlog 2>&1
df -k /usr/gapps/visit                             >> resultlog 2>&1
echo ""                                            >> resultlog 2>&1
ls -l /usr/gapps/visit/$ver/ibm-aix-pwr/bin        >> resultlog 2>&1
echo ""                                            >> resultlog 2>&1
echo "number of database plugins = "\`ls /usr/gapps/visit/$ver/ibm-aix-pwr/plugins/databases/libI* | wc -l\` >> resultlog 2>&1
echo "number of operator plugins = "\`ls /usr/gapps/visit/$ver/ibm-aix-pwr/plugins/operators/libI* | wc -l\` >> resultlog 2>&1
echo "number of plot plugins = "\`ls /usr/gapps/visit/$ver/ibm-aix-pwr/plugins/plots/libI* | wc -l\` >> resultlog 2>&1
echo ""                                            >> resultlog 2>&1
echo "The database plugins:"                       >> resultlog 2>&1
ls /usr/gapps/visit/$ver/ibm-aix-pwr/plugins/databases/libI* | sed "s/\/usr\/gapps\/visit\/$ver\/ibm-aix-pwr\/plugins\/databases\/libI//" | sed "s/Database.so//" >> resultlog 2>&1
EOF

if [ $white = true ]
then
   if [ $test = no ]
   then
      cat white >> lc

      scp white:/p/gw1/$user/white/visitbuild/visit$ver2.aix.tar.gz .
      scp visit$ver2.aix.tar.gz sc1:
   fi
fi

#
# Install on emperor.
#
rm -f emperor
cat <<EOF > emperor

./visit-install $verflag -c closed -g visit -gw -l $ver linux /usr/gapps/visit > installlog 2>&1
echo ""                                            >> resultlog 2>&1
echo "        install of visit on emperor"         >> resultlog 2>&1
echo "       -----------------------------"        >> resultlog 2>&1
echo ""                                            >> resultlog 2>&1
df -k /usr/gapps/visit                             >> resultlog 2>&1
echo ""                                            >> resultlog 2>&1
ls -l /usr/gapps/visit/$ver/linux-intel/bin        >> resultlog 2>&1
echo ""                                            >> resultlog 2>&1
echo "number of database plugins = "\`ls /usr/gapps/visit/$ver/linux-intel/plugins/databases/libI* | wc -l\` >> resultlog 2>&1
echo "number of operator plugins = "\`ls /usr/gapps/visit/$ver/linux-intel/plugins/operators/libI* | wc -l\` >> resultlog 2>&1
echo "number of plot plugins = "\`ls /usr/gapps/visit/$ver/linux-intel/plugins/plots/libI* | wc -l\` >> resultlog 2>&1
echo ""                                            >> resultlog 2>&1
echo "The database plugins:"                       >> resultlog 2>&1
ls /usr/gapps/visit/$ver/linux-intel/plugins/databases/libI* | sed "s/\/usr\/gapps\/visit\/$ver\/linux-intel\/plugins\/databases\/libI//" | sed "s/Database.so//" >> resultlog 2>&1
EOF
 
if [ $emperor = true ]
then
   if [ $test = no ]
   then
      cat emperor >> lc

      scp emperor0:/usr/tmp/$user/emperor/visitbuild/visit$ver2.linux.tar.gz .
      scp visit$ver2.linux.tar.gz sc1:
   fi
fi

#
# Install on the lc machines.
#
if [ $test = no ]
then
   scp -P 22 visit-install sc1:
   scp -P 22 lc sc1:lc_install
   ssh -p 22 sc1 "chmod 750 lc_install;./lc_install"
fi

#
# Clean up.
#
if [ $test = no ]
then
   rm -f bdiv hitit sunset lc warp sc tidalwave white emperor
fi
