Add reset volume feature to Joomla

This commit is contained in:
Llewellyn van der Merwe 2024-05-14 09:41:39 +02:00
parent 69f00e830e
commit 2ca0fc61ce
Signed by: Llewellyn
GPG Key ID: A9201372263741E7

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# The most recent program version. # The most recent program version.
_VERSION="3.5.0" _VERSION="3.5.1"
_V="3.5" _V="3.5"
# The program full name # The program full name
@ -1894,6 +1894,18 @@ function portainer__TRuST__delete() {
fi fi
} }
#####################################################################################################################VDM
######################################## RESET JOOMLA
function joomla__TRuST__reset() {
# ask if there are volumes to delete
if hasDirectories '' "${VDM_PROJECT_PATH}" &&
(whiptail --yesno "Would you like to reset persistent volumes found in (${VDM_PROJECT_PATH})?" \
--title "Continue To Reset Persistent Volumes" --backtitle "${BACK_TITLE}" 12 112); then
# trigger the volumes reset script
resetPersistentJoomlaVolumes
fi
}
#####################################################################################################################VDM #####################################################################################################################VDM
######################################## Migrate Joomla ######################################## Migrate Joomla
function joomla__TRuST__migrate() { function joomla__TRuST__migrate() {
@ -2089,6 +2101,15 @@ function deleteContainer() {
main main
} }
# reset a container
function resetContainer() {
# make sure of our container type
VDM_CONTAINER_TYPE="${1}"
VDM_TASK="reset"
# execute the task
main
}
# migrate a container # migrate a container
function migrateContainer() { function migrateContainer() {
# make sure of our container type # make sure of our container type
@ -2286,6 +2307,47 @@ function deletePersistentVolumes() {
fi fi
} }
# reset persistent Joomla volume
function resetPersistentJoomlaVolumes() {
# we first check if we have some volumes
if hasDirectories '' "${VDM_PROJECT_PATH}"; then
# set some local variables
local vdm_reset_volumes
local persistent
# saved the file
showNotice "Only reset persistent Joomla volumes of which you have made absolutely sure it's no longer in use!"
# get containers to enable
vdm_reset_volumes=$(getSelectedDirectories "Select persistent volume\s to reset." \
"${VDM_PROJECT_PATH}" "Select Persistent Volume\s to Reset")
# check that we have something, else return to main menu
if [ ${#vdm_reset_volumes} -ge 1 ]; then
# convert the string to and array
IFS=' ' read -r -a vdm_reset_volumes_array <<<"${vdm_reset_volumes[@]}"
# loop over the directories to build the
for volumes in "${vdm_reset_volumes_array[@]}"; do
# remove the " from the string
persistent="${volumes//\"/}"
# last serious check and then its gone
if [ -d "${VDM_PROJECT_PATH}/${persistent}/joomla" ] &&
(whiptail --yesno "Are you absolutely sure you would like to delete this (${persistent}/joomla) persistent volume? THIS CAN'T BE UNDONE!\n(we need sudo privileges)" \
--title "Delete Persistent Volume" --backtitle "${BACK_TITLE}" 15 112); then
# then remove soft link
sudo rm -rf "${VDM_PROJECT_PATH}/${persistent}/joomla"
fi
# last serious check and then its gone
if [ -d "${VDM_PROJECT_PATH}/${persistent}/db" ] &&
(whiptail --yesno "Are you absolutely sure you would like to delete this (${persistent}/db) persistent volume? THIS CAN'T BE UNDONE!\n(we need sudo privileges)" \
--title "Delete Persistent Volume" --backtitle "${BACK_TITLE}" 15 112); then
# then remove soft link
sudo rm -rf "${VDM_PROJECT_PATH}/${persistent}/db"
fi
done
fi
else
showError "There are no persistent volumes found in ${VDM_PROJECT_PATH}."
fi
}
# make an update # make an update
function runUpdate() { function runUpdate() {
# we need sudo permissions # we need sudo permissions
@ -2562,6 +2624,9 @@ function showJoomla() {
# delete a container # delete a container
hasDirectories 'joomla/available' && hasDirectories 'joomla/available' &&
menu_options+=("delete" "Delete a container") && i=$((i + 1)) menu_options+=("delete" "Delete a container") && i=$((i + 1))
# reset a volume
isExpert && hasDirectories 'joomla/available' &&
menu_options+=("reset" "Reset a volume") && i=$((i + 1))
# Get Joomla env details # Get Joomla env details
isExpert && hasDirectories 'joomla/available' && isExpert && hasDirectories 'joomla/available' &&
menu_options+=("joomla_env" "Open Joomla .env Details") && i=$((i + 1)) menu_options+=("joomla_env" "Open Joomla .env Details") && i=$((i + 1))
@ -2571,7 +2636,7 @@ function showJoomla() {
menu_options+=("quit" "Quit ${PROGRAM_NAME}") menu_options+=("quit" "Quit ${PROGRAM_NAME}")
# get the selection # get the selection
CHOICE=$( CHOICE=$(
whiptail --menu "Make your selection" 20 112 $i \ whiptail --menu "Make your selection" 23 112 $i \
--title "Joomla | ${PROGRAM_NAME} v${_V}" --fb \ --title "Joomla | ${PROGRAM_NAME} v${_V}" --fb \
--backtitle "${BACK_TITLE}" --nocancel --notags \ --backtitle "${BACK_TITLE}" --nocancel --notags \
"${menu_options[@]}" 3>&2 2>&1 1>&3 "${menu_options[@]}" 3>&2 2>&1 1>&3
@ -2603,6 +2668,9 @@ function showJoomla() {
"delete") "delete")
deleteContainer 'joomla' deleteContainer 'joomla'
;; ;;
"reset")
resetContainer 'joomla'
;;
"joomla_env") "joomla_env")
openEnv 'joomla' openEnv 'joomla'
;; ;;
@ -2614,7 +2682,7 @@ function showJoomla() {
# menu loop # menu loop
case $CHOICE in case $CHOICE in
"setup" | "edit" | "enable" | "disable" | "down" | "up" | "fix" | "delete" | "joomla_env" | "bulk") "setup" | "edit" | "enable" | "disable" | "down" | "up" | "fix" | "delete" | "reset" | "joomla_env" | "bulk")
showJoomla showJoomla
;; ;;
esac esac