debian/pg_createconfig_patroni: Correctly determine prefix length in $NETWORK.

This commit is contained in:
Dominik George 2020-08-07 17:39:43 +02:00
parent e162d13210
commit 08dd948377
No known key found for this signature in database
GPG key ID: B79A3C16A0C4F296
2 changed files with 8 additions and 1 deletions

3
debian/changelog vendored
View file

@ -1,5 +1,8 @@
patroni (1.6.5-5) UNRELEASED; urgency=medium
[ Dominik George ]
* debian/pg_createconfig_patroni: Correctly determine prefix length
in $NETWORK.
-- Debian PostgreSQL Maintainers <team+postgresql@tracker.debian.org> Wed, 03 Jun 2020 16:11:21 +0200

View file

@ -185,7 +185,11 @@ fi
if [ -z "$NETWORK" ]; then
if [ -x /bin/ip ]; then
NETWORK=$(/bin/ip -4 route get 8.8.8.8 | grep ^8.8.8.8 | sed -e s/.*src.// -e s/\ .*//g -e s/\.[0-9]*$/.0/)/24
ROUTE=$(/bin/ip -4 route get 8.8.8.8 | grep ^8.8.8.8)
DEV=$(echo "$ROUTE" | grep -P -o "(?<=dev )[^ ]+")
ADDRESS=$(echo "$ROUTE" | grep -P -o "(?<=src )[^ ]+")
PREFIX=$(ip -4 address show $DEV | grep -P -o "(?<=inet $ADDRESS/)[0-9]+")
NETWORK="$ADDRESS/$PREFIX"
else
echo "iproute2 package missing, cannot determine network and --network is not set"
rm -f $CONFIG_FILE