From 9b1db2a810d311b3d3e81f7cad91d96f5ca831f8 Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Thu, 13 Jun 2024 12:51:30 +0200 Subject: [PATCH] Fix implementation of JOOMLA_SMTP_HOST. --- docker-entrypoint.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index b335831..2a7f3d7 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -208,6 +208,18 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then IFS=$old_IFS # Restore the original IFS value } + # Function to split values by colon to get host and port + joomla_get_host_port_by_colon() { + local input=$1 # The input string to be split + local -n hostname=$2 # The variable to store the hostname (passed by reference) + local -n port=$3 # The variable to store the port (passed by reference) + local old_IFS=$IFS # Save the original IFS value + # shellcheck disable=SC2034 + # passed by reference + IFS=':' read -r hostname port <<< "$input" # Split the input by colon and store in hostname and port + IFS=$old_IFS # Restore the original IFS value + } + # Function to install extension from URL joomla_install_extension_via_url() { local url=$1 @@ -281,6 +293,20 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then done fi + if [[ -n "${JOOMLA_SMTP_HOST}" && "${JOOMLA_SMTP_HOST}" == *:* ]]; then + joomla_get_host_port_by_colon "$JOOMLA_SMTP_HOST" JOOMLA_SMTP_HOST JOOMLA_SMTP_HOST_PORT + fi + + if [[ -n "${JOOMLA_SMTP_HOST}" && "${#JOOMLA_SMTP_HOST}" -gt 2 ]]; then + chmod +w configuration.php + sed -i "s/public \$mailer = 'mail';/public \$mailer = 'smtp';/g" configuration.php + sed -i "s/public \$smtphost = 'localhost';/public \$smtphost = '${JOOMLA_SMTP_HOST}';/g" configuration.php + fi + + if [[ -n "${JOOMLA_SMTP_HOST_PORT}" ]]; then + sed -i "s/public \$smtpport = 25;/public \$smtpport = ${JOOMLA_SMTP_HOST_PORT};/g" configuration.php + fi + # fix the configuration.php ownership if [ "$uid" = '0' ] && [ "$(stat -c '%u:%g' configuration.php)" != "$user:$group" ]; then # Set configuration to correct owner