Fix: wwwroot is not configurable (#195)

This commit is contained in:
Fatih Ateş
2022-01-26 10:40:10 +03:00
committed by GitHub
parent fc11dd5861
commit b9ef0d08b9
2 changed files with 8 additions and 3 deletions

View File

@@ -335,13 +335,17 @@ moodle_configure_wwwroot() {
# sed replacement notes:
# - The ampersand ('&') is escaped due to sed replacing any non-escaped ampersand characters with the matched string
# - For the replacement text to be multi-line, an \ needs to be specified to escape the newline character
local -r MOODLE_HOST="${MOODLE_HOST:+"'${MOODLE_HOST}'"}"
local -r host="${MOODLE_HOST:-"\$_SERVER['HTTP_HOST']"}"
local -r conf_to_replace="if (empty(\$_SERVER['HTTP_HOST'])) {\\
\$_SERVER['HTTP_HOST'] = '127.0.0.1:${http_port}';\\
\$_SERVER['HTTP_HOST'] = '127.0.0.1:${http_port}';\\
}\\
if (isset(\$_SERVER['HTTPS']) \&\& \$_SERVER['HTTPS'] == 'on') {\\
\$CFG->wwwroot = 'https://' . \$_SERVER['HTTP_HOST'];\\
\$CFG->wwwroot = 'https://' . ${host};\\
} else {\\
\$CFG->wwwroot = 'http://' . \$_SERVER['HTTP_HOST'];\\
\$CFG->wwwroot = 'http://' . ${host};\\
}"
replace_in_file "$MOODLE_CONF_FILE" "\\\$CFG->wwwroot\s*=.*" "$conf_to_replace"
}

View File

@@ -80,6 +80,7 @@ export MOODLE_SKIP_BOOTSTRAP="${MOODLE_SKIP_BOOTSTRAP:-}" # only used during the
export MOODLE_INSTALL_EXTRA_ARGS="${MOODLE_INSTALL_EXTRA_ARGS:-}" # only used during the first initialization
export MOODLE_SITE_NAME="${MOODLE_SITE_NAME:-New Site}" # only used during the first initialization
export MOODLE_CRON_MINUTES="${MOODLE_CRON_MINUTES:-1}"
export MOODLE_HOST="${MOODLE_HOST:-}" # only used during the first initialization
# Moodle credentials
export MOODLE_USERNAME="${MOODLE_USERNAME:-user}" # only used during the first initialization