5 Commits

Author SHA1 Message Date
eb3bb297b9 Update URLs to use raw.githubusercontent.com for downloads
Switched from git.vdm.dev to raw.githubusercontent.com for fetching [octojoom] and related scripts. This ensures wider accessibility and consistency with GitHub's standard hosting practices. Updated references in the script and README accordingly.Update URLs to use raw.githubusercontent.com for downloads

Switched from git.vdm.dev to raw.githubusercontent.com for fetching [octojoom] and related scripts. This ensures wider accessibility and consistency with GitHub's standard hosting practices. Updated references in the script and README accordingly.
2025-02-26 11:38:38 +02:00
05660f568c Update remote .env handling and set version to 3.7.1
Refactor remote .env file access to use the remote user's home directory for improved reliability. Adjust comments for clarity and ensure consistent handling of tilde expansion remotely. Increment version to 3.7.1 to reflect these changes.
2025-02-26 11:26:10 +02:00
5ceddb1c71 Add network configuration option in expert mode menu
Introduced a new menu option for setting network configurations when in expert mode. Updated menu handling logic to include this new option and integrated the corresponding function call.
2024-10-24 00:58:27 +02:00
1cc718832a Add conditional handling for environment files in docker-compose
Modified the script to conditionally check for the presence of environment files associated with each Docker image before bringing the containers down. This ensures that if an environment file exists, it is used with docker-compose, providing a more flexible and robust container management process.
2024-10-24 00:50:24 +02:00
7837d8ecd4 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.
2024-10-23 02:36:21 +02:00
2 changed files with 186 additions and 95 deletions

View File

@ -20,7 +20,7 @@ Linted by [#ShellCheck](https://github.com/koalaman/shellcheck)
--- ---
# Install # Install
```shell ```shell
$ sudo curl -L "https://git.vdm.dev/api/v1/repos/octoleo/octojoom/raw/src/octojoom" -o /usr/local/bin/octojoom $ sudo curl -L "https://raw.githubusercontent.com/octoleo/octojoom/refs/heads/master/src/octojoom" -o /usr/local/bin/octojoom
$ sudo chmod +x /usr/local/bin/octojoom $ sudo chmod +x /usr/local/bin/octojoom
``` ```

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.1"
_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,11 +1955,24 @@ 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
# get the vdm_container value
vdm_container="${yml%/docker-compose.yml}"
# check if image has its own env file also
evn_file=''
# check if image has its own env file also
# shellcheck disable=SC2015
[ -f "${vdm_container}/.env" ] && evn_file="${vdm_container}/.env" || {
[ -f "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/.env" ] && evn_file="${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/.env"
}
# make sure the docker image is started
# shellcheck disable=SC2015
[ ${#evn_file} -ge 1 ] && docker-compose --env-file "${evn_file}" --file "${yml}" down || {
docker-compose --file "${yml}" down docker-compose --file "${yml}" down
}
done done
fi fi
} }
@ -1969,11 +1983,24 @@ 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
# get the vdm_container value
vdm_container="${yml%/docker-compose.yml}"
# check if image has its own env file also
evn_file=''
# check if image has its own env file also
# shellcheck disable=SC2015
[ -f "${vdm_container}/.env" ] && evn_file="${vdm_container}/.env" || {
[ -f "${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/.env" ] && evn_file="${VDM_REPO_PATH}/${VDM_CONTAINER_TYPE}/.env"
}
# make sure the docker image is started
# shellcheck disable=SC2015
[ ${#evn_file} -ge 1 ] && docker-compose --env-file "${evn_file}" --file "${yml}" down || {
docker-compose --file "${yml}" down docker-compose --file "${yml}" down
}
done done
fi fi
} }
@ -1986,14 +2013,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 +2072,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 +2120,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 +2140,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 +2158,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 +2170,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 +2670,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
@ -2655,7 +2682,7 @@ function runUpdate() {
# get the target branch to use in our update # get the target branch to use in our update
isExpert && branch=$(getTargetBranch) isExpert && branch=$(getTargetBranch)
# pull the latest version. Master is always the latest # pull the latest version. Master is always the latest
if sudo curl --fail -L "https://git.vdm.dev/api/v1/repos/octoleo/octojoom/raw/src/octojoom?ref=${branch:-master}" -o /usr/local/bin/octojoom 2>/dev/null; then if sudo curl --fail -L "https://raw.githubusercontent.com/octoleo/octojoom/refs/heads/${branch:-master}/src/octojoom" -o /usr/local/bin/octojoom 2>/dev/null; then
# give success message # give success message
echo "SUCCESS: Update was successful." echo "SUCCESS: Update was successful."
# do we have a backup # do we have a backup
@ -3085,6 +3112,8 @@ function showTraefik() {
# delete traefik container # delete traefik container
[ -f "${VDM_REPO_PATH}/traefik/docker-compose.yml" ] && [ -f "${VDM_REPO_PATH}/traefik/docker-compose.yml" ] &&
menu_options+=("delete" "Delete Traefik") && i=$((i + 1)) menu_options+=("delete" "Delete Traefik") && i=$((i + 1))
# set network if not set
isExpert && menu_options+=("network" "Set Network") && i=$((i + 1))
# Quit Octoleo Program # Quit Octoleo Program
menu_options+=("quit" "Quit ${PROGRAM_NAME}") menu_options+=("quit" "Quit ${PROGRAM_NAME}")
# get the selection # get the selection
@ -3112,12 +3141,15 @@ function showTraefik() {
"delete") "delete")
deleteContainer 'traefik' deleteContainer 'traefik'
;; ;;
"network")
setNetworks
;;
"quit") quitProgram ;; "quit") quitProgram ;;
esac esac
# menu loop # menu loop
case $CHOICE in case $CHOICE in
"setup" | "edit" | "enable" | "disable" | "delete") "setup" | "edit" | "enable" | "disable" | "delete" | "network")
showTraefik showTraefik
;; ;;
esac esac
@ -3608,6 +3640,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
@ -3781,7 +3849,7 @@ function getImageSource() {
local i=2 local i=2
# set the defaults # set the defaults
default="joomla|https://hub.docker.com/_/joomla?tab=tags;https://raw.githubusercontent.com/joomla-docker/docker-joomla/master/docker-entrypoint.sh" default="joomla|https://hub.docker.com/_/joomla?tab=tags;https://raw.githubusercontent.com/joomla-docker/docker-joomla/master/docker-entrypoint.sh"
default_octojoom="llewellyn/joomla|https://hub.docker.com/r/llewellyn/joomla/tags;https://git.vdm.dev/octoleo/docker-joomla/raw/branch/octoleo/docker-entrypoint.sh" default_octojoom="llewellyn/joomla|https://hub.docker.com/r/llewellyn/joomla/tags;https://raw.githubusercontent.com/octoleo/docker-joomla/refs/heads/octoleo/docker-entrypoint.sh"
# we only ask if we are in expert mode # we only ask if we are in expert mode
if isExpert; then if isExpert; then
# set the base images source # set the base images source
@ -3930,9 +3998,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 +4015,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
@ -4120,8 +4189,8 @@ function setUniqueKey() {
# set the Joomla website details # set the Joomla website details
function setJoomlaWebsiteDetails() { function setJoomlaWebsiteDetails() {
# ask if we should add auto deployment # 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 +4460,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 +4472,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 +4533,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 +4559,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 +4592,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 +4607,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
@ -4999,24 +5068,27 @@ function getMigrationType() {
echo "${answer:-push}" echo "${answer:-push}"
} }
# Check if the remote .env file exists # Check if the remote .env file exists using the remote user's home directory
function remoteEnvFileExists() { function remoteEnvFileExists() {
local remote_system="$1" local remote_system="$1"
# Check if the file exists on the remote system # The tilde (~) expands to the home directory of the logged-in remote user.
# shellcheck disable=SC2029 # Using single quotes ensures that the command is passed literally to the remote shell,
ssh "${remote_system}" "[ -f \"${VDM_HOME_PATH}/.config/octojoom/.env\" ]" # allowing the tilde expansion to occur remotely.
ssh "${remote_system}" '[ -f ~/.config/octojoom/.env ]'
} }
# Get a specific value from the remote .env file # Get a specific value from the remote .env file using the remote user's home directory
function getRemoteEnvValue() { function getRemoteEnvValue() {
local remote_system="$1" local remote_system="$1"
local env_key="$2" local env_key="$2"
local remote_env_value local remote_env_value
if remoteEnvFileExists "${remote_system}"; then if remoteEnvFileExists "${remote_system}"; then
# shellcheck disable=SC2029 # Execute the grep command on the remote system.
remote_env_value=$(ssh "${remote_system}" "grep '^${env_key}=' \"${VDM_HOME_PATH}/.config/octojoom/.env\"" | cut -d '=' -f 2-) # The command uses \$HOME so that the remote shell expands it to the logged-in user's home directory.
# The env_key variable is expanded locally, while the file path remains intact for the remote shell.
remote_env_value=$(ssh "${remote_system}" "grep '^${env_key}=' \"\$HOME/.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
@ -5053,11 +5125,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 +5198,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 +5329,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 +5568,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 +5581,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