From 967871529a19630e7f18de35312c40ef2768488d Mon Sep 17 00:00:00 2001 From: MRColor Date: Sat, 5 Nov 2022 12:11:18 +0100 Subject: [PATCH] added stop stack menu voice and function --- runme.ps1 | 36 ++++++++++++++++++++++++++++++------ runme.sh | 18 +++++++++++++++--- 2 files changed, 45 insertions(+), 9 deletions(-) diff --git a/runme.ps1 b/runme.ps1 index 87ece34..fde29a3 100644 --- a/runme.ps1 +++ b/runme.ps1 @@ -331,6 +331,7 @@ function fn_setupEnv { } function fn_startStack { + Clear-Host Write-Output "This menu item will launch all the apps using the configured .env file and the docker-compose.yml file (Docker must be already installed and running)" $yn = Read-Host -prompt "Do you wish to proceed Y/N?" if ($yn -eq 'Y' -or $yn -eq 'y' -or $yn -eq 'Yes' -or $yn -eq 'yes' ) { @@ -346,6 +347,25 @@ function fn_startStack { } } +function fn_stopStack() { + Clear-Host + Write-Output "This menu item will stop all the apps and delete the docker stack previously created using the configured .env file and the docker-compose.yml file." + Write-Output "You don't need to use this command to temporarily pause apps or to update the stack. Use it only in case of uninstallation!" + $yn = Read-Host -prompt "Do you wish to proceed Y/N?" + if ($yn -eq 'Y' -or $yn -eq 'y' -or $yn -eq 'Yes' -or $yn -eq 'yes' ) { + docker compose down + Write-Output "All Apps stopped and stack deleted."; + Read-Host "Now press enter to go back to the menu"; + mainmenu; + } + else { + Write-Output "Docker stack removal canceled."; + Read-Host -prompt "Press Enter to go back to mainmenu"; + mainmenu; ; + } + +} + function fn_resetEnv { Write-Output "Now a fresh env file will be downloaded and will need to be configured to be used again" $yn = Read-Host -prompt "Do you wish to proceed Y/N? " @@ -384,9 +404,10 @@ function mainmenu { Write-Output "2) Install Docker" Write-Output "3) Setup .env file" Write-Output "4) Start apps stack" - Write-Output "5) Reset .env File" - Write-Output "6) Reset docker-compose.yml file" - Write-Output "7) Exit" + Write-Output "5) Stop apps stack" + Write-Output "6) Reset .env File" + Write-Output "7) Reset docker-compose.yml file" + Write-Output "8) Exit" Do { $Select = Read-Host Switch ($Select) { @@ -403,12 +424,15 @@ function mainmenu { fn_startStack } 5 { - fn_resetEnv + fn_stopStack } 6 { - fn_resetDockerCompose + fn_resetEnv } 7 { + fn_resetDockerCompose + } + 8 { fn_bye } DEFAULT { @@ -416,7 +440,7 @@ function mainmenu { } } } - While ($Select -ne 6) + While ($Select -ne 8) } ### Startup ## diff --git a/runme.sh b/runme.sh index 829679e..8724b70 100644 --- a/runme.sh +++ b/runme.sh @@ -289,6 +289,17 @@ fn_startStack(){ esac } +fn_stopStack(){ + yellowprint "This menu item will stop all the apps and delete the docker stack previously created using the configured .env file and the docker-compose.yml file." + yellowprint "You don't need to use this command to temporarily pause apps or to update the stack. Use it only in case of uninstallation!" + read -r -p "Do you wish to proceed Y/N? " yn + case $yn in + [Yy]* ) sudo docker compose down; greenprint "All Apps stopped and stack deleted."; read -r -p "Now press enter to go back to the menu"; mainmenu;; + [Nn]* ) blueprint "Docker stack removal canceled.";read -r -p "Press Enter to go back to mainmenu"; mainmenu;; + * ) printf "Please answer yes or no.";; + esac +} + fn_resetEnv(){ redprint "Now a fresh env file will be downloaded and will need to be configured to be used again" read -r -p "Do you wish to proceed Y/N? " yn @@ -314,7 +325,7 @@ mainmenu() { clear; PS3="Select an option and press Enter " - items=("Show apps' links to register or go to dashboard" "Install Docker" "Setup .env file" "Start apps stack" "Reset .env File" "Reset docker-compose.yml file") + items=("Show apps' links to register or go to dashboard" "Install Docker" "Setup .env file" "Start apps stack" "Stop apps stack" "Reset .env File" "Reset docker-compose.yml file") select item in "${items[@]}" Quit do @@ -323,8 +334,9 @@ mainmenu() { 2) clear; fn_dockerInstall; break;; 3) clear; fn_setupEnv; break;; 4) clear; fn_startStack; break;; - 5) clear; fn_resetEnv; break;; - 6) clear; fn_resetDockerCompose; break;; + 5) clear; fn_stopStack; break;; + 6) clear; fn_resetEnv; break;; + 7) clear; fn_resetDockerCompose; break;; $((${#items[@]}+1))) fn_bye;; *) clear; fn_unknown; break;; esac