Update to version 3.7.0 and refactor prompt handling functions

Updated _VERSION to 3.7.0 and replaced whiptail-based yes/no prompts with getInputYesNo function. Added VDM_FORCE flag for automated confirmations.
This commit is contained in:
Llewellyn van der Merwe 2024-10-23 02:36:21 +02:00
parent 593ae84c89
commit 7837d8ecd4
Signed by: Llewellyn
GPG Key ID: A9201372263741E7

View File

@ -1,8 +1,8 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# The most recent program version. # The most recent program version.
_VERSION="3.6.4" _VERSION="3.7.0"
_V="3.6" _V="3.7"
# Bash version required # Bash version required
_bash_v=4 _bash_v=4
@ -296,8 +296,8 @@ function traefik__TRuST__setup() {
# saved the file # saved the file
showNotice "Saved ${VDM_CONTAINER_TYPE}:docker-compose.yml file.\nSetup of this container is complete!" showNotice "Saved ${VDM_CONTAINER_TYPE}:docker-compose.yml file.\nSetup of this container is complete!"
# ask if we should continue to enable # ask if we should continue to enable
if (whiptail --yesno "Would you also like to enable this ${VDM_CONTAINER_TYPE^} container" --defaultno \ if getInputYesNo "Would you also like to enable this ${VDM_CONTAINER_TYPE^} container" \
--title "Enable Container" --backtitle "${BACK_TITLE}" 8 112); then "Enable Container" 8 112 "defaultno"; then
enableContainer "${VDM_CONTAINER_TYPE}" enableContainer "${VDM_CONTAINER_TYPE}"
fi fi
########################## ##########################
@ -408,8 +408,8 @@ function portainer__TRuST__setup() {
# saved the file # saved the file
showNotice "Saved ${VDM_CONTAINER_TYPE}:docker-compose.yml file.\nSetup of this container is complete!" showNotice "Saved ${VDM_CONTAINER_TYPE}:docker-compose.yml file.\nSetup of this container is complete!"
# ask if we should continue to enable # ask if we should continue to enable
if (whiptail --yesno "Would you also like to enable this ${VDM_CONTAINER_TYPE^} container" \ if getInputYesNo "Would you also like to enable this ${VDM_CONTAINER_TYPE^} container" \
--defaultno --title "Enable Container" --backtitle "${BACK_TITLE}" 8 112); then "Enable Container" 8 112 "defaultno"; then
enableContainer "${VDM_CONTAINER_TYPE}" enableContainer "${VDM_CONTAINER_TYPE}"
fi fi
########################## ##########################
@ -606,8 +606,8 @@ function joomla__TRuST__setup() {
# only if in expert mode set the container user detail id needed # only if in expert mode set the container user detail id needed
if isExpert; then 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 getInputYesNo "Would you also like to enable mailcatcher for these ${VDM_CONTAINER_TYPE^} containers" \
--defaultno --title "Enable Mailcatcher" --backtitle "${BACK_TITLE}" 8 112); then "Enable Mailcatcher" 8 112 "defaultno"; 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}")
@ -723,8 +723,8 @@ function joomla__TRuST__setup() {
# saved the file # saved the file
showNotice "Saved ${VDM_CONTAINER_TYPE}:docker-compose.yml file.\nSetup of this container is complete!" showNotice "Saved ${VDM_CONTAINER_TYPE}:docker-compose.yml file.\nSetup of this container is complete!"
# ask if we should continue to enable # ask if we should continue to enable
if (whiptail --yesno "Would you also like to enable this ${VDM_CONTAINER_TYPE^} container" \ if getInputYesNo "Would you also like to enable this ${VDM_CONTAINER_TYPE^} container" \
--defaultno --title "Enable Container" --backtitle "${BACK_TITLE}" 8 112); then "Enable Container" 8 112 "defaultno"; then
# we set the container details # we set the container details
export VDM_CONTAINER="${VDM_SUBDOMAIN}.${VDM_DOMAIN}" export VDM_CONTAINER="${VDM_SUBDOMAIN}.${VDM_DOMAIN}"
# then we enable it # then we enable it
@ -936,8 +936,8 @@ function joomla__TRuST__bulk() {
fi fi
# ask if we should add mailcatcher # ask if we should add mailcatcher
enable_mailcatcher=false enable_mailcatcher=false
if (whiptail --yesno "Would you also like to enable mailcatcher for these ${VDM_CONTAINER_TYPE^} containers" \ if getInputYesNo "Would you also like to enable mailcatcher for these ${VDM_CONTAINER_TYPE^} containers" \
--defaultno --title "Enable Mailcatcher" --backtitle "${BACK_TITLE}" 8 112); then "Enable Mailcatcher" 8 112 "defaultno"; then
enable_mailcatcher=true enable_mailcatcher=true
fi fi
# we only do autodeploy for Joomla 4.3 and above # we only do autodeploy for Joomla 4.3 and above
@ -971,8 +971,8 @@ function joomla__TRuST__bulk() {
setNumberContainers setNumberContainers
# ask if we should continue to enable # ask if we should continue to enable
enable_containers=false enable_containers=false
if (whiptail --yesno "Would you also like to enable all these ${VDM_CONTAINER_TYPE^} containers" \ if getInputYesNo "Would you also like to enable all these ${VDM_CONTAINER_TYPE^} containers" \
--defaultno --title "Enable Containers" --backtitle "${BACK_TITLE}" 8 112); then "Enable Containers" 8 112 "defaultno"; then
enable_containers=true enable_containers=true
fi fi
# loop the number of containers # loop the number of containers
@ -1206,18 +1206,18 @@ function openssh__TRuST__setup() {
# get the global directory of the ssh public keys if not set # get the global directory of the ssh public keys if not set
while [ ${#VDM_PUBLIC_KEY_GLOBAL_DIR} -le 1 ] || [ ! -d "${VDM_PUBLIC_KEY_GLOBAL_DIR}" ]; do while [ ${#VDM_PUBLIC_KEY_GLOBAL_DIR} -le 1 ] || [ ! -d "${VDM_PUBLIC_KEY_GLOBAL_DIR}" ]; do
# creat the path if it exist # creat the path if it exist
if [ ${#VDM_PUBLIC_KEY_GLOBAL_DIR} -ge 1 ] && if [ ${#VDM_PUBLIC_KEY_GLOBAL_DIR} -ge 1 ] && \
(whiptail --yesno "Can we create the ${VDM_PUBLIC_KEY_GLOBAL_DIR} ssh folder" \ getInputYesNo "Can we create the ${VDM_PUBLIC_KEY_GLOBAL_DIR} ssh folder" \
--title "Create the Path" --backtitle "${BACK_TITLE}" 8 112); then "Create the Path" 8 112; then
mkdir -p "${VDM_PUBLIC_KEY_GLOBAL_DIR}" mkdir -p "${VDM_PUBLIC_KEY_GLOBAL_DIR}"
else else
# get the value # get the value
VDM_PUBLIC_KEY_GLOBAL_DIR=$(getInput "Enter the ssh path where we can select the ssh key folders from." \ VDM_PUBLIC_KEY_GLOBAL_DIR=$(getInput "Enter the ssh path where we can select the ssh key folders from." \
"${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/.ssh" 'Enter SSH Path') "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/.ssh" 'Enter SSH Path')
# keep asking if empty or does exist # keep asking if empty or does exist
if [ ${#VDM_PUBLIC_KEY_GLOBAL_DIR} -ge 1 ] && [ ! -d "${VDM_PUBLIC_KEY_GLOBAL_DIR}" ] && if [ ${#VDM_PUBLIC_KEY_GLOBAL_DIR} -ge 1 ] && [ ! -d "${VDM_PUBLIC_KEY_GLOBAL_DIR}" ] && \
(whiptail --yesno "Can we create the ${VDM_PUBLIC_KEY_GLOBAL_DIR} ssh folder" \ getInputYesNo "Can we create the ${VDM_PUBLIC_KEY_GLOBAL_DIR} ssh folder" \
--title "Create the Path" --backtitle "${BACK_TITLE}" 8 112); then "Create the Path" 8 112; then
# shellcheck disable=SC2174 # shellcheck disable=SC2174
mkdir -p -m 700 "${VDM_PUBLIC_KEY_GLOBAL_DIR}" mkdir -p -m 700 "${VDM_PUBLIC_KEY_GLOBAL_DIR}"
elif [ ${#VDM_PUBLIC_KEY_GLOBAL_DIR} -le 1 ]; then elif [ ${#VDM_PUBLIC_KEY_GLOBAL_DIR} -le 1 ]; then
@ -1231,9 +1231,9 @@ function openssh__TRuST__setup() {
# get the directory of this containers public keys if not set # get the directory of this containers public keys if not set
while [ ${#VDM_PUBLIC_KEY_U_DIR} -le 1 ] || [ ! -d "${VDM_PUBLIC_KEY_U_DIR}" ]; do while [ ${#VDM_PUBLIC_KEY_U_DIR} -le 1 ] || [ ! -d "${VDM_PUBLIC_KEY_U_DIR}" ]; do
# creat the path if it exist # creat the path if it exist
if [ ${#VDM_PUBLIC_KEY_U_DIR} -ge 1 ] && if [ ${#VDM_PUBLIC_KEY_U_DIR} -ge 1 ] && \
(whiptail --yesno "Can we create this (${VDM_PUBLIC_KEY_U_DIR}) containers' ssh public keys folder" \ getInputYesNo "Can we create this (${VDM_PUBLIC_KEY_U_DIR}) containers' ssh public keys folder" \
--title "Create the Path" --backtitle "${BACK_TITLE}" 8 112); then "Create the Path" 8 112; then
# shellcheck disable=SC2174 # shellcheck disable=SC2174
mkdir -p -m 700 "${VDM_PUBLIC_KEY_U_DIR}" mkdir -p -m 700 "${VDM_PUBLIC_KEY_U_DIR}"
else else
@ -1245,9 +1245,9 @@ function openssh__TRuST__setup() {
# add the parent dir back # add the parent dir back
VDM_PUBLIC_KEY_U_DIR="${VDM_PUBLIC_KEY_GLOBAL_DIR}/${VDM_PUBLIC_KEY_U_DIR}" VDM_PUBLIC_KEY_U_DIR="${VDM_PUBLIC_KEY_GLOBAL_DIR}/${VDM_PUBLIC_KEY_U_DIR}"
# check if this directory exist # check if this directory exist
if [ ! -d "${VDM_PUBLIC_KEY_U_DIR}" ] && if [ ! -d "${VDM_PUBLIC_KEY_U_DIR}" ] && \
(whiptail --yesno "Can we create this (${VDM_PUBLIC_KEY_U_DIR}) containers' ssh public keys folder" \ getInputYesNo "Can we create this (${VDM_PUBLIC_KEY_U_DIR}) containers' ssh public keys folder" \
--title "Create the Path" --backtitle "${BACK_TITLE}" 8 112); then "Create the Path" 8 112; then
# shellcheck disable=SC2174 # shellcheck disable=SC2174
mkdir -p -m 700 "${VDM_PUBLIC_KEY_U_DIR}" mkdir -p -m 700 "${VDM_PUBLIC_KEY_U_DIR}"
# TODO add option to add keys? # TODO add option to add keys?
@ -1263,18 +1263,18 @@ function openssh__TRuST__setup() {
# get the directory of the ssh public keys if not set # get the directory of the ssh public keys if not set
while [ ${#VDM_PROJECT_U_DIR} -le 1 ] || [ ! -d "${VDM_PROJECT_U_DIR}" ]; do while [ ${#VDM_PROJECT_U_DIR} -le 1 ] || [ ! -d "${VDM_PROJECT_U_DIR}" ]; do
# creat the path if it exist # creat the path if it exist
if [ ${#VDM_PROJECT_U_DIR} -ge 1 ] && if [ ${#VDM_PROJECT_U_DIR} -ge 1 ] && \
(whiptail --yesno "Can we create the ${VDM_PROJECT_U_DIR} parent mounting directory" \ getInputYesNo "Can we create the ${VDM_PROJECT_U_DIR} parent mounting directory" \
--title "Create the Path" --backtitle "${BACK_TITLE}" 8 112); then "Create the Path" 8 112; then
mkdir -p "${VDM_PROJECT_U_DIR}" mkdir -p "${VDM_PROJECT_U_DIR}"
else else
# get the value # get the value
VDM_PROJECT_U_DIR=$(getInput "Enter the parent path where we can select the folders to mount to this container." \ VDM_PROJECT_U_DIR=$(getInput "Enter the parent path where we can select the folders to mount to this container." \
"${VDM_PROJECT_PATH}" 'Enter Path') "${VDM_PROJECT_PATH}" 'Enter Path')
# keep asking if empty or does exist # keep asking if empty or does exist
if [ ${#VDM_PROJECT_U_DIR} -ge 1 ] && [ ! -d "${VDM_PROJECT_U_DIR}" ] && if [ ${#VDM_PROJECT_U_DIR} -ge 1 ] && [ ! -d "${VDM_PROJECT_U_DIR}" ] && \
(whiptail --yesno "Can we create the ${VDM_PROJECT_U_DIR} parent mounting directory" \ getInputYesNo "Can we create the ${VDM_PROJECT_U_DIR} parent mounting directory" \
--title "Create the Path" --backtitle "${BACK_TITLE}" 8 112); then "Create the Path" 8 112; then
# shellcheck disable=SC2174 # shellcheck disable=SC2174
mkdir -p -m 700 "${VDM_PROJECT_U_DIR}" mkdir -p -m 700 "${VDM_PROJECT_U_DIR}"
elif [ ${#VDM_PROJECT_U_DIR} -le 1 ]; then elif [ ${#VDM_PROJECT_U_DIR} -le 1 ]; then
@ -1303,8 +1303,9 @@ function openssh__TRuST__setup() {
# when we mount a joomla volume we may not want to mount the database # when we mount a joomla volume we may not want to mount the database
mFull="${VDM_PROJECT_U_DIR}/${mDir}/joomla" mFull="${VDM_PROJECT_U_DIR}/${mDir}/joomla"
# add to mount projects # add to mount projects
if [ -d "${mFull}" ] && (whiptail --yesno "Should we ONLY mount the (joomla website files) ${mDir}/joomla directory" \ if [ -d "${mFull}" ] && \
--title "Mount Joomla" --backtitle "${BACK_TITLE}" 8 112); then getInputYesNo "Should we ONLY mount the (joomla website files) ${mDir}/joomla directory" \
"Mount Joomla" 8 112; then
VDM_VOLUMES_MOUNT+=$(getYMLine3 "- \${VDM_${VDM_ENV_KEY^^}_PROJECT_DIR}/${mDir}/joomla:/app/${mDir}") VDM_VOLUMES_MOUNT+=$(getYMLine3 "- \${VDM_${VDM_ENV_KEY^^}_PROJECT_DIR}/${mDir}/joomla:/app/${mDir}")
else else
VDM_VOLUMES_MOUNT+=$(getYMLine3 "- \${VDM_${VDM_ENV_KEY^^}_PROJECT_DIR}/${mDir}:/app/${mDir}") VDM_VOLUMES_MOUNT+=$(getYMLine3 "- \${VDM_${VDM_ENV_KEY^^}_PROJECT_DIR}/${mDir}:/app/${mDir}")
@ -1339,8 +1340,8 @@ function openssh__TRuST__setup() {
# saved the file # saved the file
showNotice "Saved ${VDM_CONTAINER_TYPE}:docker-compose.yml file.\nSetup of this container is complete!" showNotice "Saved ${VDM_CONTAINER_TYPE}:docker-compose.yml file.\nSetup of this container is complete!"
# ask if we should continue to enable # ask if we should continue to enable
if (whiptail --yesno "Would you also like to enable this ${VDM_CONTAINER_TYPE^} container" \ if getInputYesNo "Would you also like to enable this ${VDM_CONTAINER_TYPE^} container" \
--defaultno --title "Enable Container" --backtitle "${BACK_TITLE}" 8 112); then "Enable Container" 8 112 "defaultno"; then
# we set the container details # we set the container details
export VDM_CONTAINER="${VDM_USER_NAME}.${VDM_DOMAIN}" export VDM_CONTAINER="${VDM_USER_NAME}.${VDM_DOMAIN}"
# then we enable it # then we enable it
@ -1954,8 +1955,8 @@ function joomla__TRuST__down() {
if ! hasDirectories "${VDM_CONTAINER_TYPE}/enabled/"; then if ! hasDirectories "${VDM_CONTAINER_TYPE}/enabled/"; then
showError "There are no ${VDM_CONTAINER_TYPE^} containers to take down.\n\ showError "There are no ${VDM_CONTAINER_TYPE^} containers to take down.\n\
(UP and DOWN targets only enabled containers)" (UP and DOWN targets only enabled containers)"
elif (whiptail --yesno "Are you absolutely sure you want to take down all the ${VDM_CONTAINER_TYPE^} containers?" \ elif getInputYesNo "Are you absolutely sure you want to take down all the ${VDM_CONTAINER_TYPE^} containers?" \
--title "Take Down Containers" --backtitle "${BACK_TITLE}" 8 112); then "Take Down Containers" 8 112; then
# get all zip files # get all zip files
for yml in "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/"*/*.yml; do for yml in "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/"*/*.yml; do
docker-compose --file "${yml}" down docker-compose --file "${yml}" down
@ -1969,8 +1970,8 @@ function openssh__TRuST__down() {
# check if this type has enabled containers # check if this type has enabled containers
if ! hasDirectories "${VDM_CONTAINER_TYPE}/enabled/"; then if ! hasDirectories "${VDM_CONTAINER_TYPE}/enabled/"; then
showError "There are no ${VDM_CONTAINER_TYPE^} containers to take down." showError "There are no ${VDM_CONTAINER_TYPE^} containers to take down."
elif (whiptail --yesno "Are you absolutely sure you want to take down all the ${VDM_CONTAINER_TYPE^} containers?" \ elif getInputYesNo "Are you absolutely sure you want to take down all the ${VDM_CONTAINER_TYPE^} containers?" \
--title "Take Down Containers" --backtitle "${BACK_TITLE}" 8 112); then "Take Down Containers" 8 112; then
# get all zip files # get all zip files
for yml in "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/"*/*.yml; do for yml in "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/"*/*.yml; do
docker-compose --file "${yml}" down docker-compose --file "${yml}" down
@ -1986,14 +1987,14 @@ function joomla__TRuST__clone() {
showError "The path ${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/available/ does not exist or is empty, first run a ${VDM_CONTAINER_TYPE^} setup." showError "The path ${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/available/ does not exist or is empty, first run a ${VDM_CONTAINER_TYPE^} setup."
else else
# ask if they want to clone a volume # ask if they want to clone a volume
if (whiptail --yesno "Would you like to clone a persistent volume found in (${VDM_PROJECT_PATH})?" \ if getInputYesNo "Would you like to clone a persistent volume found in (${VDM_PROJECT_PATH})?" \
--title "Continue To Clone Persistent Volume" --backtitle "${BACK_TITLE}" 12 112); then "Continue To Clone Persistent Volume" 12 112; then
# trigger the volumes clone script # trigger the volumes clone script
clonePersistentVolume clonePersistentVolume
fi fi
# ask if they want to clone a container # ask if they want to clone a container
if (whiptail --yesno "Would you like to clone a ${VDM_CONTAINER_TYPE^} container?" \ if getInputYesNo "Would you like to clone a ${VDM_CONTAINER_TYPE^} container?" \
--title "Continue To Clone Container (feature not ready)" --defaultno --backtitle "${BACK_TITLE}" 12 112); then "Continue To Clone Container (feature not ready)" 12 112 "defaultno"; then
# set some local variables # set some local variables
local vdm_clone_me local vdm_clone_me
local container local container
@ -2045,17 +2046,17 @@ function joomla__TRuST__delete() {
rm -rf "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${container}" rm -rf "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${container}"
fi fi
# before deleting the config we ask to make sure # before deleting the config we ask to make sure
if (whiptail --yesno "Would you like to delete the (${container}) container's folder that holds the docker-compose.yml file?" \ if getInputYesNo "Would you like to delete the (${container}) container's folder that holds the docker-compose.yml file?" \
--title "Delete Docker Compose Yaml" --backtitle "${BACK_TITLE}" 8 112); then "Delete Docker Compose Yaml" 8 112; then
# then remove docker-compose.yml file # then remove docker-compose.yml file
rm -rf "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/available/${container}" rm -rf "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/available/${container}"
fi fi
done done
fi fi
# ask if there are volumes to delete # ask if there are volumes to delete
if hasDirectories '' "${VDM_PROJECT_PATH}" && if hasDirectories '' "${VDM_PROJECT_PATH}" && \
(whiptail --yesno "Would you like to delete persistent volumes found in (${VDM_PROJECT_PATH})?" \ getInputYesNo "Would you like to delete persistent volumes found in (${VDM_PROJECT_PATH})?" \
--title "Continue To Delete Persistent Volumes" --backtitle "${BACK_TITLE}" 12 112); then "Continue To Delete Persistent Volumes" 12 112; then
# trigger the volumes removal script # trigger the volumes removal script
deletePersistentVolumes deletePersistentVolumes
fi fi
@ -2093,8 +2094,8 @@ function openssh__TRuST__delete() {
rm -fr "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${container}" rm -fr "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/enabled/${container}"
fi fi
# before deleting the config we ask to make sure # before deleting the config we ask to make sure
if (whiptail --yesno "Would you like to delete the (${container}) container's folder that holds the docker-compose.yml file?" \ if getInputYesNo "Would you like to delete the (${container}) container's folder that holds the docker-compose.yml file?" \
--title "Delete Docker Compose Yaml" --backtitle "${BACK_TITLE}" 8 112); then "Delete Docker Compose Yaml" 8 112; then
# then remove docker-compose.yml file # then remove docker-compose.yml file
rm -fr "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/available/${container}" rm -fr "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/available/${container}"
fi fi
@ -2113,8 +2114,8 @@ function traefik__TRuST__delete() {
# make sure the docker image is stopped # make sure the docker image is stopped
docker-compose --file "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/docker-compose.yml" down docker-compose --file "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/docker-compose.yml" down
# before deleting the config we ask to make sure # before deleting the config we ask to make sure
if (whiptail --yesno "Would you like to delete the ${VDM_CONTAINER_TYPE^} container's docker-compose.yml file?" \ if getInputYesNo "Would you like to delete the ${VDM_CONTAINER_TYPE^} container's docker-compose.yml file?" \
--title "Delete Docker Compose Yaml" --backtitle "${BACK_TITLE}" 8 112); then "Delete Docker Compose Yaml" 8 112; then
# then remove docker-compose.yml file # then remove docker-compose.yml file
rm -fr "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/docker-compose.yml" rm -fr "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/docker-compose.yml"
fi fi
@ -2131,8 +2132,8 @@ function portainer__TRuST__delete() {
# make sure the docker image is stopped # make sure the docker image is stopped
docker-compose --file "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/docker-compose.yml" down docker-compose --file "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/docker-compose.yml" down
# before deleting the config we ask to make sure # before deleting the config we ask to make sure
if (whiptail --yesno "Would you like to delete the ${VDM_CONTAINER_TYPE^} container's docker-compose.yml file?" \ if getInputYesNo "Would you like to delete the ${VDM_CONTAINER_TYPE^} container's docker-compose.yml file?" \
--title "Delete Docker Compose Yaml" --backtitle "${BACK_TITLE}" 8 112); then "Delete Docker Compose Yaml" 8 112; then
# then remove docker-compose.yml file # then remove docker-compose.yml file
rm -fr "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/docker-compose.yml" rm -fr "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/docker-compose.yml"
fi fi
@ -2143,9 +2144,9 @@ function portainer__TRuST__delete() {
######################################## RESET JOOMLA ######################################## RESET JOOMLA
function joomla__TRuST__reset() { function joomla__TRuST__reset() {
# ask if there are volumes to delete # ask if there are volumes to delete
if hasDirectories '' "${VDM_PROJECT_PATH}" && if hasDirectories '' "${VDM_PROJECT_PATH}" && \
(whiptail --yesno "Would you like to reset persistent volumes found in (${VDM_PROJECT_PATH})?" \ getInputYesNo "Would you like to reset persistent volumes found in (${VDM_PROJECT_PATH})?" \
--title "Continue To Reset Persistent Volumes" --backtitle "${BACK_TITLE}" 12 112); then "Continue To Reset Persistent Volumes" 12 112; then
# trigger the volumes reset script # trigger the volumes reset script
resetPersistentJoomlaVolumes resetPersistentJoomlaVolumes
fi fi
@ -2643,8 +2644,8 @@ function resetPersistentJoomlaVolumes() {
# make an update # make an update
function runUpdate() { function runUpdate() {
# we need sudo permissions # we need sudo permissions
if (whiptail --yesno "${USER^}, to update ${PROGRAM_NAME} we need sudo privileges." \ if getInputYesNo "${USER^}, to update ${PROGRAM_NAME} we need sudo privileges." \
--title "Give sudo Privileges" --backtitle "${BACK_TITLE}" 8 112); then "Give sudo Privileges" 8 112; then
# remove the current version # remove the current version
if [ -f /usr/local/bin/octojoom ]; then if [ -f /usr/local/bin/octojoom ]; then
# just backup in case of failure # just backup in case of failure
@ -3608,6 +3609,42 @@ function getInput() {
echo "${answer}" echo "${answer}"
} }
# Display a yes/no prompt using the whiptail utility.
# If "defaultno" is passed as the fifth parameter, it defaults to "No" when VDM_FORCE is set to "true".
# $1: Prompt message
# $2 (optional): Title for the dialog (default: "Confirmation Required")
# $3 (optional): Height of the dialog (default: 8)
# $4 (optional): Width of the dialog (default: 50)
# $5 (optional): Set to "defaultno" to make "No" the default choice.
# Returns 0 (yes) if the user selects "Yes".
# Returns 1 (no) if the user selects "No" or if "defaultno" is set and VDM_FORCE is "true".
function getInputYesNo() {
# set local vars
local question="$1"
local title="${2:-Confirmation Required}"
local height="${3:-8}"
local width="${4:-50}"
local defaultno="${5:-}"
# Handle VDM_FORCE behavior based on the 'defaultno' parameter
if [ "$VDM_FORCE" = "true" ]; then
if [ "$defaultno" = "defaultno" ]; then
return 1 # Default to No if "defaultno" is set and VDM_FORCE is true
else
return 0 # Default to Yes if "defaultno" is not set and VDM_FORCE is true
fi
else
# Display the whiptail prompt with the provided parameters
if [ "$defaultno" = "defaultno" ]; then
whiptail --defaultno --yesno "$question" "$height" "$width" --title "$title" \
--backtitle "${BACK_TITLE}" 3>&1 1>&2 2>&3
else
whiptail --yesno "$question" "$height" "$width" --title "$title" \
--backtitle "${BACK_TITLE}" 3>&1 1>&2 2>&3
fi
fi
}
# get the input until is gotten # get the input until is gotten
function getInputNow() { function getInputNow() {
local message local message
@ -3930,9 +3967,9 @@ function getMainDomain() {
# set the container user # set the container user
function setContainerUser() { function setContainerUser() {
# ask if a new User ID should be set if one is set # ask if a new User ID should be set if one is set
if [ -n "${VDM_PUID}" ] && [[ "${VDM_PUID}" =~ ^[0-9]+$ ]] && if [ -n "${VDM_PUID}" ] && [[ "${VDM_PUID}" =~ ^[0-9]+$ ]] && \
(whiptail --yesno "The user ID in ${PROGRAM_NAME} memory is ${VDM_PUID}, would you like to change this user ID?" \ getInputYesNo "The user ID in ${PROGRAM_NAME} memory is ${VDM_PUID}, would you like to change this user ID?" \
--defaultno --title "Set User ID" --backtitle "${BACK_TITLE}" 8 112); then "Set User ID" 8 112 "defaultno"; then
# always first reset # always first reset
unset VDM_PUID unset VDM_PUID
fi fi
@ -3947,10 +3984,11 @@ function setContainerUser() {
showError "You must enter a user ID like: ${1:-1000} (only the number)" showError "You must enter a user ID like: ${1:-1000} (only the number)"
fi fi
done done
# ask if a new Group ID should be set if one is set # ask if a new Group ID should be set if one is set
if [ -n "${VDM_PGID}" ] && [[ "${VDM_PGID}" =~ ^[0-9]+$ ]] && if [ -n "${VDM_PGID}" ] && [[ "${VDM_PGID}" =~ ^[0-9]+$ ]] && \
(whiptail --yesno "The user-group ID in ${PROGRAM_NAME} memory is ${VDM_PGID}, would you like to change this user-group ID?" \ getInputYesNo "The user-group ID in ${PROGRAM_NAME} memory is ${VDM_PGID}, would you like to change this user-group ID?" \
--defaultno --title "Set User-Group ID" --backtitle "${BACK_TITLE}"8 112); then "Set User-Group ID" 8 112 "defaultno"; then
# always first reset # always first reset
unset VDM_PGID unset VDM_PGID
fi fi
@ -4119,9 +4157,9 @@ function setUniqueKey() {
# set the Joomla website details # set the Joomla website details
function setJoomlaWebsiteDetails() { function setJoomlaWebsiteDetails() {
# ask if we should add autodeployment # ask if we should add auto deployment
if (whiptail --yesno "Would you like to enable website autodeploy for ${VDM_CONTAINER_TYPE,}:${VDM_JV}" \ if getInputYesNo "Would you like to enable website auto deploy for ${VDM_CONTAINER_TYPE,}:${VDM_JV}" \
--defaultno --title "Enable Autodeploy" --backtitle "${BACK_TITLE}" 8 112); then "Enable Auto deploy" 8 112; then
# ask for website name # ask for website name
setJoomlaSiteName setJoomlaSiteName
@ -4391,8 +4429,8 @@ function isVersionAbove() {
# set persistence volumes # set persistence volumes
function setPersistence() { function setPersistence() {
# ask the question # ask the question
if (whiptail --yesno "Would you like to enable persistence on this $1." \ if getInputYesNo "Would you like to enable persistence on this $1." \
--title "Persist Volume" --backtitle "${BACK_TITLE}" 8 112); then "Persist Volume" 8 112; then
# yes persistence # yes persistence
return 0 return 0
fi fi
@ -4403,8 +4441,8 @@ function setPersistence() {
# set the PHP settings # set the PHP settings
function setPHPSettings() { function setPHPSettings() {
# ask the question # ask the question
if (whiptail --yesno "Would you like to set some PHP overrides for the Joomla container.\n\nTo make these changes we need sudo privileges." \ if getInputYesNo "Would you like to set some PHP overrides for the Joomla container.\n\nTo make these changes we need sudo privileges." \
--defaultno --title "PHP.ini values" --backtitle "${BACK_TITLE}" 9 112); then "PHP.ini values" 9 112; then
# max_execution_time # max_execution_time
VDM_max_execution_time=$(getInputNow "Enter max execution time" \ VDM_max_execution_time=$(getInputNow "Enter max execution time" \
@ -4464,8 +4502,8 @@ function setPHPSettings() {
} > "${VDM_PROJECT_PATH}/${VDM_PHP_PROJECT_PATH}/php.ini" } > "${VDM_PROJECT_PATH}/${VDM_PHP_PROJECT_PATH}/php.ini"
# allow custom edit # allow custom edit
if isExpert && (whiptail --yesno "Would you like to set some more custom PHP overrides for this Joomla container" \ if isExpert && getInputYesNo "Would you like to set some more custom PHP overrides for this Joomla container" \
--defaultno --title "Edit PHP.ini" --backtitle "${BACK_TITLE}" 8 112); then "Edit PHP.ini" 8 112 "defaultno"; then
# give little heads-up # give little heads-up
showNotice "${USER^}, to save the changes you've made or to just close the file again press:\n\n[ctrl+x] with nano on ubuntu." 13 showNotice "${USER^}, to save the changes you've made or to just close the file again press:\n\n[ctrl+x] with nano on ubuntu." 13
# lets open the file with nano for now # lets open the file with nano for now
@ -4490,8 +4528,8 @@ function setPHPSettings() {
# set the docker entrypoint # set the docker entrypoint
function setDockerEntrypoint() { function setDockerEntrypoint() {
# ask the question # ask the question
if (whiptail --yesno "Would you like to customize the entrypoint script for this Joomla container" \ if getInputYesNo "Would you like to customize the entrypoint script for this Joomla container" \
--defaultno --title "entrypoint.sh values" --backtitle "${BACK_TITLE}" 8 112); then "entrypoint.sh values" 8 112 "defaultno"; then
# make sure the directory exist # make sure the directory exist
mkdir -p "${VDM_PROJECT_PATH}/${VDM_ENTRY_PROJECT_PATH}" mkdir -p "${VDM_PROJECT_PATH}/${VDM_ENTRY_PROJECT_PATH}"
# unattended deploy # unattended deploy
@ -4523,8 +4561,8 @@ function setDockerEntrypoint() {
# set the secure state # set the secure state
function setSecureCloudflareState() { function setSecureCloudflareState() {
# check the security switch # check the security switch
if (whiptail --yesno "Will this container be proxied by Cloudflare [ONLY for server proxied in none-strict mode via Cloudflare]" \ if getInputYesNo "Will this container be proxied by Cloudflare [ONLY for server proxied in none-strict mode via Cloudflare]" \
--defaultno --title "Cloudflare" --backtitle "${BACK_TITLE}" 8 112); then "Cloudflare" 8 112 "defaultno"; then
# we set the secure switch # we set the secure switch
VDM_SECURE_CLOUDFLARE=true VDM_SECURE_CLOUDFLARE=true
else else
@ -4538,8 +4576,8 @@ function setSecureCloudflareState() {
function setSecureState() { function setSecureState() {
if [ "${VDM_SECURE:-not}" = 'not' ]; then if [ "${VDM_SECURE:-not}" = 'not' ]; then
# check the security switch # check the security switch
if (whiptail --yesno "Would you like to use Letsencrypt auto setup for your containers [ONLY for server with public static IP]" \ if getInputYesNo "Would you like to use Letsencrypt auto setup for your containers [ONLY for server with public static IP]" \
--defaultno --title "Letsencrypt" --backtitle "${BACK_TITLE}" 8 112); then "Letsencrypt" 8 112 "defaultno"; then
# we set the secure switch # we set the secure switch
VDM_SECURE=true VDM_SECURE=true
else else
@ -5053,11 +5091,13 @@ function pushContainerMigration() {
remote_repo_path=$(getRemoteEnvValue "${remote}" "VDM_REPO_PATH") remote_repo_path=$(getRemoteEnvValue "${remote}" "VDM_REPO_PATH")
if [ ! "${remote_repo_path}" = 'none_found' ]; then if [ ! "${remote_repo_path}" = 'none_found' ]; then
local remote_path="${remote_repo_path}/${container_path}" local remote_path="${remote_repo_path}/${container_path}"
# check how we must do this # check if we must backup remote folder
if remoteFolderExists "${remote_path}" "${remote}" && (whiptail --yesno "${USER^}, would you like to backup the remote container?" \ if remoteFolderExists "${remote_path}" "${remote}" && (whiptail --yesno "${USER^}, would you like to backup the remote container?" \
--backtitle "${BACK_TITLE}" --title "Backup Remote" 15 112); then --backtitle "${BACK_TITLE}" --title "Backup Remote" 15 112); then
backupRemoteFolder "${remote_path}" "${remote}" backupRemoteFolder "${remote_path}" "${remote}"
fi fi
# if folder still exist remove remote folder
removeRemoteFolder "${remote_path}" "${remote}"
# sync folder # sync folder
syncWithRemote "${local_path}" "${remote_path}" "${remote}" syncWithRemote "${local_path}" "${remote_path}" "${remote}"
# check if it was done successfully # check if it was done successfully
@ -5124,6 +5164,8 @@ function pushDirectoryMigration() {
then then
backupRemoteFolder "${remote_path}" "${remote}" backupRemoteFolder "${remote_path}" "${remote}"
fi fi
# if folder still exist remove remote folder
removeRemoteFolder "${remote_path}" "${remote}"
# un-tar the remote file # un-tar the remote file
remoteUntarGz "${remote_path}.tar.gz" "${remote_path}" "${remote}" remoteUntarGz "${remote_path}.tar.gz" "${remote_path}" "${remote}"
# we are done # we are done
@ -5253,6 +5295,17 @@ function backupRemoteFolder() {
ssh "${remote}" "if [ -d '${remote_path}' ]; then mv '${remote_path}' '${backup_name}'; fi" ssh "${remote}" "if [ -d '${remote_path}' ]; then mv '${remote_path}' '${backup_name}'; fi"
} }
# remove the remote folder
function removeRemoteFolder() {
local remote_path="$1"
local remote="$2"
# always confirm that the path exist
if remoteFolderExists "${remote_path}" "${remote}"; then
# shellcheck disable=SC2029
ssh "${remote}" "if [ -d '${remote_path}' ]; then sudo rm -Irf '${remote_path}'; fi"
fi
}
# Prep remote folder # Prep remote folder
function prepRemoteFolder() { function prepRemoteFolder() {
local remote_path="$1" local remote_path="$1"
@ -5481,6 +5534,7 @@ EOF
# defaults # defaults
VDM_ARG_DOMAIN=false VDM_ARG_DOMAIN=false
VDM_FORCE=false
# check if we have options # check if we have options
while :; do while :; do
@ -5493,6 +5547,9 @@ while :; do
runUpdate runUpdate
shift shift
;; ;;
-y | --yes)
VDM_FORCE=true
;;
--access-token) # Takes an option argument; ensure it has been specified. --access-token) # Takes an option argument; ensure it has been specified.
if [ "$2" ]; then if [ "$2" ]; then
VDM_ACCESS_TOKEN=$2 VDM_ACCESS_TOKEN=$2