Skip to content

Commit

Permalink
Fix implementation of JOOMLA_SMTP_HOST.
Browse files Browse the repository at this point in the history
  • Loading branch information
Llewellynvdm committed Jun 13, 2024
1 parent 2df41cc commit 9b1db2a
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9b1db2a

Please sign in to comment.