#!/bin/bash

echo "starting the openMosixview installation"
echo 

if [[ $1 == "" ]]; then
 
 echo "you have to put your QT-installation directory behind ./setup"
 echo "e.g. ./setup /usr/lib/qt-2.3.0"
 echo;
 
 else

 export QTDIR=$1

 echo "This openMosixview version contains a smart 3d add-on,"
 echo "the 3dmosmon. It is a nice 3d view of your cluster."
 echo "(many thanks to Johnny Cache, the Author of 3dmosmon)"
 echo
 echo
 echo "Now compiling and installing openMosixview"
 echo 

 make clean
 rm config.cache
 rm Makefile
 ./configure
 make

 cd openmosixcollector
 make clean
 rm config.cache
 rm Makefile
 ./configure
 make
 cd ..

 cd openmosixanalyzer
 make clean
 rm config.cache
 rm Makefile
 ./configure
 make
 cd ..

 cd openmosixhistory
 make clean
 rm config.cache
 rm Makefile
 ./configure
 make
 cd ..

 cd openmosixprocs
 make clean
 rm config.cache
 rm Makefile
 ./configure
 make
 cd ..

 cd openmosixmigmon
 make clean
 rm config.cache
 rm Makefile
 ./configure
 make
 cd ..



 echo "copy the binaries to /usr/bin"
 echo
 /bin/cp openmosixview/openmosixview /usr/bin
 echo "openmosixview"
 /bin/cp openmosixprocs/openmosixprocs/openmosixprocs /usr/bin
 echo "openmosixprocs"
 /bin/cp openmosixcollector/openmosixcollector/openmosixcollector /usr/bin
 echo "openmosixcollector"
 /bin/cp openmosixcollector/openmosixcollector.init /etc/init.d/openmosixcollector
 echo "openmosixcollector.init to /etc/init.d/openmosixcollector"
 echo "(if you have your init-scripts somewhere diffrent you have to"
 echo "copy the openmosixcollector init-script manual!)"
 /bin/cp openmosixanalyzer/openmosixanalyzer/openmosixanalyzer /usr/bin
 echo "openmosixanalyzer"
 /bin/cp openmosixhistory/openmosixhistory/openmosixhistory /usr/bin
 echo "openmosixhistory"
 /bin/cp openmosixmigmon/openmosixmigmon/openmosixmigmon /usr/bin
 echo "openmosixmigmon"


 # installation finish
 echo
 echo "Installation ended successfully (if there was no error)"
 echo 
 echo "now type ./openmosixview/openmosixview and have fun!"
 echo "(do not forget to copy the openmosixprocs binary to /usr/bin of each"
 echo "your cluster-nodes e.g"
 echo " rcp /usr/bin/openmosixprocs hostname_of_node:/usr/bin"
 echo "or if you use SSH"
 echo " scp /usr/bin/openmosixprocs hostname_of_node:/usr/bin"
 echo "reply problems during installation to mosixview@t-online.de"
 echo "Thanks"
 echo

 echo  "This openMosixview version contains a smart 3d add-on,"
 echo "the 3dmosmon. It is a nice 3d view of your cluster."
 echo "(many thanks to Johnny Cache, the Author of 3dmosmon)"
 echo
 echo "If you want to install the 3dmosmon add-on please execute:"
 echo 
 echo "cd 3dmon"
 echo "./setup"
 echo 
 echo "The setup-procedure will guide you through the installation."

fi

