#!/bin/bash
echo "**********************************************************"
echo "*                        MAGiC                           *"
echo "*                                                        *"
echo "*                        ERICCA                          *"
echo "*                                                        *"
echo "*         Departement de genie mecanique - UQTR          *"
echo "*                                                        *"
echo "*         Installation des modules Code aster "$1"       *"
echo "*                                                        *"
echo "**********************************************************"
echo ""
echo $(date)
versionos=$(lsb_release -sr)
echo ""
echo "Code Aster installation"
if [ $1 == 11.6 ]; 
then
version=11.6
else
if [ $1 == 11.5 ]; 
then
version=11.5
else
if [ $1 == 11.7 ]; 
then
version=11.7
else
if [ $1 == 12.4 ]; 
then
version=12.4
else
if [ $1 == 12.5 ]; 
then
version=12.5
else
if [ $1 == 12.5mod ]; 
then
version=12.5mod
else
if [ $1 == 12.7 ]; 
then
version=12.7
else
if [ $1 == 13.6 ]; 
then
version=13.6
else
if [ $1 == 14.4 ]; 
then
version=14.4
else
if [ $1 == 14.6 ]; 
then
version=14.6
else
echo "Version "$1" non supportée"
exit
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
if [ "$versionos" \> "19" ];
then
if [ "$version" \< "14.5" ];
then
echo "Version superieur ou egal à 14.6 supporté avec votre os. Recommencer la commande avec une version compatible"
exit
fi
fi
echo "version" $version
echo "Checking / Installing dependencies"
tabdep=(gfortran python3 g++ gcc python3-dev python3-numpy python-qt4 tk bison flex libblas-dev liblapack-dev libmotif-dev )
if [ "$version" \> "14" ];
then
tabdep=( "${tabdep[@]}" "python3")
tabdep=( "${tabdep[@]}" "python3-dev")
tabdep=( "${tabdep[@]}" "python3-numpy")
if [ "$versionos" \< "15" ];
then
tabdep=( "${tabdep[@]}" "libboost-python3-dev")
fi
fi
if [ "$version" \< "14" ];
then
tabdep=( "${tabdep[@]}" "python")
tabdep=( "${tabdep[@]}" "python-dev")
tabdep=( "${tabdep[@]}" "python-numpy")
fi
if [ "$version" \> "13" ];
then
tabdep=( "${tabdep[@]}" "libboost-python-dev")
fi
echo "Dependance a verifier :"${#tabdep[*]}
for i in ${!tabdep[*]};
do
nomdep=${tabdep[i]}
dpkg -s $nomdep  >> /dev/null 2>&1
if [ $? == 1 ];
then
echo $nomdep...............FAIL
sudo apt-get -y install $nomdep  
else
echo $nomdep...............ok
fi

done
__DIR=`pwd`
echo "Verification code aster"
cd /opt/aster
if [ ! -d $version ];
then
echo "installation code aster "$version"..................FAIL"
echo "installation code aster "$version
cd $__DIR
if [ $version == 14.6 ];
then
wget http://ericca.uqtr.ca/aster-full-src-14.6.0-1.noarch.tar.gz
tar -zxf aster-full-src-14.6.0-1.noarch.tar.gz
cd aster-full-src-14.6.0
fi
if [ $version == 14.4 ];
then
wget http://ericca.uqtr.ca/aster-full-src-14.4.0-1.noarch.tar.gz
tar -zxf aster-full-src-14.4.0-1.noarch.tar.gz
cd aster-full-src-14.4.0
fi
if [ $version == 13.6 ];
then
wget http://ericca.uqtr.ca/aster-full-src-13.6.0-1.noarch.tar.gz
tar -zxf aster-full-src-13.6.0-1.noarch.tar.gz
cd aster-full-src-13.6.0
fi
if [ $version == 12.7 ];
then
wget http://ericca.uqtr.ca/aster-full-src-12.7.0-1.noarch.tar.gz
tar -zxf aster-full-src-12.7.0-1.noarch.tar.gz
cd aster-full-src-12.7.0
fi
if [ $version == 12.5mod ];
then
wget http://ericca.uqtr.ca/aster-mod-src-12.5.0-1.noarch.tar.gz
tar -zxf aster-mod-src-12.5.0-1.noarch.tar.gz
cd aster-full-src-12.5.0
fi
if [ $version == 12.5 ];
then
wget http://ericca.uqtr.ca/aster-full-src-12.5.0-1.noarch.tar.gz
tar -zxf aster-full-src-12.5.0-1.noarch.tar.gz
cd aster-full-src-12.5.0
fi

if [ $version == 12.4 ];
then
wget http://ericca.uqtr.ca/aster-full-src-12.4.0-1.noarch.tar.gz
tar -zxf aster-full-src-12.4.0-1.noarch.tar.gz
cd aster-full-src-12.4.0
fi

if [ $version == 11.7 ];
then
wget http://ericca.uqtr.ca/aster-full-src-11.7.0-1.noarch.tar.gz
tar -zxf aster-full-src-11.7.0-1.noarch.tar.gz
cd aster-full-src-11.7.0
fi

if [ $version == 11.6 ];
then
wget http://ericca.uqtr.ca/aster-full-src-11.6.0-1.noarch.tar.gz
tar -zxf aster-full-src-11.6.0-1.noarch.tar.gz
cd aster-full-src-11.6.0
fi

if [ $version == 11.5 ];
then
wget http://ericca.uqtr.ca/aster-full-src-11.5.0-4.noarch.tar.gz
tar -zxf aster-full-src-11.5.0-4.noarch.tar.gz
cd aster-full-src-11.5.0
fi

if [ $version == STA10.6 ];
then
wget http://ericca.uqtr.ca/aster-full-src-10.6.0-3.noarch.tar.gz
tar -zxf aster-full-src-10.6.0-3.noarch.tar.gz
cd aster-full-src-10.6.0
fi

if [ "$version" \> "14" ];
then
sudo python3 setup.py install --prefix=/opt/aster
else
sudo python setup.py install --prefix=/opt/aster
fi
else
echo "installation code aster "$version"..................OK"
fi




echo "  mettre les lignes suivantes dans .bashrc"
echo "    export PATHASTER=/opt/aster/bin"
echo "    PATH=\$PATH:\$PATHASTER"
echo "  verifier que le repertoire flasheur dans le home directory à les droits d'accees 777"
cd $__DIR
echo ""
echo $(date)
echo ""
echo "**********************************************************"
echo "*                        MAGiC                           *"
echo "*                                                        *"
echo "*                        ERICCA                          *"
echo "*                                                        *"
echo "*         Departement de genie mecanique - UQTR          *"
echo "*                                                        *"
echo "*           Installation du module Code aster            *"
echo "*                                                        *"
echo "**********************************************************"


