From c9a98f6ae55b8c9a551ae6ca065ae962581c8992 Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Mon, 6 Aug 2018 16:34:17 +0200 Subject: [PATCH] During startup make postgres owner of PGDATA dir if not already. Refs #51 --- README.md | 3 --- startup.sh | 7 +++++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d5965e8..d80fac4 100644 --- a/README.md +++ b/README.md @@ -70,9 +70,6 @@ docker create --name cartodb_pgdata sverhoeven/cartodb # Change to directory to save the Postgresql data dir (cartodb_pgdata) of the CartoDB image docker cp cartodb_pgdata:/var/lib/postgresql $PWD/cartodb_pgdata docker rm -f cartodb_pgdata -# Inside container cartodb_pgdata is owned by postgres (uid=103) user, -# it should be owned by same user on the local filesystem -sudo chown -R 103.103 $PWD/cartodb_pgdata ``` After this the CartoDB container will have a database that stays filled after restarts. diff --git a/startup.sh b/startup.sh index b807a9c..3210fbe 100755 --- a/startup.sh +++ b/startup.sh @@ -4,6 +4,13 @@ export CARTO_HOSTNAME=${CARTO_HOSTNAME:=$HOSTNAME} perl -pi -e 's/cartodb\.localhost/$ENV{"CARTO_HOSTNAME"}/g' /etc/nginx/sites-enabled/default /cartodb/config/app_config.yml /Windshaft-cartodb/config/environments/development.js +PGDATA=/var/lib/postgresql +if [ "$(stat -c %U $PGDATA)" != "postgres" ]; then +(>&2 echo "${PGDATA} not owned by postgres, updating permissions") +chown -R postgres $PGDATA +chmod 700 $PGDATA +fi + service postgresql start service redis-server start /opt/varnish/sbin/varnishd -a :6081 -T localhost:6082 -s malloc,256m -f /etc/varnish.vcl