#!/bin/bash

if [ -z "$CLIB" ]; then
    echo "CCP4 symbols not defined ? Abort."
    exit 1
fi 

echo -e "\n\\033[32m\\033[1mDownloading archive ...\\033[0m"
wget http://utopia.duth.gr/~glykos/progs/GraphEnt.tar.gz

echo -e "\\033[32m\\033[1mExtracting in current directory ...\\033[0m"
tar zxf GraphEnt.tar.gz


cd GraphEnt/bin/Linux/
export PGPLOT_DIR=`pwd`
mkdir test
cd test/
cp ../../../examples/rnase.mtz .

echo -e "\n\\033[32m\\033[1mWill now attempt to test the executable.\\033[0m"
echo -e "You should see a graphics window. Click (in"
echo -e "this order) : DELFIOD25, SIGDELFIOD25, Finished."
echo -e "Then press the 'Y' key. After a long pause you"
echo -e "should see the first of the two maps appearing.\n"

echo -e "\\033[37m\\033[1mLet it run until a third window appears, then"
echo -e "hit ENTER in this (unix shell) window.\\033[0m\n\n"

../graphent rnase.mtz


echo -e "\n\\033[32m\\033[1mWill now attempt to install the dual-core"
echo -e "executable in /usr/local/bin using sudo.\\033[0m" 
sudo sh -c "cd $PGPLOT_DIR ; cp GraphEnt_dual_core /usr/local/bin/GraphEnt ; cp pgxwin_server grfont.dat /usr/local/bin/ ; chmod 755 /usr/local/bin/GraphEnt /usr/local/bin/pgxwin_server ; ln -s /usr/local/bin/GraphEnt /usr/local/bin/graphent"

echo -e "\nAll done. Users should add something like this"
echo -e "\\033[1m\\033[36m    export PGPLOT_DIR=/usr/local/bin\\033[0m"
echo -e "or, this"
echo -e "\\033[1m\\033[36m    setenv PGPLOT_DIR /usr/local/bin\\033[0m"
echo -e "in their .bashrc or .tcshrc files.\n"

