* debian/pg_createconfig_patroni: Add --port option and automatically assign

the next free pg-common port if not specified.
This commit is contained in:
Michael Banck 2019-01-15 16:41:13 +01:00
parent 1331953756
commit fc45e29545
2 changed files with 15 additions and 0 deletions

2
debian/changelog vendored
View file

@ -3,6 +3,8 @@ patroni (1.5.3-3) UNRELEASED; urgency=medium
[ Michael Banck ]
* debian/README.Debian: New file (Closes: #916186).
* debian/config.yml.in: Add @PORT@ option.
* debian/pg_createconfig_patroni: Add --port option and automatically assign
the next free pg-common port if not specified.
-- Debian PostgreSQL Maintainers <team+postgresql@tracker.debian.org> Mon, 14 Jan 2019 22:29:11 +0100

View file

@ -11,6 +11,10 @@ case $i in
HOSTIP="${i#*=}"
shift # past argument=value
;;
--port=*)
PORT="${i#*=}"
shift # past argument=value
;;
--force)
FORCE="y"
shift # past argument=value
@ -26,6 +30,14 @@ if [ -z "$SCOPE" ]; then
exit 1
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))
else
# validate specified port
pg_lsclusters | awk '{print $3}' | grep -q $PORT && (echo "Port $PORT already in use"; exit 1)
fi
# support both '-' and '/' as separator
if [ $(echo $SCOPE | grep -- -) ]
then
@ -78,6 +90,7 @@ cat /etc/patroni/config.yml.in | \
sed -e s/@VERSION@/${VERSION}/g \
-e s/@CLUSTER@/${CLUSTER}/g \
-e s/@HOSTIP@/${HOSTIP}/g \
-e s/@PORT@/${PORT}/g \
>> $CONFIG_FILE
# Set permissions