Last active
December 13, 2016 06:47
-
-
Save vijaiaeroastro/203340811b6c43983a31 to your computer and use it in GitHub Desktop.
An automated installer for stanford su2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
####################################################### | |
# # | |
# Script to automatically install SU2 in Ubuntu # | |
# @author : vijai@vijaikumar.in # | |
# # | |
###################################################################################### | |
# Change Log # | |
# ========== # | |
# Early Alpha Version - It could be improved by reducing the number of if statements # | |
# I will change it very soon # | |
###################################################################################### | |
# Colors | |
ESC_SEQ="\x1b[" | |
COL_RESET=$ESC_SEQ"39;49;00m" | |
COL_RED=$ESC_SEQ"31;01m" | |
COL_GREEN=$ESC_SEQ"32;01m" | |
COL_YELLOW=$ESC_SEQ"33;01m" | |
COL_BLUE=$ESC_SEQ"34;01m" | |
COL_MAGENTA=$ESC_SEQ"35;01m" | |
COL_CYAN=$ESC_SEQ"36;01m" | |
echo -e "$COL_MAGENTA ******************************************************************** $COL_RESET" | |
echo -e "$COL_YELLOW *_________________Welcome to SU2 Automated Installer_______________* $COL_RESET" | |
cat << "EOF" | |
* * | |
* .--.--. ,----, * | |
* / / '. ,--, .' .' \ * | |
* | : /`. / ,'_ /| ,----,' | * | |
* ; | |--` .--. | | : | : . ; * | |
* | : ;_ ,'_ /| : . | ; |.' / * | |
* \ \ `. | ' | | . . `----'/ ; * | |
* `----. \| | ' | | | / ; / * | |
* __ \ \ |: | | : ' ; ; / /-, * | |
* / /`--' /| ; ' | | ' / / /.`| * | |
* '--'. / : | : ; ; | ./__; : * | |
* `--'---' ' : `--' \ | : .' * | |
* : , .-./ ; | .' * | |
* `--`----' `---' * | |
EOF | |
echo -e "$COL_YELLOW *_________________This script only works on Ubuntu_________________* $COL_RESET" | |
echo -e "$COL_YELLOW *___If your OS is Non - Debian package manager would be different__* $COL_RESET" | |
echo -e "$COL_YELLOW *____________________Hence the script would fail___________________* $COL_RESET" | |
echo -e "$COL_YELLOW *________This script pauses a lot during the installation__________* $COL_RESET" | |
echo -e "$COL_YELLOW *_If something fails it will throw an error and automatically exit_* $COL_RESET" | |
echo -e "$COL_YELLOW *___Do not close the terminal until installation is 100% complete__* $COL_RESET" | |
echo -e "$COL_MAGENTA ******************************************************************** $COL_RESET" | |
echo -e "$COL_CYAN \________________Script Released under MIT License________________/ $COL_RESET" | |
echo -e "$COL_CYAN /_______________Terms of the License are as Follows_______________\ $COL_RESET" | |
echo -e "$COL_MAGENTA ******************************************************************** $COL_RESET" | |
cat << "EOF" | |
* * | |
* * | |
* The MIT License (MIT) * | |
* * | |
* Copyright (c) 2015 Vijai Kumar S * | |
* * | |
* Permission is hereby granted, free of charge, to any person * | |
* obtaining a copy of this software and associated * | |
* documentation files (the "Software"), to deal in the * | |
* Software without restriction, including without limitation * | |
* the rights to use, copy, modify, merge, publish, distribute, * | |
* sublicense, and/or sell copies of the Software, and to * | |
* permit persons to whom the Software is furnished to do so, * | |
* subject to the following conditions: * | |
* * | |
* The above copyright notice and this permission notice * | |
* shall be included in all copies or substantial portions * | |
* of the Software. * | |
* * | |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF * | |
* ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO * | |
* THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR * | |
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * | |
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * | |
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * | |
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * | |
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * | |
* THE SOFTWARE. * | |
* * | |
* * | |
EOF | |
echo -e "$COL_MAGENTA ******************************************************************** $COL_RESET" | |
# Sanity Check | |
# Make sure only root can run our script | |
if [[ "$EUID" -ne 0 ]]; then | |
echo -e "$COL_RED This script must be run as sudo or root only! $COL_RESET" 1>&2 | |
exit 1 | |
fi | |
cat << "EOF" | |
******************************************************************** | |
* Do you accept the terms and want to continue ? * | |
* There are two options for you here * | |
* Enter one of the numbers based on what you want to do. * | |
* 1 -> Install * | |
* 2 -> Uninstall * | |
* 0 -> Exit * | |
* * | |
******************************************************************** | |
EOF | |
# Install or Uninstall | |
read OPTION | |
case $OPTION in | |
1 ) echo -e "$COL_GREEN I will continue with installation! $COL_RESET";; | |
2 ) cd $HOME && rm -rf cgnslib_3.2.1 && rm -rf SU2v4.0.0 && cd /usr/local/bin && \ | |
rm -rf *.py *SU2* && rm -rf /usr/local/lib/libcgns.a && exit 1;; | |
0 ) echo -e "$COL_RED I will Exit Here! $COL_RESET" && exit 1;; | |
esac | |
# Pre dependencies check | |
echo -e "$COL_GREEN Installation of Predependencies $COL_RESET" | |
echo -e "$COL_GREEN =============================== $COL_RESET" | |
sudo apt-get -qq -y update > /dev/null | |
echo -e "$COL_BLUE 1. Database updated! $COL_RESET" | |
sudo apt-get -qq -y install wget > /dev/null | |
echo -e "$COL_BLUE 2. Wget check done! $COL_RESET" | |
sudo apt-get -qq -y install gcc g++ gfortran > /dev/null | |
echo -e "$COL_BLUE 3. Compilers are Installed! $COL_RESET" | |
sudo apt-get -qq -y install autotools-dev build-essential openmpi-bin openmpi-doc libopenmpi-dev > /dev/null | |
echo -e "$COL_BLUE 4. OpenMPI is Installed! $COL_RESET" | |
sleep 5 | |
echo -e "$COL_RED That's our 25% mark $COL_RESET" | |
# Download cgnslib source code | |
cd $HOME | |
echo -e "$COL_GREEN Get CGNS Libs from Sourceforge! $COL_RESET" | |
if [ -f cgnslib.tar.gz ]; then | |
echo -e "$COL_BLUE CGNSlib source code is already available! $COL_RESET" | |
else | |
wget http://liquidtelecom.dl.sourceforge.net/project/cgns/cgnslib_3.2/cgnslib_3.2.1.tar.gz -O cgnslib.tar.gz > /dev/null | |
sleep 5 | |
fi | |
if [ ! -f cgnslib.tar.gz ]; then | |
echo -e "$COL_RED Something went wrong! You should have the cgnslib source code in your system by now $COL_RESET" | |
echo -e "$COL_RED So i will exit here! Sorry!! Contact vijai@vijaikumar.in $COL_RESET" | |
exit 1 | |
fi | |
# Installing cgnslib | |
echo -e "$COL_GREEN Installing CGNS libs from CGNS source code! $COL_RESET" | |
tar -xzvf cgnslib.tar.gz > /dev/null | |
cd cgnslib_3.2.1/src && ./configure > /dev/null && make > /dev/null && sudo make install > /dev/null | |
sleep 10 | |
if [ ! -f /usr/local/lib/libcgns.a ]; then | |
echo -e "$COL_RED It doesn't look like compilation of libcgns went through as we expected! $COL_RESET" | |
echo -e "$COL_RED So i will exit here! Sorry! Contact vijai@vijaikumar.in $COL_RESET" | |
exit 1 | |
else | |
echo -e "$COL_BLUE 5. CGNS libs are installed successfully! $COL_RESET" | |
fi | |
echo -e "$COL_RED That's our 50% mark $COL_RESET" | |
# Download SU2 source code | |
cd $HOME | |
echo -e "$COL_GREEN Get SU2 from Stanford university Repo $COL_RESET" | |
if [ -f SU2.tgz ]; then | |
echo -e "$COL_BLUE SU2 source code is already available! $COL_RESET" | |
else | |
wget http://su2.stanford.edu/download/v4.0.0/SU2v4.0.0.tgz -O SU2.tgz > /dev/null | |
sleep 5 | |
fi | |
if [ ! -f SU2.tgz ]; then | |
echo -e "$COL_RED Something went wrong! You should have the SU2 source code in your system by now $COL_RESET" | |
echo -e "$COL_RED So i will exit here! Sorry!! Contact vijai@vijaikumar.in $COL_RESET" | |
exit 1 | |
else | |
tar -xzvf SU2.tgz > /dev/null | |
fi | |
# Installing SU2 | |
echo -e "$COL_BLUE Give a drumroll because we are going to install SU2 finally! $COL_RESET" | |
sleep 5 | |
cd SU2v4.0.0/ && ./configure CXXFLAGS="-O3" --enable-mpi \ | |
--with-cc=/usr/bin/mpicc --with-cxx=/usr/bin/mpicxx \ | |
--with-CGNS-lib=/usr/local/lib \ | |
--with-CGNS-include=/usr/local/include > /dev/null | |
echo -e "$COL_GREEN The script will now wait for 10 seconds $COL_RESET" | |
echo -e "$COL_GREEN You must open your .bashrc file which can be found in your Home directory $COL_RESET" | |
echo -e "$COL_GREEN And add the lines shown above $COL_RESET" | |
echo -e "$COL_GREEN Simply do this nano $HOME/.bashrc and copy the configuration shown in the screen." | |
echo -e "$COL_GREEN You could use gedit too if you want. $COL_RESET" | |
sleep 10 | |
echo -e "$COL_MAGENTA This is the part in which SU2 is installed! $COL_RESET" | |
echo -e "$COL_MAGENTA Go make yourself a coffee or something.. coz it will take a really long time since it has to compile $COL_RESET" | |
cat << "EOF" | |
( | |
) ( | |
___...(-------)-....___ | |
.-"" ) ( ""-. | |
.-'``'|-._ ) _.-| | |
/ .--.| `""---...........---""` | | |
/ / | | | |
| | | | | |
\ \ | | | |
`\ `\ | | | |
`\ `| | | |
_/ /\ / | |
(__/ \ / | |
_..---""` \ /`""---.._ | |
.-' \ / '-. | |
: `-.__ __.-' : | |
: ) ""---...---"" ( : | |
'._ `"--...___...--"` _.' | |
\""--..__ __..--""/ | |
'._ """----.....______.....----""" _.' | |
`""--..,,_____ _____,,..--""` | |
`"""----"""` | |
EOF | |
sudo make install > /dev/null | |
sleep 5 | |
if which SU2_CFD >/dev/null; then | |
echo -e "$COL_YELLOW Hooray! We did it $COL_RESET" | |
echo -e "$COL_RED That's our 100% mark $COL_RESET" | |
echo -e "$COL_BLUE 6. SU2 was installed successfully ;) $COL_RESET" | |
else | |
echo -e "$COL_RED Hmmmm... SU2 is not in the path it seems :/ $COL_RESET" | |
echo -e "$COL_RED Shoot a mail to vijai@vijaikumar.in $COL_RESET" | |
fi |
i did.. i moved it to github 😃
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
change
>/dev/null
to
>&- 2>&1
and
apt-get install -qq --force-yes
to
apt-get install -qq -y