From 5181a2b320ae76b4a58a1ea33e36f8c76b1eae07 Mon Sep 17 00:00:00 2001 From: Brooke Hedrick Date: Mon, 4 Dec 2023 10:45:25 -0600 Subject: [PATCH] [bitnami/moodle] Handle --prefix (table prefix) being overridden via MOODLE_INSTALL_EXTRA_ARGS (#51278) * Handle --prefix (table prefix) being overridden via MOODLE_INSTALL_EXTRA_ARGS At the moment libmoodle.sh assumes a table prefix of the default mdl_ . When someone overrides this with the --prefix=xxx, then there are errors with the sql statements in libmoodle.sh that reference tables with mdl_.... Signed-off-by: Brooke Hedrick * Update libmoodle.sh Part 2 of 2 for --prefix support. Using the new mdl_prefix variable. Signed-off-by: Brooke Hedrick * Update bitnami/moodle/4.2/debian-11/rootfs/opt/bitnami/scripts/libmoodle.sh Co-authored-by: Michiel Signed-off-by: Brooke Hedrick * Update libmoodle.sh simplified version Signed-off-by: Brooke Hedrick --------- Signed-off-by: Brooke Hedrick Co-authored-by: Michiel --- .../rootfs/opt/bitnami/scripts/libmoodle.sh | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/bitnami/moodle/4.2/debian-11/rootfs/opt/bitnami/scripts/libmoodle.sh b/bitnami/moodle/4.2/debian-11/rootfs/opt/bitnami/scripts/libmoodle.sh index b7e043bf4d1c..bec8c505c94b 100644 --- a/bitnami/moodle/4.2/debian-11/rootfs/opt/bitnami/scripts/libmoodle.sh +++ b/bitnami/moodle/4.2/debian-11/rootfs/opt/bitnami/scripts/libmoodle.sh @@ -156,6 +156,15 @@ moodle_initialize() { read -r -a extra_args <<<"$MOODLE_INSTALL_EXTRA_ARGS" [[ "${#extra_args[@]}" -gt 0 ]] && moodle_install_args+=("${extra_args[@]}") + # Handle --prefix (table prefix) being overridden via MOODLE_INSTALL_EXTRA_ARGS + mdl_prefix="mdl_" + for extra_arg in "${extra_args[@]}"; do + if [[ $extra_arg == --prefix=* ]]; then + mdl_prefix=${extra_arg#--prefix=} + break + fi + done + # Setup Moodle if ! is_boolean_yes "$MOODLE_SKIP_BOOTSTRAP"; then info "Running Moodle install script" @@ -166,17 +175,17 @@ moodle_initialize() { [[ "$db_type" = "pgsql" ]] && db_remote_execute="postgresql_remote_execute" local -a db_execute_args=("$db_host" "$db_port" "$db_name" "$db_user" "$db_pass") # Configure no-reply e-mail address for SMTP - echo "INSERT INTO mdl_config (name, value) VALUES ('noreplyaddress', '${MOODLE_EMAIL}')" | "$db_remote_execute" "${db_execute_args[@]}" + echo "INSERT INTO ${mdl_prefix}config (name, value) VALUES ('noreplyaddress', '${MOODLE_EMAIL}')" | "$db_remote_execute" "${db_execute_args[@]}" # Additional Bitnami customizations - echo "UPDATE mdl_course SET summary='Moodle powered by Bitnami' WHERE id='1'" | "$db_remote_execute" "${db_execute_args[@]}" + echo "UPDATE ${mdl_prefix}course SET summary='Moodle powered by Bitnami' WHERE id='1'" | "$db_remote_execute" "${db_execute_args[@]}" # SMTP configuration if ! is_empty_value "$MOODLE_SMTP_HOST"; then info "Configuring SMTP credentials" "$db_remote_execute" "${db_execute_args[@]}" <