Skip to content

Commit 40d933c

Browse files
committed
3.3.0pre
1 parent 883307e commit 40d933c

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

rootfs/container/functions/10-postgres

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ EOF
8484
EOSQL
8585
fi
8686

87-
if ! grep -q "${MONITOR_USER}" "${HBA_FILE}" ; then
87+
if ! ( [ -f "${HBA_FILE}" ] && grep -q "${MONITOR_USER}" "${HBA_FILE}" 2>/dev/null ); then
8888
print_notice "[configure_monitoring] Adding '${MONITOR_USER}' to '${HBA_FILE}'"
8989
echo "host all ${MONITOR_USER} localhost md5" | silent tee -a "${HBA_FILE}"
9090
fi
@@ -121,7 +121,7 @@ postgres_configure_replication() {
121121
EOSQL
122122
fi
123123

124-
if ! grep -q "${REPLICATION_USER}" "${HBA_FILE}" ; then
124+
if ! ( [ -f "${HBA_FILE}" ] && grep -q "${REPLICATION_USER}" "${HBA_FILE}" 2>/dev/null ); then
125125
print_notice "[configure_replication] Adding '${REPLICATION_USER}/${REPLICATION_IP_ALLOW}' to '${HBA_FILE}'"
126126
echo "host replication ${REPLICATION_USER} ${REPLICATION_IP_ALLOW} md5" | silent tee -a "${HBA_FILE}"
127127
fi
@@ -222,14 +222,12 @@ postgres_configure_server() {
222222
local key="$2"
223223
local value="$3"
224224
local pattern="^${key}[[:space:]]*="
225-
if grep -qE "${pattern}" "${file}"; then
226-
s6-setuidgid postgres sed \
227-
-i \
228-
-E "s|${pattern}[[:space:]]*.*|${key} = ${value}|g"
229-
"${file}"
230-
else
231-
echo "${key} = ${value}" | s6-setuidgid postgres tee -a "${file}"
232-
fi
225+
# Only attempt grep/sed if the file exists; silence grep to prevent noisy errors
226+
if [ -f "${file}" ] && grep -qE "${pattern}" "${file}" 2>/dev/null; then
227+
s6-setuidgid postgres sed -i -E "s|${pattern}[[:space:]]*.*|${key} = ${value}|g" "${file}"
228+
else
229+
echo "${key} = ${value}" | silent s6-setuidgid postgres tee -a "${file}"
230+
fi
233231
}
234232

235233
if [ "${SETUP_MODE,,}" = "auto" ] ; then

rootfs/container/run/available/10-postgres/run

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ case "${LOG_TYPE,,}" in
1313
esac
1414

1515
if [ "${SETUP_MODE,,}" = "auto" ] ; then
16-
local engine_config="/etc/postgres/container.conf"
16+
engine_config="/etc/postgres/container.conf"
1717
else
18-
local engine_config="${CONFIG_PATH%/}/${CONFIG_FILE}"
18+
engine_config="${CONFIG_PATH%/}/${CONFIG_FILE}"
1919
fi
2020

2121
liftoff
2222

2323
print_start "Starting PostgreSQL $(psql --version | head -n 1 | awk '{print $NF}')"
2424
TZ="${TIMEZONE}" ${hide_output} exec s6-setuidgid postgres postgres \
25-
--config_file="${engine_config}" ${SERVER_ARGS}
25+
--config_file="${engine_config}" ${SERVER_ARGS}

0 commit comments

Comments
 (0)