-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-upgrade
More file actions
executable file
·29 lines (23 loc) · 882 Bytes
/
docker-upgrade
File metadata and controls
executable file
·29 lines (23 loc) · 882 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
set -e
if [ "$#" -eq 0 -o "${1:0:1}" = '-' ]; then
set -- pg_upgrade "$@"
fi
if [ "$1" = 'pg_upgrade' -a "$(id -u)" = '0' ]; then
mkdir -p "$PGDATAOLD" "$PGDATANEW"
chmod 700 "$PGDATAOLD" "$PGDATANEW"
chown postgres .
chown -R postgres "$PGDATAOLD" "$PGDATANEW"
exec gosu postgres "$BASH_SOURCE" "$@"
fi
if [ "$1" = 'pg_upgrade' ]; then
if [ ! -s "$PGDATANEW/PG_VERSION" ]; then
PGDATA="$PGDATANEW" eval "initdb $POSTGRES_INITDB_ARGS"
fi
fi
eval "$@"
cp -f $PGDATAOLD/pg_hba.conf $PGDATANEW/pg_hba.conf
echo "Starting PostGIS upgrade"
pg_ctl -D "$PGDATANEW" start
psql -U postgres -t -c "SELECT datname FROM pg_database WHERE datname NOT IN ('template0', 'template1', 'postgres')" | xargs -l1 -I{} psql -U postgres -d {} -c "ALTER EXTENSION postgis UPDATE; SELECT postgis_extensions_upgrade(); DROP EXTENSION postgis_raster;"
pg_ctl -D "$PGDATANEW" stop