mirror of
https://github.com/Retropex/btcpayserver-docker.git
synced 2025-05-28 12:22:29 +02:00
parent
bc3699ba67
commit
d321c09ba0
@ -1,50 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -Eeo pipefail
|
|
||||||
shopt -s extglob
|
|
||||||
|
|
||||||
CURRENT_PGVERSION=""
|
|
||||||
EXPECTED_PGVERSION="$PG_MAJOR"
|
|
||||||
if [[ -f "/var/lib/postgresql/data/PG_VERSION" ]]; then
|
|
||||||
CURRENT_PGVERSION="$(cat /var/lib/postgresql/data/PG_VERSION)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$CURRENT_PGVERSION" != "$EXPECTED_PGVERSION" ]] && \
|
|
||||||
[[ "$CURRENT_PGVERSION" != "" ]]; then
|
|
||||||
sed -i "s/$/ $CURRENT_PGVERSION/" /etc/apt/sources.list.d/pgdg.list
|
|
||||||
apt-get update && apt-get install -y --no-install-recommends \
|
|
||||||
postgresql-$CURRENT_PGVERSION \
|
|
||||||
postgresql-contrib-$CURRENT_PGVERSION \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
export PGBINOLD="/usr/lib/postgresql/$CURRENT_PGVERSION/bin"
|
|
||||||
export PGDATABASE="/var/lib/postgresql/data"
|
|
||||||
export PGDATAOLD="/var/lib/postgresql/data/$CURRENT_PGVERSION"
|
|
||||||
export PGDATANEW="/var/lib/postgresql/data/$EXPECTED_PGVERSION"
|
|
||||||
|
|
||||||
mkdir -p "$PGDATANEW" "$PGDATAOLD"
|
|
||||||
find "$PGDATABASE" -maxdepth 1 -mindepth 1 \
|
|
||||||
-not -wholename "$PGDATAOLD" \
|
|
||||||
-not -wholename "$PGDATANEW" \
|
|
||||||
-exec mv {} "$PGDATAOLD/" \;
|
|
||||||
|
|
||||||
chmod 700 "$PGDATAOLD" "$PGDATANEW"
|
|
||||||
chown postgres .
|
|
||||||
chown -R postgres "$PGDATAOLD" "$PGDATANEW" "$PGDATABASE"
|
|
||||||
if [ ! -s "$PGDATANEW/PG_VERSION" ]; then
|
|
||||||
PGDATA="$PGDATANEW" eval "gosu postgres initdb $POSTGRES_INITDB_ARGS"
|
|
||||||
fi
|
|
||||||
|
|
||||||
gosu postgres pg_upgrade
|
|
||||||
rm $PGDATANEW/*.conf
|
|
||||||
mv $PGDATANEW/* "$PGDATABASE"
|
|
||||||
mv $PGDATAOLD/*.conf "$PGDATABASE"
|
|
||||||
rm -r "$PGDATANEW"
|
|
||||||
./delete_old_cluster.sh
|
|
||||||
rm ./analyze_new_cluster.sh
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -f "docker-entrypoint.sh" ]; then
|
|
||||||
exec ./docker-entrypoint.sh "$@"
|
|
||||||
else
|
|
||||||
exec docker-entrypoint.sh "$@"
|
|
||||||
fi
|
|
@ -3,14 +3,11 @@ version: "3"
|
|||||||
services:
|
services:
|
||||||
postgres:
|
postgres:
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
image: postgres:13.4
|
image: postgres:9.6.20
|
||||||
entrypoint: ./migrate-docker-entrypoint.sh
|
|
||||||
command: postgres
|
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_HOST_AUTH_METHOD: trust
|
POSTGRES_HOST_AUTH_METHOD: trust
|
||||||
volumes:
|
volumes:
|
||||||
- "postgres_datadir:/var/lib/postgresql/data"
|
- "postgres_datadir:/var/lib/postgresql/data"
|
||||||
- "./postgres/migrate-docker-entrypoint.sh:/migrate-docker-entrypoint.sh:ro"
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
postgres_datadir:
|
postgres_datadir:
|
||||||
|
Loading…
Reference in New Issue
Block a user