* debian/pg_createconfig_patroni: Set default port if no clusters exist yet.

This commit is contained in:
Michael Banck 2019-01-15 18:09:30 +01:00
parent 9c475d93c7
commit e22dafae50

View file

@ -33,6 +33,10 @@ fi
if [ -z "$PORT" ]; then
# try to guess next free port
PORT=$(($(pg_lsclusters | awk '{print $3}' | grep -v Port | sort -n | tail -1) + 1))
if [ "$PORT" -eq 1 ]; then
# No cluster exists yet, use default port
PORT=5432
fi
else
# validate specified port
pg_lsclusters | awk '{print $3}' | grep -q $PORT && echo "Port $PORT already in use" && exit 1