Commit
·
a603a7e
1
Parent(s):
6ff9480
initialize postgres directly as postgres user
Browse files- docker-entrypoint-wrapper.sh +6 -10
docker-entrypoint-wrapper.sh
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
|
3 |
# Create necessary directories in the persistent /data volume
|
4 |
echo "Creating necessary directories in the persistent /data volume..."
|
5 |
-
mkdir -p /data/postgresql/data /data/postgresql/run
|
6 |
-
chmod 0700 /data/postgresql/data
|
7 |
-
chmod 0755 /data/postgresql/run
|
8 |
|
9 |
# Initialize PostgreSQL if not already initialized
|
10 |
echo "Initializing PostgreSQL if not already initialized..."
|
@@ -13,16 +13,12 @@ if [ ! -f "/data/postgresql/data/PG_VERSION" ]; then
|
|
13 |
su postgres -c "initdb -D /data/postgresql/data"
|
14 |
|
15 |
# Modify pg_hba.conf to allow local connections
|
16 |
-
echo
|
17 |
-
echo
|
18 |
fi
|
19 |
|
20 |
-
# Ensure proper ownership
|
21 |
-
echo "Ensuring proper ownership..."
|
22 |
-
chown -R postgres:postgres /data/postgresql/data /data/postgresql/run
|
23 |
-
|
24 |
# Start PostgreSQL with the persistent directories
|
25 |
-
echo "Starting PostgreSQL
|
26 |
su postgres -c "pg_ctl -D /data/postgresql/data -o '-c listen_addresses=*' -o '-c unix_socket_directories=/data/postgresql/run' start"
|
27 |
|
28 |
# Create database and roles
|
|
|
2 |
|
3 |
# Create necessary directories in the persistent /data volume
|
4 |
echo "Creating necessary directories in the persistent /data volume..."
|
5 |
+
su postgres -c "mkdir -p /data/postgresql/data /data/postgresql/run"
|
6 |
+
su postgres -c "chmod 0700 /data/postgresql/data"
|
7 |
+
su postgres -c "chmod 0755 /data/postgresql/run"
|
8 |
|
9 |
# Initialize PostgreSQL if not already initialized
|
10 |
echo "Initializing PostgreSQL if not already initialized..."
|
|
|
13 |
su postgres -c "initdb -D /data/postgresql/data"
|
14 |
|
15 |
# Modify pg_hba.conf to allow local connections
|
16 |
+
su postgres -c "echo 'local all all trust' > /data/postgresql/data/pg_hba.conf"
|
17 |
+
su postgres -c "echo 'host all all 127.0.0.1/32 trust' >> /data/postgresql/data/pg_hba.conf"
|
18 |
fi
|
19 |
|
|
|
|
|
|
|
|
|
20 |
# Start PostgreSQL with the persistent directories
|
21 |
+
echo "Starting PostgreSQL..."
|
22 |
su postgres -c "pg_ctl -D /data/postgresql/data -o '-c listen_addresses=*' -o '-c unix_socket_directories=/data/postgresql/run' start"
|
23 |
|
24 |
# Create database and roles
|