Add option to install Joomla extensions via env value.

This commit is contained in:
Llewellyn van der Merwe 2024-05-10 20:21:41 +02:00
parent 42c85ba582
commit 69f00e830e
Signed by: Llewellyn
GPG Key ID: A9201372263741E7

View File

@ -1,8 +1,8 @@
#!/bin/bash #!/bin/bash
# The most recent program version. # The most recent program version.
_VERSION="3.4.6" _VERSION="3.5.0"
_V="3.4" _V="3.5"
# The program full name # The program full name
PROGRAM_NAME="Octojoom" PROGRAM_NAME="Octojoom"
@ -462,6 +462,8 @@ 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
@ -485,10 +487,8 @@ function joomla__TRuST__setup() {
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
@ -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_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 +619,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
@ -796,11 +802,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
@ -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_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
@ -917,7 +932,7 @@ function joomla__TRuST__bulk() {
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=''
@ -1002,6 +1017,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
@ -3737,7 +3753,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 +3772,8 @@ function setJoomlaWebsiteDetails() {
# ask for username password # ask for username password
setJoomlaPassword setJoomlaPassword
# ask for extension URLs
setJoomlaExtensionUrls
fi fi
} }
@ -3846,6 +3864,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 +3985,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}"
@ -4943,8 +4993,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
====================================================== ======================================================