From bd8345cc09b79c37e0726b6f330c173e137ec480 Mon Sep 17 00:00:00 2001
From: Lukas Braun <lukas.braun@fau.de>
Date: Sun, 12 Mar 2017 16:34:22 +0100
Subject: [PATCH] test_pg.sh: search for pg_ctl in debian's paths

---
 test_pg.sh | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/test_pg.sh b/test_pg.sh
index dab00d9..9fcbcf3 100644
--- a/test_pg.sh
+++ b/test_pg.sh
@@ -2,6 +2,18 @@
 
 set -eu
 
+# Try to find a Postgres installation (Debian installs PG commands to their own dir)
+if ! which pg_ctl >/dev/null 2>/dev/null; then
+    pg_path=$(echo /usr/lib/postgresql/*/bin | grep -vF '*' | head -1)
+    if [ -n "$pg_path" ]; then
+        echo "Using PostgreSQL from $pg_path"
+        export PATH="$pg_path:$PATH"
+    else
+        echo "WARNING: Unable to find pg_ctl, skipping PostgreSQL tests"
+        exit 0
+    fi
+fi
+
 export PGHOST="$PWD/postgres_test"
 if [ $# -ge 1 ]; then
     PGHOST="$(realpath -- "$1")"
-- 
GitLab