Last active
October 4, 2018 01:23
-
-
Save suricactus/0214da3044eccbb5418897c95f776f0e to your computer and use it in GitHub Desktop.
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 | |
### To work properly, run this script as root | |
# path where the script to be installed | |
INSTALL_PATH=/opt | |
INSTALL_DIR=pcraster | |
# actual script, see http://pcraster.geo.uu.nl/getting-started/pcraster-on-linux/ | |
cd $INSTALL_PATH | |
if [[ -d "$INSTALL_PATH/$INSTALL_DIR" ]]; then | |
echo "$INSTALL_PATH/$INSTALL_DIR already exists" | |
exit 1; | |
fi | |
if [[ $1 eq 2 ]]; then | |
apt install cmake gcc g++ git libboost-all-dev libgdal-dev libncurses5-dev libpython-dev libqwt-qt5-dev libxerces-c-dev libxml2 libxml2-utils libxslt1-dev python-numpy qtbase5-dev python-docopt | |
else | |
apt install cmake gcc g++ git qtbase5-dev libncurses5-dev libqwt-qt5-dev libxerces-c-dev libboost-all-dev libgdal-dev python3-numpy python3-docopt | |
fi; | |
if [[ ! -e pcraster-4.2.0.tar.bz2 ]]; then | |
wget http://pcraster.geo.uu.nl/pcraster/4.2.0/pcraster-4.2.0.tar.bz2 | |
fi; | |
tar xf pcraster-4.2.0.tar.bz2 | |
cd pcraster-4.2.0 | |
mkdir build && cd build | |
if [[ $1 eq 2 ]]; then | |
cmake -DFERN_BUILD_ALGORITHM:BOOL=TRUE -DCMAKE_INSTALL_PREFIX:PATH=$INSTALL_PATH/$INSTALL_DIR .. | |
else | |
cmake -DFERN_BUILD_ALGORITHM:BOOL=TRUE -DCMAKE_INSTALL_PREFIX:PATH=$HOME/pcraster -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/python3 .. | |
fi; | |
cmake --build . | |
# takes ~20 minutes on my machine | |
make install | |
echo "Compilation done!" | |
# TODO python to prove it works | |
export PYTHONPATH="${PYTHONPATH}:$INSTALL_PATH/$INSTALL_DIR/python" | |
export PATH="${PATH}:$INSTALL_PATH/$INSTALL_DIR/bin" | |
echo "Checking if pcrcalc is available..."; | |
if [[ `command -v pcrcalc` ]]; then | |
echo "[SUCCESS] pcrcalc successfully installed" | |
echo "Please consider adding the PATH to your ~/.profile:" | |
echo "export PATH="\"\$"{PATH}:$INSTALL_PATH/$INSTALL_DIR/bin"\" | |
else | |
echo "[ERROR] pcrcalc not found"; | |
exit 1; | |
fi; | |
echo "Checking if python module is available..."; | |
python -c 'from pcraster import *' | |
if [[ $? -eq 0 ]]; then | |
echo "[SUCCESS] Python module successfully installed" | |
echo "Please consider adding the PYTHONPATH to your ~/.profile:" | |
echo "export PYTHONPATH="\"\$"{PYTHONPATH}:$INSTALL_PATH/$INSTALL_DIR/python"\" | |
else | |
echo "[ERROR] Python module was not found, exited with code $?"; | |
exit 1; | |
fi; | |
echo "Everything works fine, success!"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment