Skip to content
Snippets Groups Projects
Commit ca2e27e1 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

OP#7270 Icinga: Check EOL postgres: postgres 15

parent 0b7eda12
No related branches found
No related tags found
1 merge request!273OP#7270 Icinga: Check EOL postgres: postgres 15
...@@ -5,31 +5,31 @@ ...@@ -5,31 +5,31 @@
# detect version of PostgreSQL # detect version of PostgreSQL
# #
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# 2020-02-25 v1.0 <axel.hahn@iml.unibe.ch> initial version # 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-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 # 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 # 2022-04-07 v1.2 <martin.gasser@iml.unibe.ch> added location for v13
# 2024-06-11 v1.3 <axel.hahn@iml.unibe.ch> handle placeholders in otherplaces for latest version
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# # other locations. When using placeholders (like *) then it looks to the
# WORKAROUND: add additional locations in $PATH # highest number
# otherlocations="
#otherlocations="/usr/pgsql-10/bin/ /some/other/postgres/location/bin/" /usr/pgsql-10/bin
/usr/lib/postgresql/*/bin
otherlocations="/usr/pgsql-10/bin/ /usr/lib/postgresql/11/bin /usr/lib/postgresql/13/bin" "
POSTGRES=$( which postgres 2>/dev/null ) POSTGRES=$( which postgres 2>/dev/null )
test -z "$POSTGRES" && test -z "$POSTGRES" &&
for mypath in ${otherlocations} for mypath in ${otherlocations}
do do
test -x "$mypath/postgres" && POSTGRES="$mypath/postgres" if latest=$(ls -1dtr "${mypath}" 2>/dev/null | sort -n | tail -1 ); then
test -x "$latest/postgres" && POSTGRES="$latest/postgres"
fi
done done
#
# ----- example output # ----- example output
# postgres --version # postgres --version
# postgres (PostgreSQL) 9.2.24 # postgres (PostgreSQL) 15.6 (Debian 15.6-0+deb12u1)
$POSTGRES --version | cut -f 3 -d " " | cut -f 1,2 -d '.' $POSTGRES --version | cut -f 3 -d " " | cut -f 1,2 -d '.'
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment