Skip to content

Commit 5f3c7e1

Browse files
committed
fix: need to account for new config handling in test utils
1 parent b2a64fd commit 5f3c7e1

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

nix/packages/lib.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@
9191
PGSODIUM_GETKEY = "${paths.getkeyScript}";
9292
READREPL_CONF_FILE = "${paths.readReplicaConfigFile}";
9393
LOGGING_CONF_FILE = "${paths.loggingConfigFile}";
94+
AUTOEXPLAIN_CONF_FILE = "${paths.autoexplainConfigFile}";
95+
PGCRON_CONF_FILE = "${paths.pgcronConfigFile}";
9496
SUPAUTILS_CONF_FILE = "${paths.supautilsConfigFile}";
9597
PG_HBA = "${paths.pgHbaConfigFile}";
9698
PG_IDENT = "${paths.pgIdentConfigFile}";

nix/tools/run-server.sh.in

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ PSQL_CONF_FILE=@PSQL_CONF_FILE@
165165
PORTNO="${PORTNO:-@PGSQL_DEFAULT_PORT@}"
166166
SUPAUTILS_CONFIG_FILE=@SUPAUTILS_CONF_FILE@
167167
LOGGING_CONFIG_FILE=@LOGGING_CONF_FILE@
168+
AUTOEXPLAIN_CONFIG_FILE=@AUTOEXPLAIN_CONF_FILE@
169+
PGCRON_CONFIG_FILE=@PGCRON_CONF_FILE@
168170
READREPL_CONFIG_FILE=@READREPL_CONF_FILE@
169171
PG_HBA_FILE=@PG_HBA@
170172
PG_IDENT_FILE=@PG_IDENT@
@@ -215,23 +217,29 @@ fi
215217
echo "NOTE: patching postgresql.conf files"
216218
cp "$PG_HBA_FILE" "$DATDIR/pg_hba.conf"
217219
cp "$PG_IDENT_FILE" "$DATDIR/pg_ident.conf"
218-
cp "$READREPL_CONFIG_FILE" "$DATDIR/04-read-replica.conf"
220+
mkdir -p "$DATDIR/postgresql-custom"
221+
mkdir -p "$DATDIR/pg_log"
222+
cp "$READREPL_CONFIG_FILE" "$DATDIR/postgresql-custom/04-read-replica.conf"
223+
cp "$AUTOEXPLAIN_CONFIG_FILE" "$DATDIR/postgresql-custom/auto_explain.conf"
224+
cp "$PGCRON_CONFIG_FILE" "$DATDIR/postgresql-custom/pg_cron.conf"
219225
mkdir -p "$DATDIR/extension-custom-scripts"
220226
cp -r "$EXTENSION_CUSTOM_SCRIPTS"/* "$DATDIR/extension-custom-scripts"
221227

228+
# Configure logging with correct log directory
229+
sed "s|log_directory = '/var/log/postgresql'|log_directory = '$DATDIR/pg_log'|" "$LOGGING_CONFIG_FILE" > "$DATDIR/postgresql-custom/00-logging.conf"
230+
222231
# Configure supautils
223-
sed "s|supautils.extension_custom_scripts_path = '/etc/postgresql-custom/extension-custom-scripts'|supautils.extension_custom_scripts_path = '$DATDIR/extension-custom-scripts'|" "$SUPAUTILS_CONFIG_FILE" > "$DATDIR/05-supautils.conf"
232+
sed "s|supautils.extension_custom_scripts_path = '/etc/postgresql-custom/extension-custom-scripts'|supautils.extension_custom_scripts_path = '$DATDIR/extension-custom-scripts'|" "$SUPAUTILS_CONFIG_FILE" > "$DATDIR/postgresql-custom/05-supautils.conf"
224233

225234
# Configure PostgreSQL
226-
sed -e "1i\\
227-
include = '$DATDIR/05-supautils.conf'" \
228-
-e "\$a\\
235+
sed -e "\$a\\
229236
pgsodium.getkey_script = '$PGSODIUM_GETKEY_SCRIPT'" \
230237
-e "\$a\\
231238
vault.getkey_script = '$PGSODIUM_GETKEY_SCRIPT'" \
232239
-e "s|data_directory = '/var/lib/postgresql/data'|data_directory = '$DATDIR'|" \
233240
-e "s|hba_file = '/etc/postgresql/pg_hba.conf'|hba_file = '$DATDIR/pg_hba.conf'|" \
234241
-e "s|ident_file = '/etc/postgresql/pg_ident.conf'|ident_file = '$DATDIR/pg_ident.conf'|" \
242+
-e "s|include_dir = '/etc/postgresql-custom'|include_dir = '$DATDIR/postgresql-custom'|" \
235243
-e "\$a\\
236244
session_preload_libraries = 'supautils'" \
237245
"$PSQL_CONF_FILE" > "$DATDIR/postgresql.conf"
@@ -243,34 +251,34 @@ orioledb_config_items() {
243251
echo "non-macos oriole conf"
244252
sed -i 's/ timescaledb,//g;' "$DATDIR/postgresql.conf"
245253
sed -i 's/db_user_namespace = off/#db_user_namespace = off/g;' "$DATDIR/postgresql.conf"
246-
sed -i 's/ timescaledb,//g; s/ plv8,//g; s/ pgjwt,//g;' "$DATDIR/05-supautils.conf"
254+
sed -i 's/ timescaledb,//g; s/ plv8,//g; s/ pgjwt,//g;' "$DATDIR/postgresql-custom/05-supautils.conf"
247255
sed -i 's/\(shared_preload_libraries.*\)'\''\(.*\)$/\1, orioledb'\''\2/' "$DATDIR/postgresql.conf"
248256
echo "default_table_access_method = 'orioledb'" >> "$DATDIR/postgresql.conf"
249257
elif [[ "$1" = "orioledb-17" && "$CURRENT_SYSTEM" = "aarch64-darwin" ]]; then
250258
# macOS specific configuration
251259
echo "macOS detected, applying macOS specific configuration"
252260
ls -la "$DATDIR"
253-
261+
254262
# Use perl instead of sed for macOS
255263
perl -pi -e 's/ timescaledb,//g' "$DATDIR/postgresql.conf"
256264
perl -pi -e 's/db_user_namespace = off/#db_user_namespace = off/g' "$DATDIR/postgresql.conf"
257-
258-
perl -pi -e 's/ timescaledb,//g' "$DATDIR/05-supautils.conf"
259-
perl -pi -e 's/ plv8,//g' "$DATDIR/05-supautils.conf"
260-
perl -pi -e 's/ pgjwt,//g' "$DATDIR/05-supautils.conf"
265+
266+
perl -pi -e 's/ timescaledb,//g' "$DATDIR/postgresql-custom/05-supautils.conf"
267+
perl -pi -e 's/ plv8,//g' "$DATDIR/postgresql-custom/05-supautils.conf"
268+
perl -pi -e 's/ pgjwt,//g' "$DATDIR/postgresql-custom/05-supautils.conf"
261269
perl -pi -e 's/(shared_preload_libraries\s*=\s*'\''.*?)'\''/\1, orioledb'\''/' "$DATDIR/postgresql.conf"
262-
270+
263271
echo "default_table_access_method = 'orioledb'" >> "$DATDIR/postgresql.conf"
264272
elif [[ "$VERSION" == "17" && "$CURRENT_SYSTEM" != "aarch64-darwin" ]]; then
265273
echo "non-macos pg 17 conf"
266274
sed -i 's/ timescaledb,//g;' "$DATDIR/postgresql.conf"
267275
sed -i 's/db_user_namespace = off/#db_user_namespace = off/g;' "$DATDIR/postgresql.conf"
268-
sed -i 's/ timescaledb,//g; s/ plv8,//g;' "$DATDIR/05-supautils.conf"
276+
sed -i 's/ timescaledb,//g; s/ plv8,//g;' "$DATDIR/postgresql-custom/05-supautils.conf"
269277
elif [[ "$VERSION" == "17" && "$CURRENT_SYSTEM" = "aarch64-darwin" ]]; then
270278
perl -pi -e 's/db_user_namespace = off/#db_user_namespace = off/g;' "$DATDIR/postgresql.conf"
271279
perl -pi -e 's/ timescaledb,//g' "$DATDIR/postgresql.conf"
272-
perl -pi -e 's/ timescaledb,//g' "$DATDIR/05-supautils.conf"
273-
perl -pi -e 's/ plv8,//g;' "$DATDIR/05-supautils.conf"
280+
perl -pi -e 's/ timescaledb,//g' "$DATDIR/postgresql-custom/05-supautils.conf"
281+
perl -pi -e 's/ plv8,//g;' "$DATDIR/postgresql-custom/05-supautils.conf"
274282
fi
275283
}
276284

0 commit comments

Comments
 (0)