8 Commits

2 changed files with 377 additions and 136 deletions

View File

@ -1,4 +1,9 @@
# Octojoom - Easy Docker Deployment <h2><img align="middle" src="https://raw.githubusercontent.com/odb/official-bash-logo/master/assets/Logos/Icons/PNG/64x64.png" >
Octojoom - Easy Joomla! Docker Deployment
</h2>
Written by Llewellyn van der Merwe (@llewellynvdm)
With this script we can easily deploy docker containers of Joomla and Openssh. This combination of these tools give rise to a powerful and very secure shared development environment. With this script we can easily deploy docker containers of Joomla and Openssh. This combination of these tools give rise to a powerful and very secure shared development environment.
This program has **command input** options as seen in the menus below, but these command are _not the only way_ to set these values. This program has **command input** options as seen in the menus below, but these command are _not the only way_ to set these values.
@ -8,6 +13,8 @@ There are more than one .env file and the script will set those up for you whene
the script will check if those values exist, and if they don't it will ask for them, and store them automatically for future use. the script will check if those values exist, and if they don't it will ask for them, and store them automatically for future use.
That same time the output message to the terminal will show you where the specific .env file can be found. That same time the output message to the terminal will show you where the specific .env file can be found.
Linted by [#ShellCheck](https://github.com/koalaman/shellcheck)
> program only for ubuntu/debian systems at this time (should you like to use it on other OS's please open and issue...) > program only for ubuntu/debian systems at this time (should you like to use it on other OS's please open and issue...)
--- ---

View File

@ -1,8 +1,11 @@
#!/bin/bash #!/bin/bash
# The most recent program version. # The most recent program version.
_VERSION="3.4.2" _VERSION="3.6.0"
_V="3.4" _V="3.6"
# Bash version required
_bash_v=4
# The program full name # The program full name
PROGRAM_NAME="Octojoom" PROGRAM_NAME="Octojoom"
@ -13,6 +16,32 @@ SERVER_HOSTNAME="$(hostname)"
# Set the back title # Set the back title
BACK_TITLE=" Octoleo | ${USER}@${SERVER_HOSTNAME}" BACK_TITLE=" Octoleo | ${USER}@${SERVER_HOSTNAME}"
#####################################################################################################################VDM
######################################## The environment preparation
# Set OS number
OS_NUMBER=0 # Unknown
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
OS_NUMBER=1
elif [[ "$OSTYPE" == "darwin"* ]]; then
OS_NUMBER=2
elif [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
OS_NUMBER=3
fi
# Function to check Bash version
check_bash_version() {
local bash_version="$1"
local version_string="$BASH_VERSION"
local major_version="${version_string%%.*}"
local rest="${version_string#*.}"
local minor_version="${rest%%.*}"
if (( major_version < bash_version )) || (( major_version == bash_version && minor_version < 0 )); then
echo >&2 "ERROR: ${PROGRAM_NAME} v${_VERSION} script requires Bash version ${bash_version}.0 or above."
exit 1
fi
}
# Check for the appropriate version of Bash
check_bash_version "$_bash_v"
# make sure whiptail is installed # make sure whiptail is installed
command -v whiptail >/dev/null 2>&1 || { command -v whiptail >/dev/null 2>&1 || {
echo >&2 "ERROR: ${PROGRAM_NAME} v${_VERSION} script require whiptail." echo >&2 "ERROR: ${PROGRAM_NAME} v${_VERSION} script require whiptail."
@ -28,57 +57,120 @@ command -v awk >/dev/null 2>&1 || {
echo >&2 "ERROR: ${PROGRAM_NAME} v${_VERSION} script require awk." echo >&2 "ERROR: ${PROGRAM_NAME} v${_VERSION} script require awk."
exit 1 exit 1
} }
# Check if Docker is installed. # make sure rsync is installed (hmmm not always)
if ! command -v docker &>/dev/null; then #command -v rsync >/dev/null 2>&1 || {
# If Docker is not installed, ask the user if they want to install it. # echo >&2 "ERROR: ${PROGRAM_NAME} v${_VERSION} script require rsync."
if whiptail --yesno "Docker is not installed. Do you want to install it now?" \ # exit 1
--backtitle "${BACK_TITLE}" 10 60; then #}
# If the user chooses Yes, install Docker. # Function to check and install Docker on Linux
echo "Installing Docker..." install_docker_linux() {
echo "Installing Docker on Linux..."
# Add Docker GPG key and repository to sources.list. # Add Docker GPG key and repository to sources.list.
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Update package index and install Docker. # Update package index and install Docker.
sudo apt-get update sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io -y sudo apt-get install docker-ce docker-ce-cli containerd.io -y
# Add the current user to the docker group. # Add the current user to the docker group.
sudo groupadd docker sudo groupadd docker
sudo usermod -aG docker "$USER" sudo usermod -aG docker "$USER"
# Enable and start the Docker service. # Enable and start the Docker service.
sudo systemctl enable docker.service sudo systemctl enable docker.service
sudo systemctl start docker.service sudo systemctl start docker.service
echo "Docker is installed." echo "Docker is installed."
}
# Function to check and install Docker on macOS
install_docker_macos() {
echo "Installing Docker on macOS..."
brew install --cask docker
open /Applications/Docker.app
echo "Docker is installed. Please follow the prompts to complete the installation."
}
# Function to check and install Docker on Windows (MSYS/Cygwin)
install_docker_windows() {
echo "Please download and install Docker Desktop from https://www.docker.com/products/docker-desktop"
echo "Docker Desktop is required for Windows environments."
exit 0
}
# Check if Docker is installed
if ! command -v docker &>/dev/null; then
# If Docker is not installed, ask the user if they want to install it
if whiptail --yesno "Docker is not installed. Do you want to install it now?" \
--backtitle "${BACK_TITLE}" 10 60; then
# If the user chooses Yes, install Docker based on the OS
case "$OS_NUMBER" in
1)
install_docker_linux
;;
2)
install_docker_macos
;;
3)
install_docker_windows
;;
*)
echo >&2 "ERROR: Unsupported operating system."
exit 1
;;
esac
else else
# If the user chooses No, exit the script with an error message. # If the user chooses No, exit the script with an error message
echo >&2 "ERROR: ${PROGRAM_NAME} v${_VERSION} script require docker." echo >&2 "ERROR: ${PROGRAM_NAME} v${_VERSION} script requires Docker."
exit 1 exit 1
fi fi
fi fi
# Check if Docker Compose is installed. # Function to install Docker Compose on Linux
if ! command -v docker-compose &>/dev/null; then install_docker_compose_linux() {
# If Docker Compose is not installed, ask the user if they want to install it. echo "Installing Docker Compose on Linux..."
if whiptail --yesno "Docker Compose is not installed. Do you want to install it now?" \
--backtitle "${BACK_TITLE}" 10 60; then
# If the user chooses Yes, install Docker Compose.
echo "Installing Docker Compose..."
# Download the latest Docker Compose binary. # Download the latest Docker Compose binary.
COMPOSE_VERSION=$(curl --silent https://api.github.com/repos/docker/compose/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') COMPOSE_VERSION=$(curl --silent https://api.github.com/repos/docker/compose/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
sudo curl -SL "https://github.com/docker/compose/releases/download/$COMPOSE_VERSION/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose sudo curl -SL "https://github.com/docker/compose/releases/download/$COMPOSE_VERSION/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
# Make the Docker Compose binary executable. # Make the Docker Compose binary executable.
sudo chmod +x /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
echo "Docker Compose is installed." echo "Docker Compose is installed."
}
# Function to install Docker Compose on macOS
install_docker_compose_macos() {
echo "Installing Docker Compose on macOS..."
# Download the latest Docker Compose binary.
COMPOSE_VERSION=$(curl --silent https://api.github.com/repos/docker/compose/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
sudo curl -SL "https://github.com/docker/compose/releases/download/$COMPOSE_VERSION/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
# Make the Docker Compose binary executable.
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/local/bin/docker-compose
echo "Docker Compose is installed."
}
# Function to install Docker Compose on Windows (MSYS/Cygwin)
install_docker_compose_windows() {
echo "Please download Docker Compose from https://github.com/docker/compose/releases"
echo "and place it in a directory included in your PATH."
exit 0
}
# Check if Docker Compose is installed
if ! command -v docker-compose &>/dev/null; then
# If Docker Compose is not installed, ask the user if they want to install it
if whiptail --yesno "Docker Compose is not installed. Do you want to install it now?" \
--backtitle "${BACK_TITLE}" 10 60; then
# If the user chooses Yes, install Docker Compose based on the OS
case "$OS_NUMBER" in
1)
install_docker_compose_linux
;;
2)
install_docker_compose_macos
;;
3)
install_docker_compose_windows
;;
*)
echo >&2 "ERROR: Unsupported operating system."
exit 1
;;
esac
else else
# If the user chooses No, exit the script with an error message. # If the user chooses No, exit the script with an error message
echo >&2 "ERROR: ${PROGRAM_NAME} v${_VERSION} script require docker-compose." echo >&2 "ERROR: ${PROGRAM_NAME} v${_VERSION} script requires docker-compose."
exit 1 exit 1
fi fi
fi fi
@ -358,22 +450,22 @@ function joomla__TRuST__setup() {
setSecureCloudflareState setSecureCloudflareState
# add joomla labels # add joomla labels
if $VDM_SECURE_CLOUDFLARE; then if $VDM_SECURE_CLOUDFLARE; then
VDM_JOOMLA_SECURE_LABELS+=$(getYMLine3 "- \"traefik.http.routers.joomla_${VDM_KEY}.entrypoints=web\"") VDM_JOOMLA_SECURE_LABELS+=$(getYMLine3 "- \"traefik.http.routers.joomla${VDM_KEY}.entrypoints=web\"")
else else
VDM_JOOMLA_SECURE_LABELS+=$(getYMLine3 "- \"traefik.http.routers.joomla_${VDM_KEY}.entrypoints=${VDM_ENTRY_POINT}\"") VDM_JOOMLA_SECURE_LABELS+=$(getYMLine3 "- \"traefik.http.routers.joomla${VDM_KEY}.entrypoints=${VDM_ENTRY_POINT}\"")
VDM_JOOMLA_SECURE_LABELS+=$(getYMLine3 "- \"traefik.http.routers.joomla_${VDM_KEY}.tls.certresolver=vdmresolver\"") VDM_JOOMLA_SECURE_LABELS+=$(getYMLine3 "- \"traefik.http.routers.joomla${VDM_KEY}.tls.certresolver=vdmresolver\"")
fi fi
VDM_JOOMLA_SECURE_LABELS+=$(getYMLine3 "- \"traefik.http.routers.joomla_${VDM_KEY}.service=joomla_${VDM_KEY}\"") VDM_JOOMLA_SECURE_LABELS+=$(getYMLine3 "- \"traefik.http.routers.joomla${VDM_KEY}.service=joomla${VDM_KEY}\"")
VDM_JOOMLA_SECURE_LABELS+=$(getYMLine3 "- \"traefik.http.services.joomla_${VDM_KEY}.loadbalancer.server.port=80\"") VDM_JOOMLA_SECURE_LABELS+=$(getYMLine3 "- \"traefik.http.services.joomla${VDM_KEY}.loadbalancer.server.port=80\"")
# add phpmyadmin labels # add phpmyadmin labels
if $VDM_SECURE_CLOUDFLARE; then if $VDM_SECURE_CLOUDFLARE; then
VDM_PHPMYADMIN_SECURE_LABELS+=$(getYMLine3 "- \"traefik.http.routers.phpmyadmin_${VDM_KEY}.entrypoints=web\"") VDM_PHPMYADMIN_SECURE_LABELS+=$(getYMLine3 "- \"traefik.http.routers.phpmyadmin${VDM_KEY}.entrypoints=web\"")
else else
VDM_PHPMYADMIN_SECURE_LABELS+=$(getYMLine3 "- \"traefik.http.routers.phpmyadmin_${VDM_KEY}.entrypoints=${VDM_ENTRY_POINT}\"") VDM_PHPMYADMIN_SECURE_LABELS+=$(getYMLine3 "- \"traefik.http.routers.phpmyadmin${VDM_KEY}.entrypoints=${VDM_ENTRY_POINT}\"")
VDM_PHPMYADMIN_SECURE_LABELS+=$(getYMLine3 "- \"traefik.http.routers.phpmyadmin_${VDM_KEY}.tls.certresolver=vdmresolver\"") VDM_PHPMYADMIN_SECURE_LABELS+=$(getYMLine3 "- \"traefik.http.routers.phpmyadmin${VDM_KEY}.tls.certresolver=vdmresolver\"")
fi fi
VDM_PHPMYADMIN_SECURE_LABELS+=$(getYMLine3 "- \"traefik.http.routers.phpmyadmin_${VDM_KEY}.service=phpmyadmin_${VDM_KEY}\"") VDM_PHPMYADMIN_SECURE_LABELS+=$(getYMLine3 "- \"traefik.http.routers.phpmyadmin${VDM_KEY}.service=phpmyadmin${VDM_KEY}\"")
VDM_PHPMYADMIN_SECURE_LABELS+=$(getYMLine3 "- \"traefik.http.services.phpmyadmin_${VDM_KEY}.loadbalancer.server.port=80\"") VDM_PHPMYADMIN_SECURE_LABELS+=$(getYMLine3 "- \"traefik.http.services.phpmyadmin${VDM_KEY}.loadbalancer.server.port=80\"")
else else
VDM_REMOVE_SECURE="#" VDM_REMOVE_SECURE="#"
VDM_ENTRY_POINT="web" VDM_ENTRY_POINT="web"
@ -462,33 +554,33 @@ function joomla__TRuST__setup() {
$reset_volume && VDM_VOLUMES='' $reset_volume && VDM_VOLUMES=''
# add the projects path # add the projects path
setContainerEnvVariable "VDM_PROJECT_PATH=\"${VDM_PROJECT_PATH}\"" setContainerEnvVariable "VDM_PROJECT_PATH=\"${VDM_PROJECT_PATH}\""
# only if in expert mode set the container user detail id needed
if isExpert; then
# ask if we should add mailcatcher # ask if we should add mailcatcher
if (whiptail --yesno "Would you also like to enable mailcatcher for these ${VDM_CONTAINER_TYPE^} containers" \ if (whiptail --yesno "Would you also like to enable mailcatcher for these ${VDM_CONTAINER_TYPE^} containers" \
--defaultno --title "Enable Mailcatcher" --backtitle "${BACK_TITLE}" 8 112); then --defaultno --title "Enable Mailcatcher" --backtitle "${BACK_TITLE}" 8 112); then
VDM_EXTRA_CONTAINER_STUFF=$(getYMLine1 "mailcatcher_${VDM_KEY}:") VDM_EXTRA_CONTAINER_STUFF=$(getYMLine1 "mailcatcher${VDM_KEY}:")
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine2 "image: schickling/mailcatcher") VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine2 "image: schickling/mailcatcher")
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine2 "container_name: mailcatcher_${VDM_KEY}") VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine2 "container_name: mailcatcher${VDM_KEY}")
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine2 "restart: unless-stopped") VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine2 "restart: unless-stopped")
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine2 "networks:") VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine2 "networks:")
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "- traefik") VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "- traefik")
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine2 "labels:") VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine2 "labels:")
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "# mailcatcher") VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "# mailcatcher")
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "- \"traefik.enable=true\"") VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "- \"traefik.enable=true\"")
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "- \"traefik.http.routers.mailcatcher_${VDM_KEY}.rule=Host(\`${VDM_SUBDOMAIN}mail.${VDM_DOMAIN}\`)\"") VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "- \"traefik.http.routers.mailcatcher${VDM_KEY}.rule=Host(\`${VDM_SUBDOMAIN}mail.${VDM_DOMAIN}\`)\"")
if $VDM_SECURE; then if $VDM_SECURE; then
if $VDM_SECURE_CLOUDFLARE; then if $VDM_SECURE_CLOUDFLARE; then
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "- \"traefik.http.routers.mailcatcher_${VDM_KEY}.entrypoints=web\"") VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "- \"traefik.http.routers.mailcatcher${VDM_KEY}.entrypoints=web\"")
else else
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "- \"traefik.http.routers.mailcatcher_${VDM_KEY}.entrypoints=${VDM_ENTRY_POINT}\"") VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "- \"traefik.http.routers.mailcatcher${VDM_KEY}.entrypoints=${VDM_ENTRY_POINT}\"")
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "- \"traefik.http.routers.mailcatcher_${VDM_KEY}.tls.certresolver=vdmresolver\"") VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "- \"traefik.http.routers.mailcatcher${VDM_KEY}.tls.certresolver=vdmresolver\"")
fi fi
fi fi
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "- \"traefik.http.routers.mailcatcher_${VDM_KEY}.service=mailcatcher_${VDM_KEY}\"") VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "- \"traefik.http.routers.mailcatcher${VDM_KEY}.service=mailcatcher${VDM_KEY}\"")
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "- \"traefik.http.services.mailcatcher_${VDM_KEY}.loadbalancer.server.port=1080\"") VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "- \"traefik.http.services.mailcatcher${VDM_KEY}.loadbalancer.server.port=1080\"")
VDM_EXTRA_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_SMTP_HOST=mailcatcher_${VDM_KEY}") VDM_EXTRA_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_SMTP_HOST=mailcatcher${VDM_KEY}:1080")
fi fi
# only if in expert mode set the container user detail id needed
if isExpert; then
# if this is our octoleo images we can also set the user ID and user-group ID # if this is our octoleo images we can also set the user ID and user-group ID
setContainerUser "$(id -u)" setContainerUser "$(id -u)"
# check that we got the details # check that we got the details
@ -520,12 +612,17 @@ function joomla__TRuST__setup() {
setContainerEnvVariable "VDM_${VDM_ENV_KEY^^}_JOOMLA_ADMIN_PASSWORD=\"${VDM_J_PASSWORD}\"" setContainerEnvVariable "VDM_${VDM_ENV_KEY^^}_JOOMLA_ADMIN_PASSWORD=\"${VDM_J_PASSWORD}\""
VDM_EXTRA_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_DB_TYPE=\${VDM_${VDM_ENV_KEY^^}_JOOMLA_DB_TYPE}") VDM_EXTRA_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_DB_TYPE=\${VDM_${VDM_ENV_KEY^^}_JOOMLA_DB_TYPE}")
VDM_EXTRA_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_DB_PREFIX=\${VDM_${VDM_ENV_KEY^^}_JOOMLA_DB_PREFIX}") VDM_EXTRA_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_DB_PREFIX=\${VDM_${VDM_ENV_KEY^^}_JOOMLA_DB_PREFIX}")
VDM_EXTRA_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_SITE_NAME=\"\${VDM_${VDM_ENV_KEY^^}_JOOMLA_SITE_NAME}\"") VDM_EXTRA_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_SITE_NAME=\${VDM_${VDM_ENV_KEY^^}_JOOMLA_SITE_NAME}")
VDM_EXTRA_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_ADMIN_USERNAME=\${VDM_${VDM_ENV_KEY^^}_JOOMLA_ADMIN_USERNAME}") VDM_EXTRA_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_ADMIN_USERNAME=\${VDM_${VDM_ENV_KEY^^}_JOOMLA_ADMIN_USERNAME}")
VDM_EXTRA_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_ADMIN_USER=\"\${VDM_${VDM_ENV_KEY^^}_JOOMLA_ADMIN_USER}\"") VDM_EXTRA_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_ADMIN_USER=\${VDM_${VDM_ENV_KEY^^}_JOOMLA_ADMIN_USER}")
VDM_EXTRA_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_ADMIN_EMAIL=\${VDM_${VDM_ENV_KEY^^}_JOOMLA_ADMIN_EMAIL}") VDM_EXTRA_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_ADMIN_EMAIL=\${VDM_${VDM_ENV_KEY^^}_JOOMLA_ADMIN_EMAIL}")
VDM_EXTRA_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_ADMIN_PASSWORD=\${VDM_${VDM_ENV_KEY^^}_JOOMLA_ADMIN_PASSWORD}") VDM_EXTRA_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_ADMIN_PASSWORD=\${VDM_${VDM_ENV_KEY^^}_JOOMLA_ADMIN_PASSWORD}")
fi fi
if [[ -n "${VDM_J_EXTENSIONS_URLS}" && "${#VDM_J_EXTENSIONS_URLS}" -gt 2 ]]; then
# add extra Joomla envs
setContainerEnvVariable "VDM_${VDM_ENV_KEY^^}_EXTENSIONS_URLS=\"${VDM_J_EXTENSIONS_URLS}\""
VDM_EXTRA_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_EXTENSIONS_URLS=\${VDM_${VDM_ENV_KEY^^}_EXTENSIONS_URLS}")
fi
fi fi
# add PHP settings # add PHP settings
VDM_PHP_PROJECT_PATH="${VDM_KEY}" VDM_PHP_PROJECT_PATH="${VDM_KEY}"
@ -614,6 +711,7 @@ function joomla__TRuST__setup() {
unset VDM_J_USER unset VDM_J_USER
unset VDM_J_EMAIL unset VDM_J_EMAIL
unset VDM_J_PASSWORD unset VDM_J_PASSWORD
unset VDM_J_EXTENSIONS_URLS
# container lower # container lower
unset vdm_database_name unset vdm_database_name
unset vdm_database_user unset vdm_database_user
@ -636,9 +734,9 @@ function joomlaContainer() {
cat <<EOF cat <<EOF
version: '2' version: '2'
services: services:
mariadb_${VDM_KEY}: mariadb${VDM_KEY}:
image: mariadb:latest image: mariadb:latest
container_name: mariadb_${VDM_KEY} container_name: mariadb${VDM_KEY}
restart: unless-stopped restart: unless-stopped
environment: environment:
- MARIADB_DATABASE=\${VDM_${VDM_ENV_KEY^^}_DB} - MARIADB_DATABASE=\${VDM_${VDM_ENV_KEY^^}_DB}
@ -648,40 +746,40 @@ services:
volumes:${VDM_DB_VOLUMES_MOUNT} volumes:${VDM_DB_VOLUMES_MOUNT}
networks: networks:
- traefik - traefik
joomla_${VDM_KEY}: joomla${VDM_KEY}:
image: ${VDM_J_REPO}:${VDM_JV} image: ${VDM_J_REPO}:${VDM_JV}
container_name: joomla_${VDM_KEY} container_name: joomla${VDM_KEY}
restart: unless-stopped restart: unless-stopped
environment:${vdm_container_user} environment:${vdm_container_user}
- JOOMLA_DB_HOST=mariadb_${VDM_KEY}:3306 - JOOMLA_DB_HOST=mariadb${VDM_KEY}:3306
- JOOMLA_DB_NAME=\${VDM_${VDM_ENV_KEY^^}_DB} - JOOMLA_DB_NAME=\${VDM_${VDM_ENV_KEY^^}_DB}
- JOOMLA_DB_USER=\${VDM_${VDM_ENV_KEY^^}_DB_USER} - JOOMLA_DB_USER=\${VDM_${VDM_ENV_KEY^^}_DB_USER}
- JOOMLA_DB_PASSWORD=\${VDM_${VDM_ENV_KEY^^}_DB_PASS}${VDM_EXTRA_JOOMLA_ENV} - JOOMLA_DB_PASSWORD=\${VDM_${VDM_ENV_KEY^^}_DB_PASS}${VDM_EXTRA_JOOMLA_ENV}
depends_on: depends_on:
- mariadb_${VDM_KEY} - mariadb${VDM_KEY}
volumes:${VDM_JOOMLA_VOLUMES_MOUNT} volumes:${VDM_JOOMLA_VOLUMES_MOUNT}
networks: networks:
- traefik - traefik
labels: labels:
# joomla # joomla
- "traefik.enable=true" - "traefik.enable=true"
- "traefik.http.routers.joomla_${VDM_KEY}.rule=Host(\`${VDM_SUBDOMAIN}.${VDM_DOMAIN}\`)"${VDM_JOOMLA_SECURE_LABELS} - "traefik.http.routers.joomla${VDM_KEY}.rule=Host(\`${VDM_SUBDOMAIN}.${VDM_DOMAIN}\`)"${VDM_JOOMLA_SECURE_LABELS}
phpmyadmin_${VDM_KEY}: phpmyadmin${VDM_KEY}:
image: phpmyadmin/phpmyadmin image: phpmyadmin/phpmyadmin
container_name: phpmyadmin_${VDM_KEY} container_name: phpmyadmin${VDM_KEY}
restart: unless-stopped restart: unless-stopped
environment: environment:
PMA_HOST: mariadb_${VDM_KEY} PMA_HOST: mariadb${VDM_KEY}
PMA_PORT: 3306 PMA_PORT: 3306
UPLOAD_LIMIT: 300M UPLOAD_LIMIT: 300M
depends_on: depends_on:
- mariadb_${VDM_KEY} - mariadb${VDM_KEY}
networks: networks:
- traefik - traefik
labels: labels:
# phpmyadmin # phpmyadmin
- "traefik.enable=true" - "traefik.enable=true"
- "traefik.http.routers.phpmyadmin_${VDM_KEY}.rule=Host(\`${VDM_SUBDOMAIN}db.${VDM_DOMAIN}\`)"${VDM_PHPMYADMIN_SECURE_LABELS}${VDM_EXTRA_CONTAINER_STUFF} - "traefik.http.routers.phpmyadmin${VDM_KEY}.rule=Host(\`${VDM_SUBDOMAIN}db.${VDM_DOMAIN}\`)"${VDM_PHPMYADMIN_SECURE_LABELS}${VDM_EXTRA_CONTAINER_STUFF}
networks: networks:
traefik: traefik:
external: true external: true
@ -796,11 +894,15 @@ function joomla__TRuST__bulk() {
fi fi
# we only do autodeploy for Joomla 4.3 and above # we only do autodeploy for Joomla 4.3 and above
enable_autodeploy=false enable_autodeploy=false
enable_extension_autodeploy=false
if isVersionAbove "$VDM_JV" "4.3"; then if isVersionAbove "$VDM_JV" "4.3"; then
# get website setup details # get website setup details
setJoomlaWebsiteDetails setJoomlaWebsiteDetails
if [[ -n "${VDM_J_EMAIL}" ]]; then if [[ -n "${VDM_J_EMAIL}" ]]; then
enable_autodeploy=true enable_autodeploy=true
if [[ -n "${VDM_J_EXTENSIONS_URLS}" && "${#VDM_J_EXTENSIONS_URLS}" -gt 2 ]]; then
enable_extension_autodeploy=true
fi
fi fi
fi fi
# add the projects path # add the projects path
@ -864,11 +966,16 @@ function joomla__TRuST__bulk() {
setContainerEnvVariable "VDM_${VDM_ENV_KEY^^}_JOOMLA_ADMIN_PASSWORD=\"${VDM_J_PASSWORD}\"" setContainerEnvVariable "VDM_${VDM_ENV_KEY^^}_JOOMLA_ADMIN_PASSWORD=\"${VDM_J_PASSWORD}\""
VDM_EXTRA_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_DB_TYPE=\${VDM_${VDM_ENV_KEY^^}_JOOMLA_DB_TYPE}") VDM_EXTRA_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_DB_TYPE=\${VDM_${VDM_ENV_KEY^^}_JOOMLA_DB_TYPE}")
VDM_EXTRA_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_DB_PREFIX=\${VDM_${VDM_ENV_KEY^^}_JOOMLA_DB_PREFIX}") VDM_EXTRA_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_DB_PREFIX=\${VDM_${VDM_ENV_KEY^^}_JOOMLA_DB_PREFIX}")
VDM_EXTRA_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_SITE_NAME=\"\${VDM_${VDM_ENV_KEY^^}_JOOMLA_SITE_NAME}\"") VDM_EXTRA_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_SITE_NAME=\${VDM_${VDM_ENV_KEY^^}_JOOMLA_SITE_NAME}")
VDM_EXTRA_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_ADMIN_USERNAME=\${VDM_${VDM_ENV_KEY^^}_JOOMLA_ADMIN_USERNAME}") VDM_EXTRA_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_ADMIN_USERNAME=\${VDM_${VDM_ENV_KEY^^}_JOOMLA_ADMIN_USERNAME}")
VDM_EXTRA_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_ADMIN_USER=\"\${VDM_${VDM_ENV_KEY^^}_JOOMLA_ADMIN_USER}\"") VDM_EXTRA_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_ADMIN_USER=\${VDM_${VDM_ENV_KEY^^}_JOOMLA_ADMIN_USER}")
VDM_EXTRA_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_ADMIN_EMAIL=\${VDM_${VDM_ENV_KEY^^}_JOOMLA_ADMIN_EMAIL}") VDM_EXTRA_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_ADMIN_EMAIL=\${VDM_${VDM_ENV_KEY^^}_JOOMLA_ADMIN_EMAIL}")
VDM_EXTRA_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_ADMIN_PASSWORD=\${VDM_${VDM_ENV_KEY^^}_JOOMLA_ADMIN_PASSWORD}") VDM_EXTRA_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_ADMIN_PASSWORD=\${VDM_${VDM_ENV_KEY^^}_JOOMLA_ADMIN_PASSWORD}")
if $enable_extension_autodeploy; then
# add extra Joomla envs
setContainerEnvVariable "VDM_${VDM_ENV_KEY^^}_EXTENSIONS_URLS=\"${VDM_J_EXTENSIONS_URLS}\""
VDM_EXTRA_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_EXTENSIONS_URLS=\${VDM_${VDM_ENV_KEY^^}_EXTENSIONS_URLS}")
fi
fi fi
# set persistence # set persistence
reset_volume=true reset_volume=true
@ -897,27 +1004,27 @@ function joomla__TRuST__bulk() {
$reset_volume && VDM_VOLUMES='' $reset_volume && VDM_VOLUMES=''
# add the mailcatcher if needed # add the mailcatcher if needed
if $enable_mailcatcher; then if $enable_mailcatcher; then
VDM_EXTRA_CONTAINER_STUFF=$(getYMLine1 "mailcatcher_${VDM_KEY}:") VDM_EXTRA_CONTAINER_STUFF=$(getYMLine1 "mailcatcher${VDM_KEY}:")
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine2 "image: schickling/mailcatcher") VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine2 "image: schickling/mailcatcher")
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine2 "container_name: mailcatcher_${VDM_KEY}") VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine2 "container_name: mailcatcher${VDM_KEY}")
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine2 "restart: unless-stopped") VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine2 "restart: unless-stopped")
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine2 "networks:") VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine2 "networks:")
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "- traefik") VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "- traefik")
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine2 "labels:") VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine2 "labels:")
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "# mailcatcher") VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "# mailcatcher")
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "- \"traefik.enable=true\"") VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "- \"traefik.enable=true\"")
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "- \"traefik.http.routers.mailcatcher_${VDM_KEY}.rule=Host(\`${VDM_SUBDOMAIN}mail.${VDM_DOMAIN}\`)\"") VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "- \"traefik.http.routers.mailcatcher${VDM_KEY}.rule=Host(\`${VDM_SUBDOMAIN}mail.${VDM_DOMAIN}\`)\"")
if $VDM_SECURE; then if $VDM_SECURE; then
if $VDM_SECURE_CLOUDFLARE; then if $VDM_SECURE_CLOUDFLARE; then
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "- \"traefik.http.routers.mailcatcher_${VDM_KEY}.entrypoints=web\"") VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "- \"traefik.http.routers.mailcatcher${VDM_KEY}.entrypoints=web\"")
else else
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "- \"traefik.http.routers.mailcatcher_${VDM_KEY}.entrypoints=${VDM_ENTRY_POINT}\"") VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "- \"traefik.http.routers.mailcatcher${VDM_KEY}.entrypoints=${VDM_ENTRY_POINT}\"")
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "- \"traefik.http.routers.mailcatcher_${VDM_KEY}.tls.certresolver=vdmresolver\"") VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "- \"traefik.http.routers.mailcatcher${VDM_KEY}.tls.certresolver=vdmresolver\"")
fi fi
fi fi
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "- \"traefik.http.routers.mailcatcher_${VDM_KEY}.service=mailcatcher_${VDM_KEY}\"") VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "- \"traefik.http.routers.mailcatcher${VDM_KEY}.service=mailcatcher${VDM_KEY}\"")
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "- \"traefik.http.services.mailcatcher_${VDM_KEY}.loadbalancer.server.port=1080\"") VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "- \"traefik.http.services.mailcatcher${VDM_KEY}.loadbalancer.server.port=1080\"")
VDM_EXTRA_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_SMTP_HOST=mailcatcher_${VDM_KEY}") VDM_EXTRA_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_SMTP_HOST=mailcatcher${VDM_KEY}:1080")
fi fi
# setup letsencrypt stuff # setup letsencrypt stuff
VDM_JOOMLA_SECURE_LABELS='' VDM_JOOMLA_SECURE_LABELS=''
@ -925,22 +1032,22 @@ function joomla__TRuST__bulk() {
if $VDM_SECURE; then if $VDM_SECURE; then
# add joomla labels # add joomla labels
if $VDM_SECURE_CLOUDFLARE; then if $VDM_SECURE_CLOUDFLARE; then
VDM_JOOMLA_SECURE_LABELS+=$(getYMLine3 "- \"traefik.http.routers.joomla_${VDM_KEY}.entrypoints=web\"") VDM_JOOMLA_SECURE_LABELS+=$(getYMLine3 "- \"traefik.http.routers.joomla${VDM_KEY}.entrypoints=web\"")
else else
VDM_JOOMLA_SECURE_LABELS+=$(getYMLine3 "- \"traefik.http.routers.joomla_${VDM_KEY}.entrypoints=${VDM_ENTRY_POINT}\"") VDM_JOOMLA_SECURE_LABELS+=$(getYMLine3 "- \"traefik.http.routers.joomla${VDM_KEY}.entrypoints=${VDM_ENTRY_POINT}\"")
VDM_JOOMLA_SECURE_LABELS+=$(getYMLine3 "- \"traefik.http.routers.joomla_${VDM_KEY}.tls.certresolver=vdmresolver\"") VDM_JOOMLA_SECURE_LABELS+=$(getYMLine3 "- \"traefik.http.routers.joomla${VDM_KEY}.tls.certresolver=vdmresolver\"")
fi fi
VDM_JOOMLA_SECURE_LABELS+=$(getYMLine3 "- \"traefik.http.routers.joomla_${VDM_KEY}.service=joomla_${VDM_KEY}\"") VDM_JOOMLA_SECURE_LABELS+=$(getYMLine3 "- \"traefik.http.routers.joomla${VDM_KEY}.service=joomla${VDM_KEY}\"")
VDM_JOOMLA_SECURE_LABELS+=$(getYMLine3 "- \"traefik.http.services.joomla_${VDM_KEY}.loadbalancer.server.port=80\"") VDM_JOOMLA_SECURE_LABELS+=$(getYMLine3 "- \"traefik.http.services.joomla${VDM_KEY}.loadbalancer.server.port=80\"")
# add phpmyadmin labels # add phpmyadmin labels
if $VDM_SECURE_CLOUDFLARE; then if $VDM_SECURE_CLOUDFLARE; then
VDM_PHPMYADMIN_SECURE_LABELS+=$(getYMLine3 "- \"traefik.http.routers.phpmyadmin_${VDM_KEY}.entrypoints=web\"") VDM_PHPMYADMIN_SECURE_LABELS+=$(getYMLine3 "- \"traefik.http.routers.phpmyadmin${VDM_KEY}.entrypoints=web\"")
else else
VDM_PHPMYADMIN_SECURE_LABELS+=$(getYMLine3 "- \"traefik.http.routers.phpmyadmin_${VDM_KEY}.entrypoints=${VDM_ENTRY_POINT}\"") VDM_PHPMYADMIN_SECURE_LABELS+=$(getYMLine3 "- \"traefik.http.routers.phpmyadmin${VDM_KEY}.entrypoints=${VDM_ENTRY_POINT}\"")
VDM_PHPMYADMIN_SECURE_LABELS+=$(getYMLine3 "- \"traefik.http.routers.phpmyadmin_${VDM_KEY}.tls.certresolver=vdmresolver\"") VDM_PHPMYADMIN_SECURE_LABELS+=$(getYMLine3 "- \"traefik.http.routers.phpmyadmin${VDM_KEY}.tls.certresolver=vdmresolver\"")
fi fi
VDM_PHPMYADMIN_SECURE_LABELS+=$(getYMLine3 "- \"traefik.http.routers.phpmyadmin_${VDM_KEY}.service=phpmyadmin_${VDM_KEY}\"") VDM_PHPMYADMIN_SECURE_LABELS+=$(getYMLine3 "- \"traefik.http.routers.phpmyadmin${VDM_KEY}.service=phpmyadmin${VDM_KEY}\"")
VDM_PHPMYADMIN_SECURE_LABELS+=$(getYMLine3 "- \"traefik.http.services.phpmyadmin_${VDM_KEY}.loadbalancer.server.port=80\"") VDM_PHPMYADMIN_SECURE_LABELS+=$(getYMLine3 "- \"traefik.http.services.phpmyadmin${VDM_KEY}.loadbalancer.server.port=80\"")
fi fi
# global # global
export VDM_KEY export VDM_KEY
@ -1002,6 +1109,7 @@ function joomla__TRuST__bulk() {
unset VDM_J_USER unset VDM_J_USER
unset VDM_J_EMAIL unset VDM_J_EMAIL
unset VDM_J_PASSWORD unset VDM_J_PASSWORD
unset VDM_J_EXTENSIONS_URLS
# container lower # container lower
unset vdm_database_name unset vdm_database_name
unset vdm_database_user unset vdm_database_user
@ -1878,6 +1986,18 @@ function portainer__TRuST__delete() {
fi fi
} }
#####################################################################################################################VDM
######################################## RESET JOOMLA
function joomla__TRuST__reset() {
# ask if there are volumes to delete
if hasDirectories '' "${VDM_PROJECT_PATH}" &&
(whiptail --yesno "Would you like to reset persistent volumes found in (${VDM_PROJECT_PATH})?" \
--title "Continue To Reset Persistent Volumes" --backtitle "${BACK_TITLE}" 12 112); then
# trigger the volumes reset script
resetPersistentJoomlaVolumes
fi
}
#####################################################################################################################VDM #####################################################################################################################VDM
######################################## Migrate Joomla ######################################## Migrate Joomla
function joomla__TRuST__migrate() { function joomla__TRuST__migrate() {
@ -2073,6 +2193,15 @@ function deleteContainer() {
main main
} }
# reset a container
function resetContainer() {
# make sure of our container type
VDM_CONTAINER_TYPE="${1}"
VDM_TASK="reset"
# execute the task
main
}
# migrate a container # migrate a container
function migrateContainer() { function migrateContainer() {
# make sure of our container type # make sure of our container type
@ -2270,6 +2399,47 @@ function deletePersistentVolumes() {
fi fi
} }
# reset persistent Joomla volume
function resetPersistentJoomlaVolumes() {
# we first check if we have some volumes
if hasDirectories '' "${VDM_PROJECT_PATH}"; then
# set some local variables
local vdm_reset_volumes
local persistent
# saved the file
showNotice "Only reset persistent Joomla volumes of which you have made absolutely sure it's no longer in use!"
# get containers to enable
vdm_reset_volumes=$(getSelectedDirectories "Select persistent volume\s to reset." \
"${VDM_PROJECT_PATH}" "Select Persistent Volume\s to Reset")
# check that we have something, else return to main menu
if [ ${#vdm_reset_volumes} -ge 1 ]; then
# convert the string to and array
IFS=' ' read -r -a vdm_reset_volumes_array <<<"${vdm_reset_volumes[@]}"
# loop over the directories to build the
for volumes in "${vdm_reset_volumes_array[@]}"; do
# remove the " from the string
persistent="${volumes//\"/}"
# last serious check and then its gone
if [ -d "${VDM_PROJECT_PATH}/${persistent}/joomla" ] &&
(whiptail --yesno "Are you absolutely sure you would like to delete this (${persistent}/joomla) persistent volume? THIS CAN'T BE UNDONE!\n(we need sudo privileges)" \
--title "Delete Persistent Volume" --backtitle "${BACK_TITLE}" 15 112); then
# then remove soft link
sudo rm -rf "${VDM_PROJECT_PATH}/${persistent}/joomla"
fi
# last serious check and then its gone
if [ -d "${VDM_PROJECT_PATH}/${persistent}/db" ] &&
(whiptail --yesno "Are you absolutely sure you would like to delete this (${persistent}/db) persistent volume? THIS CAN'T BE UNDONE!\n(we need sudo privileges)" \
--title "Delete Persistent Volume" --backtitle "${BACK_TITLE}" 15 112); then
# then remove soft link
sudo rm -rf "${VDM_PROJECT_PATH}/${persistent}/db"
fi
done
fi
else
showError "There are no persistent volumes found in ${VDM_PROJECT_PATH}."
fi
}
# make an update # make an update
function runUpdate() { function runUpdate() {
# we need sudo permissions # we need sudo permissions
@ -2546,6 +2716,9 @@ function showJoomla() {
# delete a container # delete a container
hasDirectories 'joomla/available' && hasDirectories 'joomla/available' &&
menu_options+=("delete" "Delete a container") && i=$((i + 1)) menu_options+=("delete" "Delete a container") && i=$((i + 1))
# reset a volume
isExpert && hasDirectories 'joomla/available' &&
menu_options+=("reset" "Reset a volume") && i=$((i + 1))
# Get Joomla env details # Get Joomla env details
isExpert && hasDirectories 'joomla/available' && isExpert && hasDirectories 'joomla/available' &&
menu_options+=("joomla_env" "Open Joomla .env Details") && i=$((i + 1)) menu_options+=("joomla_env" "Open Joomla .env Details") && i=$((i + 1))
@ -2555,7 +2728,7 @@ function showJoomla() {
menu_options+=("quit" "Quit ${PROGRAM_NAME}") menu_options+=("quit" "Quit ${PROGRAM_NAME}")
# get the selection # get the selection
CHOICE=$( CHOICE=$(
whiptail --menu "Make your selection" 20 112 $i \ whiptail --menu "Make your selection" 23 112 $i \
--title "Joomla | ${PROGRAM_NAME} v${_V}" --fb \ --title "Joomla | ${PROGRAM_NAME} v${_V}" --fb \
--backtitle "${BACK_TITLE}" --nocancel --notags \ --backtitle "${BACK_TITLE}" --nocancel --notags \
"${menu_options[@]}" 3>&2 2>&1 1>&3 "${menu_options[@]}" 3>&2 2>&1 1>&3
@ -2587,6 +2760,9 @@ function showJoomla() {
"delete") "delete")
deleteContainer 'joomla' deleteContainer 'joomla'
;; ;;
"reset")
resetContainer 'joomla'
;;
"joomla_env") "joomla_env")
openEnv 'joomla' openEnv 'joomla'
;; ;;
@ -2598,7 +2774,7 @@ function showJoomla() {
# menu loop # menu loop
case $CHOICE in case $CHOICE in
"setup" | "edit" | "enable" | "disable" | "down" | "up" | "fix" | "delete" | "joomla_env" | "bulk") "setup" | "edit" | "enable" | "disable" | "down" | "up" | "fix" | "delete" | "reset" | "joomla_env" | "bulk")
showJoomla showJoomla
;; ;;
esac esac
@ -3183,7 +3359,7 @@ function showJoomlaConfigDetails() {
Running the Joomla container for the first time you will need these details: Running the Joomla container for the first time you will need these details:
-------------------------------------------------------------------- --------------------------------------------------------------------
URL: ${VDM_HTTP_SCHEME}${VDM_SUBDOMAIN}.${VDM_DOMAIN} URL: ${VDM_HTTP_SCHEME}${VDM_SUBDOMAIN}.${VDM_DOMAIN}
DATABASE_HOST: mariadb_${VDM_KEY}:3306 DATABASE_HOST: mariadb${VDM_KEY}:3306
-------------------------------------------------------------------- --------------------------------------------------------------------
VDM_${VDM_ENV_KEY^^}_DB: ${vdm_database_name} VDM_${VDM_ENV_KEY^^}_DB: ${vdm_database_name}
VDM_${VDM_ENV_KEY^^}_DB_USER: ${vdm_database_user} VDM_${VDM_ENV_KEY^^}_DB_USER: ${vdm_database_user}
@ -3737,7 +3913,7 @@ function setUniqueKey() {
# set the Joomla website details # set the Joomla website details
function setJoomlaWebsiteDetails() { function setJoomlaWebsiteDetails() {
# ask if we should add mailcatcher # ask if we should add autodeployment
if (whiptail --yesno "Would you like to enable website autodeploy for ${VDM_CONTAINER_TYPE,}:${VDM_JV}" \ if (whiptail --yesno "Would you like to enable website autodeploy for ${VDM_CONTAINER_TYPE,}:${VDM_JV}" \
--defaultno --title "Enable Autodeploy" --backtitle "${BACK_TITLE}" 8 112); then --defaultno --title "Enable Autodeploy" --backtitle "${BACK_TITLE}" 8 112); then
@ -3756,6 +3932,8 @@ function setJoomlaWebsiteDetails() {
# ask for username password # ask for username password
setJoomlaPassword setJoomlaPassword
# ask for extension URLs
setJoomlaExtensionUrls
fi fi
} }
@ -3846,6 +4024,38 @@ function setJoomlaPassword() {
export VDM_J_PASSWORD export VDM_J_PASSWORD
} }
# This function asks for Joomla extension ZIP URLs using whiptail, validates them,
# and concatenates them into a single environment variable.
function setJoomlaExtensionUrls() {
local urls=()
local input=""
local prompt_message="Enter Joomla Extension ZIP URL (leave empty to for none):"
local title="Enter Joomla Extension Installation URL"
# Loop to collect URLs until an empty string or cancellation
while true; do
input=$(getInput "$prompt_message" "" "$title")
# Break loop if input is empty
if [[ -z "$input" ]]; then
break
fi
# Validate URL format
if [[ "$input" =~ ^http(s)?://[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(/.*)?$ ]]; then
urls+=("$input")
else
showNotice "Invalid URL. Please enter a valid ZIP URL (must be a .zip file)." 10
fi
done
# Join URLs with semicolons
if [ ${#urls[@]} -gt 0 ]; then
VDM_J_EXTENSIONS_URLS=$(IFS=';'; echo "${urls[*]}")
export VDM_J_EXTENSIONS_URLS
fi
}
# set the number of containers to build # set the number of containers to build
function setNumberContainers() { function setNumberContainers() {
local valid=0 local valid=0
@ -3935,7 +4145,7 @@ function setImageSource() {
# get the Joomla version if not set # get the Joomla version if not set
while [ ${#VDM_JV} -le 1 ]; do while [ ${#VDM_JV} -le 1 ]; do
# get the value # get the value
VDM_JV=$(getInput "Enter Joomla version tag for this container.\n[See available tags here ${vdm_tag_url}]" '5.0' 'Enter Version Tag') VDM_JV=$(getInput "Enter Joomla version tag for this container.\n[See available tags here ${vdm_tag_url}]" '5.1' 'Enter Version Tag')
# keep asking # keep asking
[ ${#VDM_JV} -ge 1 ] || { [ ${#VDM_JV} -ge 1 ] || {
showError "You must enter a version tag. See available tags here ${vdm_tag_url}" showError "You must enter a version tag. See available tags here ${vdm_tag_url}"
@ -4002,6 +4212,12 @@ function setPHPSettings() {
# remember this for next time # remember this for next time
setUniqueEnvVariable "VDM_max_input_time=${VDM_max_input_time}" setUniqueEnvVariable "VDM_max_input_time=${VDM_max_input_time}"
# max_input_vars
VDM_max_input_vars=$(getInputNow "Enter max_input_vars" \
"${VDM_max_input_vars:-3000}" 'max_input_vars')
# remember this for next time
setUniqueEnvVariable "VDM_max_input_vars=${VDM_max_input_vars}"
# error_reporting # error_reporting
default_error_reporting="E_ALL & ~E_DEPRECATED & ~E_STRICT" default_error_reporting="E_ALL & ~E_DEPRECATED & ~E_STRICT"
VDM_error_reporting=$(getInputNow "Enter error reporting" \ VDM_error_reporting=$(getInputNow "Enter error reporting" \
@ -4034,6 +4250,7 @@ function setPHPSettings() {
{ {
echo "max_execution_time = ${VDM_max_execution_time}" echo "max_execution_time = ${VDM_max_execution_time}"
echo "max_input_time = ${VDM_max_input_time}" echo "max_input_time = ${VDM_max_input_time}"
echo "max_input_vars = ${VDM_max_input_vars}"
echo "error_reporting = ${VDM_error_reporting}" echo "error_reporting = ${VDM_error_reporting}"
echo "upload_max_filesize = ${VDM_upload_max_filesize}" echo "upload_max_filesize = ${VDM_upload_max_filesize}"
echo "post_max_size = ${VDM_post_max_size}" echo "post_max_size = ${VDM_post_max_size}"
@ -4445,9 +4662,9 @@ function openEnv() {
# Check if any hosts are set in the SSH config file # Check if any hosts are set in the SSH config file
function hasRemoteSystemSet() { function hasRemoteSystemSet() {
local ssh_config="/home/${USER}/.ssh/config" local ssh_config="${VDM_HOME_PATH}/.ssh/config"
if [ ! -d "/home/${USER}/.ssh" ] || [ ! -f "${ssh_config}" ] || if [ ! -d "${VDM_HOME_PATH}/.ssh" ] || [ ! -f "${ssh_config}" ] ||
[[ $(grep -i -c '^host' "${ssh_config}") -eq 0 ]]; then [[ $(grep -i -c '^host' "${ssh_config}") -eq 0 ]]; then
showError "To use this feature you must first set up the needed remote host details in (~/.ssh/config) to allow easy and secure SSH access." showError "To use this feature you must first set up the needed remote host details in (~/.ssh/config) to allow easy and secure SSH access."
return 1 return 1
@ -4461,7 +4678,7 @@ function getRemoteSystem() {
# The selected folder # The selected folder
local answer local answer
if [ -f "/home/${USER}/.ssh/config" ]; then if [ -f "${VDM_HOME_PATH}/.ssh/config" ]; then
# We start the selection array # We start the selection array
local selected=() local selected=()
# Our counter # Our counter
@ -4474,7 +4691,7 @@ function getRemoteSystem() {
if [ "$i" -le 10 ]; then if [ "$i" -le 10 ]; then
i=$((i + 1)) i=$((i + 1))
fi fi
done < <(grep -i '^host' "/home/${USER}/.ssh/config" | awk '{print $2}' | sort) done < <(grep -i '^host' "${VDM_HOME_PATH}/.ssh/config" | awk '{print $2}' | sort)
# Add manual input option # Add manual input option
selected+=("Enter manually" "Enter manually" "OFF") selected+=("Enter manually" "Enter manually" "OFF")
@ -4520,7 +4737,7 @@ function remoteEnvFileExists() {
# Check if the file exists on the remote system # Check if the file exists on the remote system
# shellcheck disable=SC2029 # shellcheck disable=SC2029
ssh "${remote_system}" "[ -f \"/home/${USER}/.config/octojoom/.env\" ]" ssh "${remote_system}" "[ -f \"${VDM_HOME_PATH}/.config/octojoom/.env\" ]"
} }
# Get a specific value from the remote .env file # Get a specific value from the remote .env file
@ -4531,7 +4748,7 @@ function getRemoteEnvValue() {
if remoteEnvFileExists "${remote_system}"; then if remoteEnvFileExists "${remote_system}"; then
# shellcheck disable=SC2029 # shellcheck disable=SC2029
remote_env_value=$(ssh "${remote_system}" "grep '^${env_key}=' \"/home/${USER}/.config/octojoom/.env\"" | cut -d '=' -f 2-) remote_env_value=$(ssh "${remote_system}" "grep '^${env_key}=' \"${VDM_HOME_PATH}/.config/octojoom/.env\"" | cut -d '=' -f 2-)
fi fi
# Remove any double quotes from the returned value # Remove any double quotes from the returned value
@ -4804,8 +5021,8 @@ function moveTarToRemote() {
local remote_path="$2" local remote_path="$2"
local remote="$3" local remote="$3"
if [ -f "/home/${USER}/.ssh/config" ]; then if [ -f "${VDM_HOME_PATH}/.ssh/config" ]; then
scp -F "/home/${USER}/.ssh/config" "${local_path}" "${remote}:${remote_path}" scp -F "${VDM_HOME_PATH}/.ssh/config" "${local_path}" "${remote}:${remote_path}"
else else
scp "${local_path}" "${remote}:${remote_path}" scp "${local_path}" "${remote}:${remote_path}"
fi fi
@ -4936,8 +5153,8 @@ Usage: octojoom [OPTION...]
====================================================== ======================================================
-j|--joomla-version <version-tag> -j|--joomla-version <version-tag>
see available tags here https://hub.docker.com/_/joomla see available tags here https://hub.docker.com/_/joomla
example: octojoom -j=5.0 example: octojoom -j=5.1
example: octojoom --joomla-version=5.0 example: octojoom --joomla-version=5.1
====================================================== ======================================================
AVAILABLE FOR OPENSSH CONTAINER AVAILABLE FOR OPENSSH CONTAINER
====================================================== ======================================================
@ -5305,15 +5522,32 @@ fi
#####################################################################################################################VDM #####################################################################################################################VDM
######################################## SETUP KEY PATHS ######################################## SETUP KEY PATHS
# the src folder path is where we store the script global env # we set a home path based on OS
VDM_SRC_PATH="/home/${USER}/.config/octojoom" VDM_HOME_PATH=''
# create the folder if not set case "$OS_NUMBER" in
1) # Linux
VDM_HOME_PATH="/home/${USER}"
;;
2) # macOS
VDM_HOME_PATH="/Users/${USER}"
;;
3) # Windows (MSYS/Cygwin)
VDM_HOME_PATH="/c/Users/${USER}"
;;
*)
echo >&2 "ERROR: Unsupported operating system."
exit 1
;;
esac
# Set the src folder path based on OS
VDM_SRC_PATH="${VDM_HOME_PATH}/.config/octojoom"
# Create the folder if not set
# shellcheck disable=SC2174 # shellcheck disable=SC2174
mkdir -p -m '700' "${VDM_SRC_PATH}" mkdir -p -m '700' "${VDM_SRC_PATH}"
# first run switch # first run switch
VDM_FIRST_RUN=false VDM_FIRST_RUN=false
# load the globals # load the globals
# shellcheck disable=SC1090 # shellcheck disable=SC1090 source=/dev/null
[ -f "${VDM_SRC_PATH}/.env" ] && source "${VDM_SRC_PATH}/.env" [ -f "${VDM_SRC_PATH}/.env" ] && source "${VDM_SRC_PATH}/.env"
# get repo path where store the container deploy scripts # get repo path where store the container deploy scripts
while [ ${#VDM_REPO_PATH} -le 1 ] || [ ! -d "${VDM_REPO_PATH}" ]; do while [ ${#VDM_REPO_PATH} -le 1 ] || [ ! -d "${VDM_REPO_PATH}" ]; do
@ -5324,7 +5558,7 @@ while [ ${#VDM_REPO_PATH} -le 1 ] || [ ! -d "${VDM_REPO_PATH}" ]; do
else else
# get the value # get the value
VDM_REPO_PATH=$(getInput "Enter the repository path where we can store the containers' docker-composer.yml deployment files." \ VDM_REPO_PATH=$(getInput "Enter the repository path where we can store the containers' docker-composer.yml deployment files." \
"/home/${USER}/Docker" 'Enter Repository Path') "${VDM_HOME_PATH}/Docker" 'Enter Repository Path')
# keep asking if empty or does exist # keep asking if empty or does exist
if [ ${#VDM_REPO_PATH} -ge 1 ] && [ ! -d "${VDM_REPO_PATH}" ] && (whiptail --yesno "Can we create the ${VDM_REPO_PATH} repository folder" \ if [ ${#VDM_REPO_PATH} -ge 1 ] && [ ! -d "${VDM_REPO_PATH}" ] && (whiptail --yesno "Can we create the ${VDM_REPO_PATH} repository folder" \
--title "Create the Path" --backtitle "${BACK_TITLE}" 8 112); then --title "Create the Path" --backtitle "${BACK_TITLE}" 8 112); then
@ -5347,7 +5581,7 @@ while [ ${#VDM_PROJECT_PATH} -le 1 ] || [ ! -d "${VDM_PROJECT_PATH}" ]; do
else else
# get the value # get the value
VDM_PROJECT_PATH=$(getInput "Enter the projects' path where we can store the containers' persistent volumes." \ VDM_PROJECT_PATH=$(getInput "Enter the projects' path where we can store the containers' persistent volumes." \
"/home/${USER}/Projects" "Enter Projects' Path") "${VDM_HOME_PATH}/Projects" "Enter Projects' Path")
# keep asking if empty or does exist # keep asking if empty or does exist
if [ ${#VDM_PROJECT_PATH} -ge 1 ] && [ ! -d "${VDM_PROJECT_PATH}" ] && (whiptail --yesno "Can we create the ${VDM_PROJECT_PATH} projects folder" \ if [ ${#VDM_PROJECT_PATH} -ge 1 ] && [ ! -d "${VDM_PROJECT_PATH}" ] && (whiptail --yesno "Can we create the ${VDM_PROJECT_PATH} projects folder" \
--title "Create the Path" --backtitle "${BACK_TITLE}" 8 112); then --title "Create the Path" --backtitle "${BACK_TITLE}" 8 112); then