add support for USERMAP_* env variables

This commit is contained in:
Tim Neumann
2015-05-26 22:18:56 +02:00
parent 18c17a1a52
commit df2a0478d0
2 changed files with 31 additions and 4 deletions
+15
View File
@@ -6,6 +6,18 @@ PG_CONFDIR="/etc/postgresql/${PG_VERSION}/main"
PG_BINDIR="/usr/lib/postgresql/${PG_VERSION}/bin"
PG_DATADIR="${PG_HOME}/${PG_VERSION}/main"
if [ -n "${USERMAP_UID}" ] || [ -n "${USERMAP_GID}" ]; then
if [ -n "${USERMAP_UID}" ] && [ -n "${USERMAP_GID}" ]; then
groupmod -g ${USERMAP_GID} postgres
usermod -u ${USERMAP_UID} -g ${USERMAP_GID} postgres
else
echo ""
echo "WARNING: "
echo " Please specify USERMAP_UID AND USERMAP_GID or neither. Not changing user id..."
echo ""
fi
fi
# set this env variable to true to enable a line in the
# pg_hba.conf file to trust samenet. this can be used to connect
# from other containers on the same host without authentication
@@ -16,6 +28,9 @@ DB_USER=${DB_USER:-}
DB_PASS=${DB_PASS:-}
DB_UNACCENT=${DB_UNACCENT:false}
# fix ownership of ${PG_CONFDIR} (may be necessary if USERMAP_* was set)
chown -R postgres:postgres ${PG_CONFDIR}
# fix permissions and ownership of ${PG_HOME}
mkdir -p -m 0700 ${PG_HOME}
chown -R postgres:postgres ${PG_HOME}