#!/bin/sh ############################################################################### # # # iTOUGH2 installation script for Unix (S. Finsterle, May 2002) # # ==================================== # # # # Make it2install executable (type: chmod a+x it2install) # # Type ./it2install and follow instructions. # # # # In case of difficulties, read instructions in file read.me # # or send e-mail to SAFinsterle@lbl.gov # # # ############################################################################### # INSTALLDIR=$HOME/itough2v6.0 # STARTDIR=`pwd` EXTRACTDIR=$STARTDIR DIROK=YesOfCourse OVERWRITE=NoWay PRINTREADME=WhyNot IT2TAR=it*2*.tar echon=`/bin/echo -n | grep -c n` /bin/echo /bin/echo '*******************************************************************************' /bin/echo '* it2install it2install it2install it2install it2install it2install *' /bin/echo '*******************************************************************************' /bin/echo Logfile of iTOUGH2 installation script $STARTDIR/it2install > $HOME/it2install.log 2>&1 /bin/echo Date: `date` >> $HOME/it2install.log 2>&1 /bin/echo "* iTOUGH2 installation directory is: $INSTALLDIR" case $echon in 0) /bin/echo -n '* OK [Y*/N]? ' ;; *) /bin/echo '* OK [Y*/N]? \c' ;; esac read DIROK if [ -n "`/bin/echo $DIROK | grep -i 'n'`" ] then case $echon in 0) /bin/echo -n '* Provide new FULL path to iTOUGH2 installation directory: ' ;; *) /bin/echo '* Provide new FULL path to iTOUGH2 installation directory: \c' ;; esac read INSTALLDIR fi SEPARATORTEST=`/bin/echo $INSTALLDIR | grep '#'` if [ -d $INSTALLDIR ] || [ -f $INSTALLDIR ] || [ -n "$SEPARATORTEST" ] then /bin/echo "*" /bin/echo "* iTOUGH2 installation directory $INSTALLDIR already exists." case $echon in 0) /bin/echo -n '* Do you want to overwrite it [Y/N*]? ' ;; *) /bin/echo '* Do you want to overwrite it [Y/N*]? \c' ;; esac read OVERWRITE fi while [ ! -n "`/bin/echo $OVERWRITE | grep -i 'y'`" ] && \ ( [ ! -n "$INSTALLDIR" ] || [ -d "$INSTALLDIR" ] || [ -f "$INSTALLDIR" ] || [ -n "$SEPARATORTEST" ] ) do /bin/echo "* iTOUGH2 installation directory $INSTALLDIR already exists." case $echon in 0) /bin/echo -n '* Provide new FULL path to iTOUGH2 installation directory: ' ;; *) /bin/echo '* Provide new FULL path to iTOUGH2 installation directory: \c' ;; esac read INSTALLDIR SEPARATORTEST=`/bin/echo $INSTALLDIR | grep '#'` done # create the directory if [ ! -d $INSTALLDIR ] || [ ! -f $INSTALLDIR ] then mkdir -p $INSTALLDIR >> $HOME/it2install.log 2>&1 fi /bin/echo "Installation directory: $INSTALLDIR" >> $HOME/it2install.log 2>&1 while [ `ls $EXTRACTDIR | grep -i tar | grep -i -c it` -eq 0 ] do /bin/echo "*" /bin/echo "* No distribution file $IT2TAR* found in directory $EXTRACTDIR." case $echon in 0) /bin/echo -n '* Please provide directory where distribution files are located: ' ;; *) /bin/echo '* Please provide directory where distribution files are located: \c' ;; esac read EXTRACTDIR done cd $EXTRACTDIR /bin/echo Distribution directory: $EXTRACTDIR >> $HOME/it2install.log 2>&1 POTFILE=`ls $EXTRACTDIR | grep -i tar | grep -i it` ifiles=`ls $POTFILE | wc -l` if test "$ifiles" -gt 1 then thisfile=0 /bin/echo "*" /bin/echo "* Multiple potential installation files found in directory $EXTRACTDIR:" ic=0 for file in $POTFILE do ic=`expr $ic + 1` /bin/echo "* $ic --> $file" done while [ "$thisfile" -lt 1 ] || [ "$thisfile" -gt "$ifiles" ] do /bin/echo "*" case $echon in 0) /bin/echo -n '* Enter ID of file to be installed: ' ;; *) /bin/echo '* Enter ID of file to be installed: \c' ;; esac read thisfile if test "$thisfile" = "" then thisfile=0 fi done ic=0 for file in $POTFILE do ic=`expr $ic + 1` if test $ic -eq $thisfile then INSTFILE=$file fi done else INSTFILE=$POTFILE fi /bin/echo "*" /bin/echo "* Copying distribution file $EXTRACTDIR/$INSTFILE to directory $INSTALLDIR ..." /bin/echo "Copying distribution file $EXTRACTDIR/$INSTFILE to $INSTALLDIR" >> $HOME/it2install.log 2>&1 cp $INSTFILE $INSTALLDIR >> $HOME/it2install.log 2>&1 # change to the installation directory and extract files cd $INSTALLDIR if [ `ls $INSTFILE | grep -c ".Z"` -eq 1 ] then [ ! -f $IT2TAR ] || /bin/rm $IT2TAR >> $HOME/it2install.log 2>&1 /bin/echo "* Uncompressing file $INSTFILE ..." /bin/echo "Uncompressing file $INSTFILE" >> $HOME/it2install.log 2>&1 uncompress $INSTFILE >> $HOME/it2install.log 2>&1 elif [ `ls $INSTFILE | grep -c ".gz"` -eq 1 ] then /bin/echo "* Unzipping file $INSTFILE ..." /bin/echo "Unzipping file $INSTFILE" >> $HOME/it2install.log 2>&1 gunzip $INSTFILE >> $HOME/it2install.log 2>&1 fi /bin/echo "* Extracting files ..." /bin/echo Files extracted: >> $HOME/it2install.log 2>&1 tar xvf $IT2TAR >> $HOME/it2install.log 2>&1 # change to the users home cd $HOME if [ -d $HOME/bin ] then BINDIR=$HOME/bin # # assumes $HOME/bin is already in path # else BINDIR=$INSTALLDIR/bin if [ ! -d BINDIR ] then mkdir -p $BINDIR >> $HOME/it2install.log 2>&1 fi # # append a line to the users profile (depending on the shell # this is .profile, .bash_rpfile, or .login) and set the path variable if { /bin/echo $SHELL|grep -q -s -i '/csh' ; } # c-shell then PATHTEST=`cat .login | grep -i path | -c "$BINDIR"` >> $HOME/it2install.log 2>&1 if test "$PATHTEST" -eq "0" then /bin/echo "* Adding $BINDIR to PATH in file .login ..." /bin/echo "Adding $BINDIR to PATH in file .login" >> $HOME/it2install.log 2>&1 /bin/echo 'set PATH=($PATH '"$BINDIR)" >> .login PATH=$PATH:$BINDIR export PATH fi elif { /bin/echo $SHELL|grep -q -s -i '/bash' ; } # bash-shell then PATHTEST=`cat .bash_profile | grep -i path | grep -c "$BINDIR"` >> $HOME/it2install.log 2>&1 if test "$PATHTEST" -eq "0" then /bin/echo "* Adding $BINDIR to PATH in file .bash_profile ..." /bin/echo "Adding $BINDIR to PATH in file .bash_profile" >> $HOME/it2install.log 2>&1 /bin/echo 'PATH=$PATH:'"$BINDIR" >> .bash_profile PATH=$BINDIR:${PATH} export PATH fi else # POSIX-, bourne- and korn-shell PATHTEST=`cat .profile | grep -i path | grep -c "$BINDIR"` >> $HOME/it2install.log 2>&1 if test "$PATHTEST" -eq "0" then /bin/echo "* Adding $BINDIR to PATH in file .profile ..." /bin/echo "Adding $BINDIR to PATH in file .profile" >> $HOME/it2install.log 2>&1 /bin/echo 'PATH=$PATH:'"$BINDIR" >> .profile PATH=$BINDIR:${PATH} export PATH fi fi /bin/echo "* You may have to login to activate the path to $BINDIR !!!" /bin/echo "You may have to login to activate the path to $BINDIR" >> $HOME/it2install.log 2>&1 fi cd $INSTALLDIR/Scripts chmod a+x itough2 kit prista tough2 it2help >> $HOME/it2install.log 2>&1 cp itough2 kit prista tough2 it2help $BINDIR >> $HOME/it2install.log 2>&1 cd $BINDIR >> $HOME/it2install.log 2>&1 /bin/echo "* Changing the iTOUGH2 scripts itough2, tough2, and it2help ..." # edit the original itough2 script sed 's#prog_dir=$HOME/itough2#prog_dir='$INSTALLDIR# itough2 > itough2.tmp cp itough2.tmp itough2 rm itough2.tmp # # edit the original tough2 script sed 's#script_dir=$HOME/bin#script_dir='$BINDIR# tough2 > tough2.tmp cp tough2.tmp tough2 rm tough2.tmp # # edit the original it2help script sed 's#help_dir=$HOME/itough2#help_dir='$INSTALLDIR# it2help > it2help.tmp cp it2help.tmp it2help rm it2help.tmp cd # # test installation of script files # /bin/echo "* Testing installation of script files ..." if [ ! prista >/dev/null 2>&1 ] then /bin/echo "* WARNING: Logout and login again to update command search path." /bin/echo "* WARNING: Add $BINDIR to the command search path and check installation" /bin/echo "* of script files itough2, tough2, prista, kit, and it2help." /bin/echo "WARNING: Logout and login again to update command search path" >> $HOME/it2install.log 2>&1 /bin/echo "WARNING: Add $BINDIR to the command search path." >> $HOME/it2install.log 2>&1 /bin/echo "WARNING: Check isntallation of script files" >> $HOME/it2install.log 2>&1 /bin/echo " itough2, tough2, kit, prista, and it2help." >> $HOME/it2install.log 2>&1 fi # cd $INSTALLDIR/SourceCode chmod a+x it2make # /bin/echo "* Building all iTOUGH2 executables needed to run the sample problem ..." # /bin/echo "Building all iTOUGH2 executables needed to run the sample problem:" >> $HOME/it2install.log 2>&1 /bin/echo "* Building iTOUGH2/EOS9 ..." cat maxsize.inc | sed 's/PARAMETER (MAXK=.*)/PARAMETER (MAXK=1)/' > maxsize.1 cat maxsize.1 | sed 's/PARAMETER (MAXEQ=.*)/PARAMETER (MAXEQ=1)/' > maxsize.2 cat maxsize.2 | sed 's/PARAMETER (MAXPH=.*)/PARAMETER (MAXPH=2)/' > maxsize.3 cat maxsize.3 | sed 's/PARAMETER (MAXB=.*)/PARAMETER (MAXB=6)/' > maxsize.inc ./it2make 9 case "$?" in 1) echo "* ERROR in it2make: No FORTRAN compiler found." exit 1;; 2) echo "* ERROR in it2make: Platform not supported." exit 2;; esac #cat maxsize.inc | sed 's/PARAMETER (MAXK=.*)/PARAMETER (MAXK=5)/' > maxsize.1 #cat maxsize.1 | sed 's/PARAMETER (MAXEQ=.*)/PARAMETER (MAXEQ=6)/' > maxsize.2 #cat maxsize.2 | sed 's/PARAMETER (MAXPH=.*)/PARAMETER (MAXPH=2)/' > maxsize.3 #cat maxsize.3 | sed 's/PARAMETER (MAXB=.*)/PARAMETER (MAXB=11)/' > maxsize.inc #/bin/echo "* Building iTOUGH2/EOS7r ..." #./it2make 7r cat maxsize.inc | sed 's/PARAMETER (MAXK=.*)/PARAMETER (MAXK=2)/' > maxsize.1 cat maxsize.1 | sed 's/PARAMETER (MAXEQ=.*)/PARAMETER (MAXEQ=3)/' > maxsize.2 cat maxsize.2 | sed 's/PARAMETER (MAXPH=.*)/PARAMETER (MAXPH=2)/' > maxsize.3 cat maxsize.3 | sed 's/PARAMETER (MAXB=.*)/PARAMETER (MAXB=6)/' > maxsize.inc #/bin/echo "* Building iTOUGH2/EOS3nn ..." #./it2make 3nn /bin/echo "* Building iTOUGH2/EOS1 ..." ./it2make 1 /bin/echo "* Building iTOUGH2/EOS3 ..." ./it2make 3 /bin/echo "* Building iTOUGH2/EOS4 ..." ./it2make 4 /bin/rm maxsize.? /bin/echo "* Created the following iTOUGH2 executables in directory $INSTALLDIR:" for file in itough2_*.* do EOSMODULE=`echo $file | awk -F_ '{ print $2 }' | awk -F. '{ print $1 }'` /bin/echo "* For EOS module $EOSMODULE: $file" done /bin/echo "To build additional executables, go to $INSTALLDIR and type it2make or use the Makefile." >> $HOME/it2install.log 2>&1 /bin/echo "* To build additional executables, use script it2make or the make utility." /bin/echo "* The script file it2make and the Makefile can be found in $INSTALLDIR" /bin/echo iTOUGH2 installation completed: `date` >> $HOME/it2install.log 2>&1 mv $HOME/it2install.log . cd $STARTDIR /bin/echo '*******************************************************************************' case $echon in 0) /bin/echo -n '* Do you want to print the read_me file [Y/N*]? ' ;; *) /bin/echo '* Do you want to print the read_me file [Y/N*]? \c' ;; esac read PRINTREADME if [ -n "`/bin/echo $PRINTREADME | grep -i 'y'`" ] then cat $INSTALLDIR/read_me.txt | lpr /bin/echo '* File read_me.txt sent to default printer.' fi /bin/echo '*******************************************************************************' /bin/echo "* Installation report in logfile $INSTALLDIR/it2install.log" /bin/echo "* You may need to logout and login again to invoke changes in the search path." /bin/echo "* Test the installation by running appropriate sample problems." /bin/echo "* Input files for sample problem X are provided in subdirectory" /bin/echo "* $INSTALLDIR/Samples/sampleX" /bin/echo '*******************************************************************************' /bin/echo "* it2install completed" /bin/echo '*******************************************************************************' /bin/echo ' '