From 75a32f6cf0d39339b7f7e978f52e72a0edb33761 Mon Sep 17 00:00:00 2001 From: Simon L Date: Fri, 16 Jun 2023 15:15:16 +0200 Subject: [PATCH] only modify postgresql.conf if it exists Signed-off-by: Simon L --- Containers/postgresql/start.sh | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/Containers/postgresql/start.sh b/Containers/postgresql/start.sh index 8f033b7a..75a86abd 100644 --- a/Containers/postgresql/start.sh +++ b/Containers/postgresql/start.sh @@ -146,16 +146,19 @@ if ! [ -f "$DATADIR/PG_VERSION" ] && ! [ -f "$DUMP_FILE" ]; then rm -rf "${DATADIR:?}/"* fi -echo "Setting max connections..." -MEMORY=$(awk '/MemTotal/ {printf "%d", $2/1024}' /proc/meminfo) -MAX_CONNECTIONS=$((MEMORY/50+3)) -if [ -n "$MAX_CONNECTIONS" ]; then - sed -i "s|^max_connections =.*|max_connections = $MAX_CONNECTIONS|" "/var/lib/postgresql/data/postgresql.conf" -fi +# Modify postgresql.conf +if [ -f "/var/lib/postgresql/data/postgresql.conf" ]; then + echo "Setting max connections..." + MEMORY=$(awk '/MemTotal/ {printf "%d", $2/1024}' /proc/meminfo) + MAX_CONNECTIONS=$((MEMORY/50+3)) + if [ -n "$MAX_CONNECTIONS" ]; then + sed -i "s|^max_connections =.*|max_connections = $MAX_CONNECTIONS|" "/var/lib/postgresql/data/postgresql.conf" + fi -# Modify conf -if grep -q "#log_checkpoints" /var/lib/postgresql/data/postgresql.conf; then - sed -i 's|#log_checkpoints.*|log_checkpoints = off|' /var/lib/postgresql/data/postgresql.conf + # Modify conf + if grep -q "#log_checkpoints" /var/lib/postgresql/data/postgresql.conf; then + sed -i 's|#log_checkpoints.*|log_checkpoints = off|' /var/lib/postgresql/data/postgresql.conf + fi fi # Catch docker stop attempts