|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Bash shell script to install PyGPSClient on 64-bit Arch-based |
| 4 | +# Linux environments. |
| 5 | +# |
| 6 | +# Change shebang /bin/bash to /bin/zsh if running from zsh shell. |
| 7 | +# NB: NOT for use on Windows or MacOS! |
| 8 | +# |
| 9 | +# Remember to run chmod +x pygpsclient_arch_install.sh to make this script executable. |
| 10 | +# |
| 11 | +# Full installation instructions: |
| 12 | +# https://github.com/semuconsulting/PyGPSClient |
| 13 | +# |
| 14 | +# Created by semuadmin on 20 Sep 2023. |
| 15 | +# |
| 16 | +# exit on error |
| 17 | +set -e |
| 18 | + |
| 19 | +PYVER="$(python3 -c 'import sys; print(".".join(map(str, sys.version_info[:2])))')" |
| 20 | + |
| 21 | +echo "Installed Python version is $PYVER" |
| 22 | + |
| 23 | +echo "PyGPSClient will be installed at $HOME/pygpsclient/bin" |
| 24 | + |
| 25 | +echo "Installing dependencies..." |
| 26 | +sudo pacman -S tk libspatialite |
| 27 | + |
| 28 | +echo "Setting user permissions..." |
| 29 | +sudo usermod -aG uucp $USER |
| 30 | + |
| 31 | +echo "Creating virtual environment..." |
| 32 | +cd $HOME |
| 33 | +python3 -m venv pygpsclient |
| 34 | +source pygpsclient/bin/activate |
| 35 | +python3 -m pip install --upgrade pip pygpsclient rasterio |
| 36 | +deactivate |
| 37 | + |
| 38 | +echo "Adding desktop launch icon..." |
| 39 | +# the LD_LIBRARY_PATH env setting allows PyGPSClient to find the |
| 40 | +# mod_spatialite.so module, which is typically installed in this location |
| 41 | +# you can set other env variables in a similar fashion if required |
| 42 | +mkdir -p $HOME/.local/share/applications |
| 43 | +cat > $HOME/.local/share/applications/pygpsclient.desktop <<EOF |
| 44 | +[Desktop Entry] |
| 45 | +Type=Application |
| 46 | +Terminal=false |
| 47 | +Name=PyGPSClient |
| 48 | +Icon=$HOME/pygpsclient/lib/python$PYVER/site-packages/pygpsclient/resources/pygpsclient.ico |
| 49 | +Exec=env LD_LIBRARY_PATH=/usr/local/lib $HOME/pygpsclient/bin/pygpsclient |
| 50 | +EOF |
| 51 | + |
| 52 | +echo "Adding directory to PATH..." |
| 53 | +BASHPROF1=$HOME/.profile |
| 54 | +BASHPROF2=$HOME/.bashrc |
| 55 | +ZSHPROF1=$HOME/.zprofile |
| 56 | +ZSHPROF2=$HOME/.zshrc |
| 57 | +if test -f $BASHPROF1 |
| 58 | +then |
| 59 | +PROF=$BASHPROF1 |
| 60 | +elif test -f $BASHPROF2 |
| 61 | +then |
| 62 | +PROF=$BASHPROF2 |
| 63 | +fi |
| 64 | +if test -f $ZSHPROF1 |
| 65 | +then |
| 66 | +PROF=$ZSHPROF1 |
| 67 | +elif test -f $ZSHPROF2 |
| 68 | +then |
| 69 | +PROF=$ZSHPROF2 |
| 70 | +fi |
| 71 | +sed -i '$a# Path to PyGPSClient executable\nexport PATH="${HOME}/pygpsclient/bin:${PATH}"' $PROF |
| 72 | +source $PROF # this will throw an error if running as bash script in zsh shell |
| 73 | + |
| 74 | +echo "Installation complete" |
0 commit comments