Go to file
2024-05-08 17:01:52 +02:00
joomla-entrypoint.sh first commit 2024-05-08 17:01:52 +02:00
joomla-readme.md first commit 2024-05-08 17:01:52 +02:00
LICENSE.txt first commit 2024-05-08 17:01:52 +02:00
README.md first commit 2024-05-08 17:01:52 +02:00

Octoleo Joomla Docker fix

We add some changes to the official Joomla Docker images, this document helps us remember what these changes are.

Our own README

We have our own readme document, that replace the Joomla official readme, here in this repo its called joomla-readme.md

Changes to entrypoint.sh

We have added some code to the entrypoint, the updated version is here in this repo, and is called joomla-entrypoint.sh, the code is marked with ####### OCTOLEO ## and also listed below.

The Extra Functions

validate_url() {
 if [[ $1 =~ ^http(s)?://[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(/.*)?$ ]]; then
  return 0
 else
  return 1
 fi
}

The Extra Install actions

# Install any extensions found in the extensions urls env
if [[ -n "${JOOMLA_EXTENSIONS_URLS}" && "${#JOOMLA_EXTENSIONS_URLS}" -gt 2 ]]; then
IFS=';' read -ra ADDR <<< "$JOOMLA_EXTENSIONS_URLS"
for extension_url in "${ADDR[@]}"; do
 # Validate each URL
 if validate_url "$extension_url"; then
  # Try to install the Joomla extension from the URL
  if php cli/joomla.php extension:install --url "${extension_url}"; then
   echo >&2 "Successfully installed ${extension_url}"
  else
   echo >&2 "Failed to install ${extension_url}"
  fi
 else
  echo >&2 "Invalid URL: ${extension_url}"
 fi
done
fi
# Extract the hostname and port from JOOMLA_SMTP_HOST if it includes ':'
if [[ -n "${JOOMLA_SMTP_HOST}" && "${JOOMLA_SMTP_HOST}" == *:* ]]; then
 IFS=':' read -r hostname port <<< "${JOOMLA_SMTP_HOST}"
 JOOMLA_SMTP_HOST=$hostname
 JOOMLA_SMTP_HOST_PORT=$port
fi
# Update configuration.php if JOOMLA_SMTP_HOST is set and longer than 2 characters
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
# Update the SMTP port in configuration.php if JOOMLA_SMTP_HOST_PORT is set
 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 ownership
if [ "$uid" = '0' ] && [ "$(stat -c '%u:%g' configuration.php)" != "$user:$group" ]; then
 # Set configuration to correct owner
 if ! chown -R "$user:$group" .; then
  echo >&2
  echo >&2 "Error: Ownership of configuration.php failed to be corrected."
 fi
 # Set configuration to correct permissions
 if ! chmod 444 configuration.php; then
  echo >&2
  echo >&2 "Error: Permissions of configuration.php failed to be corrected."
 fi
fi

License

Copyright (C) 2024 Llewellyn van der Merwe. All rights reserved.
Licensed under the GNU General Public License version 2 or later; see LICENSE.txt