From ea1f991c76ac41cebb4c74939f191e15d5bee136 Mon Sep 17 00:00:00 2001 From: Michael Vogl Date: Tue, 22 Oct 2024 14:10:15 +0200 Subject: [PATCH] Allow to specify postgres-client-version To install a newer client version pass a variable. https://www.postgresql.org/download/linux/ubuntu/\#apt --- features/postgres-client/README.md | 5 ++++- features/postgres-client/install.sh | 13 ++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/features/postgres-client/README.md b/features/postgres-client/README.md index f931d6a..dd446b4 100644 --- a/features/postgres-client/README.md +++ b/features/postgres-client/README.md @@ -14,6 +14,9 @@ service using the official [Postgres docker image](https://hub.docker.com/_/post ``` ## Options +| Options Id | Description | Type | Default Value | +|-----|-----|-----|-----| +| version | The postgres-client version | string | 15 | ## Customizations @@ -21,4 +24,4 @@ service using the official [Postgres docker image](https://hub.docker.com/_/post This Feature should work on recent versions of Debian/Ubuntu-based distributions with the `apt` package manager installed. -`bash` is required to execute the `install.sh` script. \ No newline at end of file +`bash` is required to execute the `install.sh` script. diff --git a/features/postgres-client/install.sh b/features/postgres-client/install.sh index 9907853..703eeee 100755 --- a/features/postgres-client/install.sh +++ b/features/postgres-client/install.sh @@ -1,6 +1,17 @@ #!/bin/sh set -e -apt-get update -y && apt-get -y install --no-install-recommends libpq-dev postgresql-client +export POSTGRES_CLIENT_VERSION="${VERSION:-"15"}" + +apt-get update -qq + +VERSION_EXISTS=$(apt-cache search --names-only postgresql-client-$POSTGRES_CLIENT_VERSION | wc -l) + +if [ "$VERSION_EXISTS" -ge 1 ]; then + apt-get install --no-install-recommends -y postgresql-client-$POSTGRES_CLIENT_VERSION +else + apt-get install --no-install-recommends -y postgresql-common + /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y && apt-get install --no-install-recommends -y postgresql-client-$POSTGRES_CLIENT_VERSION +fi rm -rf /var/lib/apt/lists/*