2
3
mirror of https://github.com/octoleo/docker-joomla.git synced 2024-11-08 13:54:07 +00:00

Fix implementation of JOOMLA_SMTP_HOST.

This commit is contained in:
Llewellyn van der Merwe 2024-06-13 12:51:30 +02:00
parent 2df41cc0f6
commit 9b1db2a810
Signed by: Llewellyn
GPG Key ID: A9201372263741E7

View File

@ -208,6 +208,18 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
IFS=$old_IFS # Restore the original IFS value 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 # Function to install extension from URL
joomla_install_extension_via_url() { joomla_install_extension_via_url() {
local url=$1 local url=$1
@ -281,6 +293,20 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
done done
fi 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 # fix the configuration.php ownership
if [ "$uid" = '0' ] && [ "$(stat -c '%u:%g' configuration.php)" != "$user:$group" ]; then if [ "$uid" = '0' ] && [ "$(stat -c '%u:%g' configuration.php)" != "$user:$group" ]; then
# Set configuration to correct owner # Set configuration to correct owner