#!/bin/sh PGWEB="$HOME/.local/share/pgweb/pgweb_linux_amd64" if ! [ -d "${PGWEB%/*}" ] ; then mkdir -p "${PGWEB%/*}" fi LATEST="$(curl -s https://api.github.com/repos/sosedoff/pgweb/releases/latest | grep '"tag_name":' | cut -d'"' -f 4)" INSTALLED="$($PGWEB --version | cut -d ' ' -f 2)" if [ "$INSTALLED" != "$LATEST" ] ; then opt="$(printf 'Yes\nNo\n' | menu "Newer pgweb version available, update?")" if [ "$opt" = "Yes" ] ; then echo "Updating pgweb..." if ! curl -L --progress-bar -o "$PGWEB.zip" \ https://github.com/sosedoff/pgweb/releases/latest/download/pgweb_linux_amd64.zip ; then echo "Error updating pgweb" exit 1 fi (cd "${PGWEB%/*}" && unzip "$PGWEB.zip") chmod +x "$PGWEB" fi unset opt fi exec $PGWEB