# ---------------------------------------------------------------------------- # # EOL - End of life detection - Warn before reaching end of life # # detect version of PostgreSQL # # ---------------------------------------------------------------------------- # 2020-02-25 v1.0 <axel.hahn@iml.unibe.ch> initial version # 2021-03-26 v1.1 <axel.hahn@iml.unibe.ch> add locations if postgres is not in PATH # 2021-08-23 v1.1 <martin.gasser@iml.unibe.ch> added location for v11 # 2022-04-07 v1.2 <martin.gasser@iml.unibe.ch> added location for v13 # ---------------------------------------------------------------------------- # # WORKAROUND: add additional locations in $PATH # #otherlocations="/usr/pgsql-10/bin/ /some/other/postgres/location/bin/" otherlocations="/usr/pgsql-10/bin/ /usr/lib/postgresql/11/bin /usr/lib/postgresql/13/bin" POSTGRES=$( which postgres 2>/dev/null ) test -z "$POSTGRES" && for mypath in ${otherlocations} do test -x "$mypath/postgres" && POSTGRES="$mypath/postgres" done # # ----- example output # postgres --version # postgres (PostgreSQL) 9.2.24 $POSTGRES --version | cut -f 3 -d " " | cut -f 1,2 -d '.'