|
5 | 5 | postgres_bootstrap_filesystem() { |
6 | 6 | create_folder \ |
7 | 7 | "${CERT_PATH},\ |
8 | | - ${CONFIG_PATH},\ |
9 | 8 | ${LOG_PATH}" \ |
10 | 9 | postgres:postgres 755 |
11 | 10 |
|
12 | 11 | if [ -n "${CONFIG_PATH}" ] ; then |
13 | 12 | create_folder \ |
14 | 13 | "${CONFIG_PATH}" \ |
15 | | - postgres:postgres 755 |
| 14 | + postgres:postgres 750 |
16 | 15 | fi |
17 | 16 |
|
18 | 17 | create_folder \ |
19 | | - "${DATA_PATH},\ |
| 18 | + "/etc/postgres,\ |
| 19 | + ${DATA_PATH},\ |
20 | 20 | ${WAL_PATH},\ |
21 | 21 | /var/run/postgresql" \ |
22 | 22 | postgres:postgres 700 |
|
84 | 84 | EOSQL |
85 | 85 | fi |
86 | 86 |
|
87 | | - if ! grep -q "${MONITOR_USER}" "${HBA_FILE}" ; then |
| 87 | + if ! ( [ -f "${HBA_FILE}" ] && grep -q "${MONITOR_USER}" "${HBA_FILE}" 2>/dev/null ); then |
88 | 88 | print_notice "[configure_monitoring] Adding '${MONITOR_USER}' to '${HBA_FILE}'" |
89 | 89 | echo "host all ${MONITOR_USER} localhost md5" | silent tee -a "${HBA_FILE}" |
90 | 90 | fi |
@@ -121,7 +121,7 @@ postgres_configure_replication() { |
121 | 121 | EOSQL |
122 | 122 | fi |
123 | 123 |
|
124 | | - if ! grep -q "${REPLICATION_USER}" "${HBA_FILE}" ; then |
| 124 | + if ! ( [ -f "${HBA_FILE}" ] && grep -q "${REPLICATION_USER}" "${HBA_FILE}" 2>/dev/null ); then |
125 | 125 | print_notice "[configure_replication] Adding '${REPLICATION_USER}/${REPLICATION_IP_ALLOW}' to '${HBA_FILE}'" |
126 | 126 | echo "host replication ${REPLICATION_USER} ${REPLICATION_IP_ALLOW} md5" | silent tee -a "${HBA_FILE}" |
127 | 127 | fi |
@@ -222,14 +222,12 @@ postgres_configure_server() { |
222 | 222 | local key="$2" |
223 | 223 | local value="$3" |
224 | 224 | 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 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 |
233 | 231 | } |
234 | 232 |
|
235 | 233 | if [ "${SETUP_MODE,,}" = "auto" ] ; then |
|
0 commit comments