#!/bin/bash
# Version 2010-31-03 E. Schumacher
echo This script installs Gamess, compiled in 
echo a Knoppix or Ubuntu environment into other Linuxes.
echo It needs an archive 'gamess_export.tar.gz'
echo created by the script 'exportntv.sh'
echo with a full Gamess installation in Knoppix/Ubuntu
echo " "
#make sure we are in /home/$USER
cd /home/$USER
if [ ! -e gamess_export.tar.gz ]; then
  echo 'gamess_export.tar.gz' does not exists!
	echo Please create it with the script
	echo 'exportntv.sh' on your Knoppix or Ubuntu and
	echo copy it into this /home/$USER directory
	exit
fi
if [ -e gamess ];  then
  echo The directory 'Gamess' exists!
	echo please rename it before you
	echo install a new Gamess directory!
	exit
fi
mkdir scr
tar xzvf gamess_export.tar.gz
mv gamess_export gamess
mv ~/gamess/gmolden4.7.linux ~
mkdir ~/gamess/logs
cd gamess
if [ ! -e /bin/csh ]; then
  if [ $USER == knoppix ] || [ $USER == ubuntu ]; then
    sudo cp csh /bin/csh
  else
    echo after this script finishes
    echo become root, copy from here
    echo 'csh' into /bin and exit;
		echo otherwise 'rungms' does not work
  fi
fi
if [ ! -e gamessloc.sh ]; then
  wget http://www.chemsoft.ch/downloads/gamessloc.sh
fi
chmod +x gamessloc.sh
echo " "
echo When calling gamess do not use 'rungms' directly but
echo "./gamessloc.sh job(.inp) > job.out"
echo or modify /home/$USER/.bashrc as follows:
echo open it in a text editor and add the line
echo export LD_LIBRARY_PATH=/home/$USER/gamess
echo save it and execute: source .bashrc
echo " "
sudo /sbin/sysctl -w kernel.shmmax=500000000
echo Now running tests:
export LD_LIBRARY_PATH=/home/$USER/gamess
./runall
cd tools/checktst
./checktst
exit


