#!/bin/bash # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # install or upgrade postgrest / frode klevstul / oct 2025 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if [ "$EUID" -ne 0 ] then echo "error: run as 'root'" exit fi # --- # postgrest # --- cd /tmp # fetch the latest release version # src: https://gist.github.com/steinwaywhw/a4cd19cda655b8249d908261a62687f8?permalink_comment_id=5097031#gistcomment-5097031 latest_version=$(curl -s https://api.github.com/repos/PostgREST/postgrest/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")') # construct download url download_url="https://github.com/PostgREST/postgrest/releases/download/${latest_version}/postgrest-${latest_version}-linux-static-x86-64.tar.xz" # download the file wget -O postgrest.tar.xz ${download_url} # extract the executable tar -xJf *.xz # move executable to correct directory mv postgrest /usr/local/bin if ! [ -d "/etc/postgrest" ] then # make dir(s) if they do not exist mkdir -p "/etc/postgrest" fi if ! [ -f "/etc/postgrest/config" ] then wget https://gt.op.fo/fro/srv-pub/raw/branch/trunk/cfg/pgr/config cp config /etc/postgrest/ echo "please add proper login data to /etc/postgrest/config!" fi