chore: Changes to Postgres to support readonly root FS (#30517)

This commit is contained in:
Shrikant Sharat Kandula 2024-01-23 10:42:18 +05:30 committed by GitHub
parent 2bde0d11c4
commit 51c91f8a67
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -390,9 +390,13 @@ init_postgres() {
echo "Checking initialized local postgres"
POSTGRES_DB_PATH="$stacks_path/data/postgres/main"
if [ -e "$POSTGRES_DB_PATH/PG_VERSION" ]; then
echo "Found existing Postgres, Skipping initialization"
chown -R postgres:postgres "$POSTGRES_DB_PATH"
mkdir -p "$POSTGRES_DB_PATH" "$TMP/pg-runtime"
# Postgres does not allow it's server to be run with super user access, we use user postgres and the file system owner also needs to be the same user postgres
chown -R postgres:postgres "$POSTGRES_DB_PATH" "$TMP/pg-runtime"
if [[ -e "$POSTGRES_DB_PATH/PG_VERSION" ]]; then
echo "Found existing Postgres, Skipping initialization"
else
echo "Initializing local postgresql database"
mkdir -p "$POSTGRES_DB_PATH"
@ -402,6 +406,7 @@ init_postgres() {
# Initialize the postgres db file system
su postgres -c "/usr/lib/postgresql/13/bin/initdb -D $POSTGRES_DB_PATH"
sed -Ei "s,^#(unix_socket_directories =).*,\\1 '$TMP/pg-runtime'," "$POSTGRES_DB_PATH/postgresql.conf"
# Start the postgres server in daemon mode
su postgres -c "/usr/lib/postgresql/13/bin/pg_ctl -D $POSTGRES_DB_PATH start"