patroni/debian/pg_clonecluster_patroni
Michael Banck f9ee2d0854 * debian/pg_createcluster_patroni, debian/pg_clonecluster_patroni: New files,
wrapper scripts that can be used for Patroni bootstrap or standby setup.
  * debian/patroni.install: Install them in /usr/share/patroni.
2018-10-22 18:40:17 +02:00

38 lines
711 B
Bash
Executable file

#!/bin/sh
for i in "$@"
do
case $i in
--scope=*)
SCOPE="${i#*=}"
shift # past argument=value
;;
--role=*)
ROLE="${i#*=}"
shift # past argument=value
;;
--datadir=*)
DATADIR="${i#*=}"
shift # past argument=value
;;
--connstring=*)
CONNSTR="${i#*=}"
shift # past argument=value
;;
*)
# unknown option
;;
esac
done
VERSION=$(echo $SCOPE | sed -e 's/\/.*//')
CLUSTER=$(echo $SCOPE | sed -e 's/.*\///')
if [ -f /etc/postgresql/$VERSION/$CLUSTER/postgresql.conf ]
then
pg_dropcluster $VERSION $CLUSTER
fi
pg_createcluster $VERSION $CLUSTER && rm -rf $DATADIR && pg_basebackup --pgdata $DATADIR -X stream --dbname=$CONNSTR
exit $?