Fixes for pg 10 to start nicely

pull/88/head
Tim Sutton 2018-02-08 22:23:54 +02:00
rodzic 2bf076739e
commit 1250909c4e
2 zmienionych plików z 29 dodań i 15 usunięć

Wyświetl plik

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
# Commit and redeploy the user map container # Commit and redeploy the user map container
set -x
usage() usage()
{ {
cat << EOF cat << EOF
@ -18,11 +19,12 @@ OPTIONS:
-l local port (defaults to 25432) -l local port (defaults to 25432)
-u Postgres user name (defaults to 'docker') -u Postgres user name (defaults to 'docker')
-p Postgres password (defaults to 'docker') -p Postgres password (defaults to 'docker')
-d database name (defaults to 'gis') -d database cluster path (defaults to debian package defaults)
-z database name (defaults to 'gis')
EOF EOF
} }
while getopts ":h:n:v:l:u:p:d:" OPTION while getopts ":h:n:v:l:u:p:d:z:" OPTION
do do
case $OPTION in case $OPTION in
n) n)
@ -32,10 +34,10 @@ do
VOLUME=${OPTARG} VOLUME=${OPTARG}
;; ;;
l) l)
LOCALPORT=${optarg} LOCALPORT=${OPTARG}
;; ;;
u) u)
PGUSER=${optarg} PGUSER=${OPTARG}
;; ;;
p) p)
PGPASSWORD=${OPTARG} PGPASSWORD=${OPTARG}
@ -43,7 +45,10 @@ do
d) d)
DATADIR=${OPTARG} DATADIR=${OPTARG}
;; ;;
*) z)
DBNAME=${OPTARG}
;;
\?)
usage usage
exit 1 exit 1
;; ;;
@ -86,6 +91,7 @@ CMD="docker run --name="${CONTAINER_NAME}" \
-e POSTGRES_USER=${PGUSER} \ -e POSTGRES_USER=${PGUSER} \
-e POSTGRES_PASS=${PGPASSWORD} \ -e POSTGRES_PASS=${PGPASSWORD} \
-e DATADIR=${DATADIR} \ -e DATADIR=${DATADIR} \
-e POSTGRES_DBNAME=${DBNAME} \
-d -t \ -d -t \
${VOLUME_OPTION} \ ${VOLUME_OPTION} \
-p "${LOCALPORT}:5432" \ -p "${LOCALPORT}:5432" \

Wyświetl plik

@ -2,11 +2,11 @@
# This script will run as the postgres user due to the Dockerfile USER directive # This script will run as the postgres user due to the Dockerfile USER directive
DATADIR="/var/lib/postgresql/10.0/main" DATADIR="/var/lib/postgresql/10/main"
CONF="/etc/postgresql/10.0/main/postgresql.conf" CONF="/etc/postgresql/10/main/postgresql.conf"
POSTGRES="/usr/lib/postgresql/10.0/bin/postgres" POSTGRES="/usr/lib/postgresql/10/bin/postgres"
INITDB="/usr/lib/postgresql/10.0/bin/initdb" INITDB="/usr/lib/postgresql/10/bin/initdb"
SQLDIR="/usr/share/postgresql/10.0/contrib/postgis-2.2/" SQLDIR="/usr/share/postgresql/10/contrib/postgis-2.2/"
LOCALONLY="-c listen_addresses='127.0.0.1, ::1'" LOCALONLY="-c listen_addresses='127.0.0.1, ::1'"
# /etc/ssl/private can't be accessed from within container for some reason # /etc/ssl/private can't be accessed from within container for some reason
@ -18,12 +18,12 @@ rm -r /etc/ssl
mv /tmp/ssl-copy /etc/ssl mv /tmp/ssl-copy /etc/ssl
# Needed under debian, wasnt needed under ubuntu # Needed under debian, wasnt needed under ubuntu
mkdir -p /var/run/postgresql/10.0-main.pg_stat_tmp mkdir -p /var/run/postgresql/10-main.pg_stat_tmp
chmod 0777 /var/run/postgresql/10.0-main.pg_stat_tmp chmod 0777 /var/run/postgresql/10-main.pg_stat_tmp
# test if DATADIR is existent # test if DATADIR is existent
if [ ! -d $DATADIR ]; then if [ ! -d $DATADIR ]; then
echo "Creating Postgres data at $DATADIR" echo "Creating Postgres data directory at $DATADIR"
mkdir -p $DATADIR mkdir -p $DATADIR
fi fi
# needs to be done as root: # needs to be done as root:
@ -139,14 +139,22 @@ fi
# This should show up in docker logs afterwards # This should show up in docker logs afterwards
su - postgres -c "psql -l" su - postgres -c "psql -l"
PID=`cat /var/run/postgresql/10.0-main.pid` echo "Lock files"
echo "------------------------"
ls /var/run/postgresql/
echo "------------------------"
PID=`cat /var/run/postgresql/10-main.pid`
kill -TERM ${PID} kill -TERM ${PID}
# Wait for background postgres main process to exit # Wait for background postgres main process to exit
while [ "$(ls -A /var/run/postgresql/10.0-main.pid 2>/dev/null)" ]; do while [ "$(ls -A /var/run/postgresql/10-main.pid 2>/dev/null)" ]; do
sleep 1 sleep 1
done done
# Remove the lock file that may have been left behind in the above step
rm /var/run/postgresql/*.pid
echo "Postgres initialisation process completed .... restarting in foreground" echo "Postgres initialisation process completed .... restarting in foreground"
SETVARS="POSTGIS_ENABLE_OUTDB_RASTERS=1 POSTGIS_GDAL_ENABLED_DRIVERS=ENABLE_ALL" SETVARS="POSTGIS_ENABLE_OUTDB_RASTERS=1 POSTGIS_GDAL_ENABLED_DRIVERS=ENABLE_ALL"
su - postgres -c "$SETVARS $POSTGRES -D $DATADIR -c config_file=$CONF" su - postgres -c "$SETVARS $POSTGRES -D $DATADIR -c config_file=$CONF"