Skip to content

Instantly share code, notes, and snippets.

@iomarmochtar
Created August 24, 2017 02:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iomarmochtar/e13ec5305f337045023636ce6c6623fa to your computer and use it in GitHub Desktop.
Save iomarmochtar/e13ec5305f337045023636ce6c6623fa to your computer and use it in GitHub Desktop.
Script for automating pgAdmin4 installation
#!/bin/bash
# Author: Imam Omar Mochtar (iomarmochtar@gmail.com)
# Desc : Script for automating pgAdmin4 as Desktop mode, make sure postgresql-dev and python-dev package has been installed
# , was tested in Ubuntu 16.04 LTS
BASE_DIR="/opt/pgadmin4"
RUN_SCRIPT="$BASE_DIR/run.sh"
VIRTENV="/usr/local/bin/virtualenv"
VIRTENV_DIR="$BASE_DIR/virtenv"
PIP="$VIRTENV_DIR/bin/pip"
PGADMIN4_DIR="$VIRTENV_DIR/lib/python2.7/site-packages/pgadmin4"
PGADMIN4_LCONFIG="$PGADMIN4_DIR/config_local.py"
PGADMIN4_URL="https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v1.6/pip/pgadmin4-1.6-py2.py3-none-any.whl"
echo "Creating base directory $BASE_DIR"
mkdir -p $BASE_DIR
echo "Setup python virtual environment"
$VIRTENV $VIRTENV_DIR
echo "Download and install pgadmin4"
$PIP install $PGADMIN4_URL
echo "Creating local config for desktop mode"
echo "SERVER_MODE=False" > $PGADMIN4_LCONFIG
echo "Creating running script $RUN_SCRIPT"
echo "#!/bin/bash" > $RUN_SCRIPT
echo "$VIRTENV_DIR/bin/python $PGADMIN4_DIR/pgAdmin4.py" >> $RUN_SCRIPT
chmod +x $RUN_SCRIPT
echo "[DONE] execute this script $RUN_SCRIPT (as normal user) to run pgAdmin4"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment