Skip to content

Commit d453bf0

Browse files
committed
ROX-19980 fix
1 parent d710e77 commit d453bf0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

image/db/rhel/scripts/custom-entrypoint.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ set -e
88

99
if [ ! -d "/var/lib/postgresql/data/pgdata" ]; then
1010

11-
# This uses the "archival" methoc
11+
# ARCHIVAL METHOD
1212
# echo "Creating /var/lib/postgresql/data/pgdata..."
1313
# mkdir -p /var/lib/postgresql/data/pgdata
1414
#
@@ -20,13 +20,14 @@ if [ ! -d "/var/lib/postgresql/data/pgdata" ]; then
2020
#
2121
# echo "Removing archive..."
2222
# rm /var/lib/postgresql/data/pgdata/data.tar.gz
23+
# END ARCHIVAL METHOD
2324

2425
# SYMLINK METHOD
2526
echo "Creating /var/lib/postgresql/data/pgdata..."
2627
mkdir -p /var/lib/postgresql/data
27-
2828
echo "Create a symbolic link from /var/lib/postgresql/data/pgdata to /tmp/data"
2929
ln -s /tmp/data /var/lib/postgresql/data/pgdata
30+
# END SYMLINK METHOD
3031

3132
echo "Starting database..."
3233
POSTGRES_PASSWORD_FILE="" POSTGRES_PASSWORD=postgres /usr/local/bin/docker-entrypoint.sh postgres -c config_file=/etc/postgresql.conf &
@@ -36,11 +37,14 @@ if [ ! -d "/var/lib/postgresql/data/pgdata" ]; then
3637
sleep 1
3738
done
3839

39-
echo "Changing password if POSTGRES_PASSWORD is set..."
4040
if [ -n "$POSTGRES_PASSWORD" ]; then
41+
echo "Changing password via POSTGRES_PASSWORD environment variable..."
4142
PGPASSWORD=postgres psql -c "ALTER USER postgres WITH PASSWORD '$POSTGRES_PASSWORD';"
4243
elif [ -n "$POSTGRES_PASSWORD_FILE" ]; then
44+
echo "Changing password via POSTGRES_PASSWORD_FILE environment variable..."
4345
PGPASSWORD=postgres psql -c "ALTER USER postgres WITH PASSWORD '$(cat "$POSTGRES_PASSWORD_FILE")';"
46+
else
47+
echo "No password set. Skipping password change..."
4448
fi
4549

4650
echo "Renaming postgres user if necessary..."

0 commit comments

Comments
 (0)