8
8
9
9
if [ ! -d " /var/lib/postgresql/data/pgdata" ]; then
10
10
11
- # This uses the "archival" methoc
11
+ # ARCHIVAL METHOD
12
12
# echo "Creating /var/lib/postgresql/data/pgdata..."
13
13
# mkdir -p /var/lib/postgresql/data/pgdata
14
14
#
@@ -20,13 +20,14 @@ if [ ! -d "/var/lib/postgresql/data/pgdata" ]; then
20
20
#
21
21
# echo "Removing archive..."
22
22
# rm /var/lib/postgresql/data/pgdata/data.tar.gz
23
+ # END ARCHIVAL METHOD
23
24
24
25
# SYMLINK METHOD
25
26
echo " Creating /var/lib/postgresql/data/pgdata..."
26
27
mkdir -p /var/lib/postgresql/data
27
-
28
28
echo " Create a symbolic link from /var/lib/postgresql/data/pgdata to /tmp/data"
29
29
ln -s /tmp/data /var/lib/postgresql/data/pgdata
30
+ # END SYMLINK METHOD
30
31
31
32
echo " Starting database..."
32
33
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
36
37
sleep 1
37
38
done
38
39
39
- echo " Changing password if POSTGRES_PASSWORD is set..."
40
40
if [ -n " $POSTGRES_PASSWORD " ]; then
41
+ echo " Changing password via POSTGRES_PASSWORD environment variable..."
41
42
PGPASSWORD=postgres psql -c " ALTER USER postgres WITH PASSWORD '$POSTGRES_PASSWORD ';"
42
43
elif [ -n " $POSTGRES_PASSWORD_FILE " ]; then
44
+ echo " Changing password via POSTGRES_PASSWORD_FILE environment variable..."
43
45
PGPASSWORD=postgres psql -c " ALTER USER postgres WITH PASSWORD '$( cat " $POSTGRES_PASSWORD_FILE " ) ';"
46
+ else
47
+ echo " No password set. Skipping password change..."
44
48
fi
45
49
46
50
echo " Renaming postgres user if necessary..."
0 commit comments