Compare commits

...

5 Commits

2 changed files with 168 additions and 36 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.
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.
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...)
---

View File

@ -1,8 +1,8 @@
#!/bin/bash
# The most recent program version.
_VERSION="3.4.4"
_V="3.4"
_VERSION="3.5.1"
_V="3.5"
# The program full name
PROGRAM_NAME="Octojoom"
@ -462,33 +462,33 @@ function joomla__TRuST__setup() {
$reset_volume && VDM_VOLUMES=''
# add the projects path
setContainerEnvVariable "VDM_PROJECT_PATH=\"${VDM_PROJECT_PATH}\""
# ask if we should add mailcatcher
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
VDM_EXTRA_CONTAINER_STUFF=$(getYMLine1 "mailcatcher${VDM_KEY}:")
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine2 "image: schickling/mailcatcher")
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine2 "container_name: mailcatcher${VDM_KEY}")
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine2 "restart: unless-stopped")
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine2 "networks:")
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "- traefik")
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine2 "labels:")
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "# mailcatcher")
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}\`)\"")
if $VDM_SECURE; then
if $VDM_SECURE_CLOUDFLARE; then
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "- \"traefik.http.routers.mailcatcher${VDM_KEY}.entrypoints=web\"")
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}.tls.certresolver=vdmresolver\"")
fi
fi
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_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_SMTP_HOST=mailcatcher${VDM_KEY}")
fi
# only if in expert mode set the container user detail id needed
if isExpert; then
# ask if we should add mailcatcher
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
VDM_EXTRA_CONTAINER_STUFF=$(getYMLine1 "mailcatcher${VDM_KEY}:")
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine2 "image: schickling/mailcatcher")
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine2 "container_name: mailcatcher${VDM_KEY}")
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine2 "restart: unless-stopped")
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine2 "networks:")
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "- traefik")
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine2 "labels:")
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "# mailcatcher")
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}\`)\"")
if $VDM_SECURE; then
if $VDM_SECURE_CLOUDFLARE; then
VDM_EXTRA_CONTAINER_STUFF+=$(getYMLine3 "- \"traefik.http.routers.mailcatcher${VDM_KEY}.entrypoints=web\"")
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}.tls.certresolver=vdmresolver\"")
fi
fi
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_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_SMTP_HOST=mailcatcher${VDM_KEY}:1080")
fi
# if this is our octoleo images we can also set the user ID and user-group ID
setContainerUser "$(id -u)"
# check that we got the details
@ -526,6 +526,11 @@ function joomla__TRuST__setup() {
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}")
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
# add PHP settings
VDM_PHP_PROJECT_PATH="${VDM_KEY}"
@ -614,6 +619,7 @@ function joomla__TRuST__setup() {
unset VDM_J_USER
unset VDM_J_EMAIL
unset VDM_J_PASSWORD
unset VDM_J_EXTENSIONS_URLS
# container lower
unset vdm_database_name
unset vdm_database_user
@ -796,11 +802,15 @@ function joomla__TRuST__bulk() {
fi
# we only do autodeploy for Joomla 4.3 and above
enable_autodeploy=false
enable_extension_autodeploy=false
if isVersionAbove "$VDM_JV" "4.3"; then
# get website setup details
setJoomlaWebsiteDetails
if [[ -n "${VDM_J_EMAIL}" ]]; then
enable_autodeploy=true
if [[ -n "${VDM_J_EXTENSIONS_URLS}" && "${#VDM_J_EXTENSIONS_URLS}" -gt 2 ]]; then
enable_extension_autodeploy=true
fi
fi
fi
# add the projects path
@ -869,6 +879,11 @@ function joomla__TRuST__bulk() {
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_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
# set persistence
reset_volume=true
@ -917,7 +932,7 @@ function joomla__TRuST__bulk() {
fi
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_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_SMTP_HOST=mailcatcher${VDM_KEY}")
VDM_EXTRA_JOOMLA_ENV+=$(getYMLine3 "- JOOMLA_SMTP_HOST=mailcatcher${VDM_KEY}:1080")
fi
# setup letsencrypt stuff
VDM_JOOMLA_SECURE_LABELS=''
@ -1002,6 +1017,7 @@ function joomla__TRuST__bulk() {
unset VDM_J_USER
unset VDM_J_EMAIL
unset VDM_J_PASSWORD
unset VDM_J_EXTENSIONS_URLS
# container lower
unset vdm_database_name
unset vdm_database_user
@ -1878,6 +1894,18 @@ function portainer__TRuST__delete() {
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
######################################## Migrate Joomla
function joomla__TRuST__migrate() {
@ -2073,6 +2101,15 @@ function deleteContainer() {
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
function migrateContainer() {
# make sure of our container type
@ -2270,6 +2307,47 @@ function deletePersistentVolumes() {
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
function runUpdate() {
# we need sudo permissions
@ -2546,6 +2624,9 @@ function showJoomla() {
# delete a container
hasDirectories 'joomla/available' &&
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
isExpert && hasDirectories 'joomla/available' &&
menu_options+=("joomla_env" "Open Joomla .env Details") && i=$((i + 1))
@ -2555,7 +2636,7 @@ function showJoomla() {
menu_options+=("quit" "Quit ${PROGRAM_NAME}")
# get the selection
CHOICE=$(
whiptail --menu "Make your selection" 20 112 $i \
whiptail --menu "Make your selection" 23 112 $i \
--title "Joomla | ${PROGRAM_NAME} v${_V}" --fb \
--backtitle "${BACK_TITLE}" --nocancel --notags \
"${menu_options[@]}" 3>&2 2>&1 1>&3
@ -2587,6 +2668,9 @@ function showJoomla() {
"delete")
deleteContainer 'joomla'
;;
"reset")
resetContainer 'joomla'
;;
"joomla_env")
openEnv 'joomla'
;;
@ -2598,7 +2682,7 @@ function showJoomla() {
# menu loop
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
;;
esac
@ -3737,7 +3821,7 @@ function setUniqueKey() {
# set the Joomla website details
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}" \
--defaultno --title "Enable Autodeploy" --backtitle "${BACK_TITLE}" 8 112); then
@ -3756,6 +3840,8 @@ function setJoomlaWebsiteDetails() {
# ask for username password
setJoomlaPassword
# ask for extension URLs
setJoomlaExtensionUrls
fi
}
@ -3846,6 +3932,38 @@ function setJoomlaPassword() {
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
function setNumberContainers() {
local valid=0
@ -3935,7 +4053,7 @@ function setImageSource() {
# get the Joomla version if not set
while [ ${#VDM_JV} -le 1 ]; do
# 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
[ ${#VDM_JV} -ge 1 ] || {
showError "You must enter a version tag. See available tags here ${vdm_tag_url}"
@ -4002,6 +4120,12 @@ function setPHPSettings() {
# remember this for next 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
default_error_reporting="E_ALL & ~E_DEPRECATED & ~E_STRICT"
VDM_error_reporting=$(getInputNow "Enter error reporting" \
@ -4034,6 +4158,7 @@ function setPHPSettings() {
{
echo "max_execution_time = ${VDM_max_execution_time}"
echo "max_input_time = ${VDM_max_input_time}"
echo "max_input_vars = ${VDM_max_input_vars}"
echo "error_reporting = ${VDM_error_reporting}"
echo "upload_max_filesize = ${VDM_upload_max_filesize}"
echo "post_max_size = ${VDM_post_max_size}"
@ -4936,8 +5061,8 @@ Usage: octojoom [OPTION...]
======================================================
-j|--joomla-version <version-tag>
see available tags here https://hub.docker.com/_/joomla
example: octojoom -j=5.0
example: octojoom --joomla-version=5.0
example: octojoom -j=5.1
example: octojoom --joomla-version=5.1
======================================================
AVAILABLE FOR OPENSSH CONTAINER
======================================================
@ -5313,7 +5438,7 @@ mkdir -p -m '700' "${VDM_SRC_PATH}"
# first run switch
VDM_FIRST_RUN=false
# load the globals
# shellcheck disable=SC1090
# shellcheck disable=SC1090 source=/dev/null
[ -f "${VDM_SRC_PATH}/.env" ] && source "${VDM_SRC_PATH}/.env"
# get repo path where store the container deploy scripts
while [ ${#VDM_REPO_PATH} -le 1 ] || [ ! -d "${VDM_REPO_PATH}" ]; do