From 382b8296be0416fc164cefccd569ca9d363960d9 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 13:30:23 -0600 Subject: [PATCH 001/352] testing self update --- heavy_script.sh | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 1c28a7b8..d1a10de2 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,12 +4,38 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit +self_update() { +SCRIPT=$(readlink -f "$0") +SCRIPTPATH=$(dirname "$SCRIPT") +SCRIPTNAME="$0" +ARGS="$@" +BRANCH="beta" + +cd $SCRIPTPATH +git fetch + +[[ -n $(git diff --name-only origin/$BRANCH | grep $SCRIPTNAME) ]] && { + echo "Found a new version of me, updating myself..." + git pull --force + git checkout $BRANCH + git pull --force + echo "Running the new version..." + exec "$SCRIPTNAME" "$@" + + # Now exit this old instance + exit 1 + } + echo "Already the latest version." +} + +self_update + help(){ [[ $help == "true" ]] && clear -x echo "Basic Utilities" echo "--mount | Initiates mounting feature, choose between unmounting and mounting PVC data" echo "--restore | Opens a menu to restore a \"heavy_script\" backup that was taken on your \"ix-applications\" dataset" -echo "--delete backup | Opens a menu to delete backups on your system" +echo "--delete-backup | Opens a menu to delete backups on your system" echo "--dns | list all of your applications DNS names and their web ports" echo echo "Update Options" @@ -24,14 +50,14 @@ echo "-v | verbose output" echo "-t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" echo "-s | sync catalog" echo "-p | Prune unused/old docker images" -echo +echo echo "Examples" echo "bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vrsUp" echo "bash /mnt/tank/scripts/heavy_script.sh -t 150 --mount" echo "bash /mnt/tank/scripts/heavy_script.sh --dns" -echo "bash /mnt/tank/scripts/heavy_script.sh --restore" +echo "bash /mnt/tank/scripts/heavy_script.sh --restore" echo "bash /mnt/tank/scripts/heavy_script.sh --delete-backup" -echo +echo exit } export -f help @@ -102,8 +128,8 @@ export -f restore dns(){ clear -x echo "Generating DNS Names.." -#ignored dependency pods, No change required -dep_ignore="cron|kube-system|nvidia|svclb|NAME|memcached" +#ignored dependency pods, may need to add more in the future. +dep_ignore="\-cronjob\-|^kube-system|\ssvclb|NAME|\-memcached\-.[^custom\-app]|\-postgresql\-.[^custom\-app]|\-redis\-.[^custom\-app]|\-mariadb\-.[^custom\-app]|\-promtail\-.[^custom\-app]" # Pulling pod names mapfile -t main < <(k3s kubectl get pods -A | grep -Ev "$dep_ignore" | sort) @@ -430,4 +456,4 @@ done [[ "$number_of_backups" -ge 1 ]] && backup [[ "$sync" == "true" ]] && sync [[ "$update_all_apps" == "true" || "$update_apps" == "true" ]] && update_apps -[[ "$prune" == "true" ]] && prune +[[ "$prune" == "true" ]] && prune \ No newline at end of file From bbb6428466ff74dfbcfde3b68756d615e71434ec Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 13:55:49 -0600 Subject: [PATCH 002/352] testing self update --- heavy_script.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index d1a10de2..a9240fd1 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -3,14 +3,14 @@ #If no argument is passed, kill the script. [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit - -self_update() { +ARGS="echo $* | sed s/--self-update//" SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" -ARGS="$@" BRANCH="beta" +self_update() { + cd $SCRIPTPATH git fetch @@ -20,7 +20,7 @@ git fetch git checkout $BRANCH git pull --force echo "Running the new version..." - exec "$SCRIPTNAME" "$@" + exec "$SCRIPTNAME" "$ARGS" # Now exit this old instance exit 1 @@ -28,7 +28,7 @@ git fetch echo "Already the latest version." } -self_update + help(){ [[ $help == "true" ]] && clear -x @@ -371,6 +371,9 @@ do help) help="true" ;; + self-update) + self_update="true" + ;; dns) dns="true" ;; @@ -448,6 +451,7 @@ done [[ "$update_all_apps" == "true" && "$update_apps" == "true" ]] && echo -e "-U and -u cannot BOTH be called" && exit #Continue to call functions in specific order +[[ "$self_update" == "true" ]] && self_update [[ "$help" == "true" ]] && help [[ "$deleteBackup" == "true" ]] && deleteBackup && exit [[ "$dns" == "true" ]] && dns && exit From e4dd02a78429e33af50044c5baf00781e49b480c Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 13:56:26 -0600 Subject: [PATCH 003/352] bash scriptname --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index a9240fd1..813f2910 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -20,7 +20,7 @@ git fetch git checkout $BRANCH git pull --force echo "Running the new version..." - exec "$SCRIPTNAME" "$ARGS" + exec bash "$SCRIPTNAME" "$ARGS" # Now exit this old instance exit 1 From f92adc4c0c31e32c128b9bc49f8aee54bae1a9cd Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 13:59:31 -0600 Subject: [PATCH 004/352] testing --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 813f2910..1168be69 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -28,7 +28,7 @@ git fetch echo "Already the latest version." } - +echo help(){ [[ $help == "true" ]] && clear -x From cc1d9883a5308299f477675665c81211fa1d943a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:05:27 -0600 Subject: [PATCH 005/352] replace string --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 1168be69..ee47c0d3 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -3,7 +3,7 @@ #If no argument is passed, kill the script. [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit -ARGS="echo $* | sed s/--self-update//" +ARGS="$*" ; echo "${ARGS}//--self-update/" SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" From a1dc4fd99ae90b9c772458dd3fb496211de5cc19 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:06:03 -0600 Subject: [PATCH 006/352] pushing just to push --- heavy_script.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/heavy_script.sh b/heavy_script.sh index ee47c0d3..986fdafc 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -9,6 +9,8 @@ SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" BRANCH="beta" + + self_update() { cd $SCRIPTPATH From cad43d63ef13d381d64cec510bdcc47e3e2b06cf Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:07:23 -0600 Subject: [PATCH 007/352] another push --- heavy_script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 986fdafc..3f3cfd98 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -3,7 +3,7 @@ #If no argument is passed, kill the script. [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit -ARGS="$*" ; echo "${ARGS}//--self-update/" +ARGS="$*" ; echo "${ARGS//--self-update/}" SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" @@ -30,7 +30,7 @@ git fetch echo "Already the latest version." } -echo + help(){ [[ $help == "true" ]] && clear -x From 169c5fe8a3c1603181017df0842d1be8e757cb21 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:07:47 -0600 Subject: [PATCH 008/352] another --- heavy_script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 3f3cfd98..8d029bfa 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -10,7 +10,6 @@ SCRIPTNAME="$0" BRANCH="beta" - self_update() { cd $SCRIPTPATH From eceba192fb2bea328bfc7eaab08a23336310ee2f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:08:45 -0600 Subject: [PATCH 009/352] test --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 8d029bfa..6ee5472f 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -3,7 +3,7 @@ #If no argument is passed, kill the script. [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit -ARGS="$*" ; echo "${ARGS//--self-update/}" +ARGS="$*" ; echo "${ARGS//--self-update}" SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" From 94036179d4695e773f11573a3299bd5ef76a45a3 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:09:12 -0600 Subject: [PATCH 010/352] test --- heavy_script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 6ee5472f..cef2b6cd 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -9,7 +9,6 @@ SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" BRANCH="beta" - self_update() { cd $SCRIPTPATH From 06e7ad4b27676e0b0f61b032d64ee614af7101c5 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:10:28 -0600 Subject: [PATCH 011/352] escape hyphens? --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index cef2b6cd..b4398a15 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -3,7 +3,7 @@ #If no argument is passed, kill the script. [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit -ARGS="$*" ; echo "${ARGS//--self-update}" +ARGS="$*" ; echo "${ARGS//\-\-self\-update}" SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" From bb4edf6bf1fe0ecb59b4f55794ca3f5f34e810d3 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:10:54 -0600 Subject: [PATCH 012/352] test --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index b4398a15..610f0392 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -9,6 +9,7 @@ SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" BRANCH="beta" + self_update() { cd $SCRIPTPATH From 151b37947bed1aa98e0dc4c952955476d5ddecf5 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:11:51 -0600 Subject: [PATCH 013/352] remove self update form args --- heavy_script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 610f0392..054e7ebc 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -3,7 +3,7 @@ #If no argument is passed, kill the script. [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit -ARGS="$*" ; echo "${ARGS//\-\-self\-update}" +ARGS="$*" SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" @@ -21,7 +21,7 @@ git fetch git checkout $BRANCH git pull --force echo "Running the new version..." - exec bash "$SCRIPTNAME" "$ARGS" + exec bash "$SCRIPTNAME" "${ARGS//\-\-self\-update}" # Now exit this old instance exit 1 From 69393bab6b08a644da74052d25b42864f907d2ce Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:12:18 -0600 Subject: [PATCH 014/352] only real way to test this unf --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index 054e7ebc..300b9a18 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -3,6 +3,7 @@ #If no argument is passed, kill the script. [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit + ARGS="$*" SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") From d2d5f6f7aebb0d71e57b5801108314df228a1fc0 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:13:17 -0600 Subject: [PATCH 015/352] test --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 300b9a18..ed41f382 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -22,7 +22,7 @@ git fetch git checkout $BRANCH git pull --force echo "Running the new version..." - exec bash "$SCRIPTNAME" "${ARGS//\-\-self\-update}" + bash "$SCRIPTNAME" "${ARGS//\ \-\-self\-update}" # Now exit this old instance exit 1 From ab68827f8ffd975d3eeb01b0b37e555b06c1090e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:13:35 -0600 Subject: [PATCH 016/352] test --- heavy_script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index ed41f382..7456f664 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -10,7 +10,6 @@ SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" BRANCH="beta" - self_update() { cd $SCRIPTPATH From 362974975c299aa28fbb6d53cc4ac31e0608d567 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:14:25 -0600 Subject: [PATCH 017/352] once again --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index 7456f664..ed41f382 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -10,6 +10,7 @@ SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" BRANCH="beta" + self_update() { cd $SCRIPTPATH From 7f44d500b89619c93e1044489d5b449de1885ee4 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:16:12 -0600 Subject: [PATCH 018/352] more testing --- heavy_script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index ed41f382..7456f664 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -10,7 +10,6 @@ SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" BRANCH="beta" - self_update() { cd $SCRIPTPATH From e880da61ed8128b6acb6f2ad0b878c64f7418794 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:17:23 -0600 Subject: [PATCH 019/352] more testing --- heavy_script.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 7456f664..f2724dbb 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -21,7 +21,7 @@ git fetch git checkout $BRANCH git pull --force echo "Running the new version..." - bash "$SCRIPTNAME" "${ARGS//\ \-\-self\-update}" + bash "$SCRIPTNAME" "${ARGS//\ \-\-self\-update\ }" # Now exit this old instance exit 1 @@ -30,7 +30,6 @@ git fetch } - help(){ [[ $help == "true" ]] && clear -x echo "Basic Utilities" From 5f2df0a69e50c836b876c6cc3367ef1a97edd6eb Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:25:37 -0600 Subject: [PATCH 020/352] test --- heavy_script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index f2724dbb..c5d1603d 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,7 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit -ARGS="$*" +ARGS="$@" SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" @@ -21,7 +21,7 @@ git fetch git checkout $BRANCH git pull --force echo "Running the new version..." - bash "$SCRIPTNAME" "${ARGS//\ \-\-self\-update\ }" + exec bash "$SCRIPTNAME" "${ARGS//\ \-\-self\-update\ }" # Now exit this old instance exit 1 From 7e82f95bf24295f893fa10d8316c4291f6439a84 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:26:15 -0600 Subject: [PATCH 021/352] test --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index c5d1603d..0fa18fe7 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,6 +4,7 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit + ARGS="$@" SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") From b50f475743aa009adc80046b3d22b1667834c948 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:26:54 -0600 Subject: [PATCH 022/352] string --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 0fa18fe7..093b3cd3 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -5,7 +5,7 @@ -ARGS="$@" +ARGS="$*" SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" From 3fab72b9d9b6ce265c3001f470e7a7c0266be2b4 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:27:19 -0600 Subject: [PATCH 023/352] test --- heavy_script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 093b3cd3..26f70132 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,6 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit - ARGS="$*" SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") From 9da93da982e2981176ffefeb9e6bcac36ae401a1 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:28:41 -0600 Subject: [PATCH 024/352] test --- heavy_script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 26f70132..779fda63 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,7 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit -ARGS="$*" +ARGS="$@" SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" @@ -21,7 +21,7 @@ git fetch git checkout $BRANCH git pull --force echo "Running the new version..." - exec bash "$SCRIPTNAME" "${ARGS//\ \-\-self\-update\ }" + exec bash "$SCRIPTNAME" "${ARGS//\-\-self\-update}" # Now exit this old instance exit 1 From 8dc864cae74fcdf9dc380a391a16fbee3df8791e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:29:00 -0600 Subject: [PATCH 025/352] test --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index 779fda63..c19eb5d2 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,6 +4,7 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit + ARGS="$@" SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") From f11ef25a43fe773cac26e60ffccb615edbfda158 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:35:45 -0600 Subject: [PATCH 026/352] test --- heavy_script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index c19eb5d2..77c56652 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -5,7 +5,7 @@ -ARGS="$@" +ARGS=( "$@" ) SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" @@ -22,7 +22,7 @@ git fetch git checkout $BRANCH git pull --force echo "Running the new version..." - exec bash "$SCRIPTNAME" "${ARGS//\-\-self\-update}" + exec bash "$SCRIPTNAME" "${ARGS[@]//\-\-self\-update}" # Now exit this old instance exit 1 From 29665ca8cf396ec1dca0e641fbdd6a00e572c4c6 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:37:02 -0600 Subject: [PATCH 027/352] test --- heavy_script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 77c56652..e57950ff 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,6 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit - ARGS=( "$@" ) SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") From 6c1e4a762fefd327d957dc40699093808f0b97fa Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:38:14 -0600 Subject: [PATCH 028/352] test --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index e57950ff..77c56652 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,6 +4,7 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit + ARGS=( "$@" ) SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") From 0a01f4b0c2e8513bb80514261b67b38874f127cf Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:41:15 -0600 Subject: [PATCH 029/352] test --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 77c56652..689bffba 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -22,7 +22,7 @@ git fetch git checkout $BRANCH git pull --force echo "Running the new version..." - exec bash "$SCRIPTNAME" "${ARGS[@]//\-\-self\-update}" + exec bash "$SCRIPTNAME" "${ARGS[@]/\-\-self\-update}" # Now exit this old instance exit 1 From 5f40b315f2be192f48159a46fc90277e000afb1d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:41:32 -0600 Subject: [PATCH 030/352] test --- heavy_script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 689bffba..c62a17fe 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,6 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit - ARGS=( "$@" ) SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") From 70f5388b7de8bb2176a5ca1e303839bb991ddb74 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:43:16 -0600 Subject: [PATCH 031/352] test --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index c62a17fe..72cda34c 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -21,7 +21,7 @@ git fetch git checkout $BRANCH git pull --force echo "Running the new version..." - exec bash "$SCRIPTNAME" "${ARGS[@]/\-\-self\-update}" + exec bash "$SCRIPTNAME" "${ARGS[@]/\ \-\-self\-update\ }" # Now exit this old instance exit 1 From 1713d195288a437549b80b83b67a7b6c5237a68f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:43:42 -0600 Subject: [PATCH 032/352] test --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index 72cda34c..d107139e 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,6 +4,7 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit + ARGS=( "$@" ) SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") From c7f594b63b3aa444c4526a635157d54f811bc66b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:45:11 -0600 Subject: [PATCH 033/352] test --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index d107139e..eede1ab9 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -22,7 +22,7 @@ git fetch git checkout $BRANCH git pull --force echo "Running the new version..." - exec bash "$SCRIPTNAME" "${ARGS[@]/\ \-\-self\-update\ }" + exec bash "$SCRIPTNAME" "${ARGS[@]/[\ ]\-\-self\-update[\ ]}" # Now exit this old instance exit 1 From b6b7f18f14298cb472aa59e82af3fff50194fd33 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:45:29 -0600 Subject: [PATCH 034/352] test --- heavy_script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index eede1ab9..3d8f2766 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,6 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit - ARGS=( "$@" ) SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") From a17d0a0faad9e25894e0e757005263b94f7c2257 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:46:32 -0600 Subject: [PATCH 035/352] test --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 3d8f2766..b31616c8 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -21,7 +21,7 @@ git fetch git checkout $BRANCH git pull --force echo "Running the new version..." - exec bash "$SCRIPTNAME" "${ARGS[@]/[\ ]\-\-self\-update[\ ]}" + exec bash "$SCRIPTNAME" "${ARGS[@]/(\ )\-\-self\-update(\ )}" # Now exit this old instance exit 1 From 8e2d77323ebcb0db9e328dd32561088fa9ee0c9a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:46:45 -0600 Subject: [PATCH 036/352] test --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index b31616c8..069d89d6 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,6 +4,7 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit + ARGS=( "$@" ) SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") From 8c0cb93fe0b6631f1dfc3d63a42ae55bca7557fb Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:51:40 -0600 Subject: [PATCH 037/352] test --- heavy_script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 069d89d6..800c1747 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -5,7 +5,7 @@ -ARGS=( "$@" ) +ARGS=( "$@" ) SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" @@ -22,7 +22,7 @@ git fetch git checkout $BRANCH git pull --force echo "Running the new version..." - exec bash "$SCRIPTNAME" "${ARGS[@]/(\ )\-\-self\-update(\ )}" + exec bash "$SCRIPTNAME" "${ARGS[@]/\s?\-\-self\-update\s?}" # Now exit this old instance exit 1 From d39634b39f9e2033491bcf93b5691d1b65d94fdd Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:52:03 -0600 Subject: [PATCH 038/352] test --- heavy_script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 800c1747..be75bac5 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,6 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit - ARGS=( "$@" ) SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") From 4c9ee5de13de19e30f2c7dcee0390fb0f31ce73f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:53:01 -0600 Subject: [PATCH 039/352] sed --- heavy_script.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index be75bac5..d7abe91e 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,8 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit -ARGS=( "$@" ) + +ARGS="$@" ; echo "$ARGS" | sed -e 's/\s?\-\-self\-update\s?//' SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" @@ -21,7 +22,7 @@ git fetch git checkout $BRANCH git pull --force echo "Running the new version..." - exec bash "$SCRIPTNAME" "${ARGS[@]/\s?\-\-self\-update\s?}" + exec bash "$SCRIPTNAME" "${ARGS[@]}" # Now exit this old instance exit 1 From 8c1db858b8a8bdfa5c0ae8967eeede676b191319 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:53:20 -0600 Subject: [PATCH 040/352] test --- heavy_script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index d7abe91e..62db01d7 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,6 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit - ARGS="$@" ; echo "$ARGS" | sed -e 's/\s?\-\-self\-update\s?//' SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") From 8ac7b496d9d53d7789e68df0aa55c60f97569f9d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 14:59:37 -0600 Subject: [PATCH 041/352] regex --- heavy_script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 62db01d7..d7ce4cce 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,7 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit -ARGS="$@" ; echo "$ARGS" | sed -e 's/\s?\-\-self\-update\s?//' +ARGS="$@" ; echo "$ARGS" | sed -e 's/[:space:]\?\-\-self\-update[:space:]\?//' SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" @@ -21,7 +21,7 @@ git fetch git checkout $BRANCH git pull --force echo "Running the new version..." - exec bash "$SCRIPTNAME" "${ARGS[@]}" + exec bash "$SCRIPTNAME" ${ARGS[@]} # Now exit this old instance exit 1 From 1845d3c9c028f06dd971e6ed483b50cfdd271cd7 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:00:09 -0600 Subject: [PATCH 042/352] test --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index d7ce4cce..3daae58d 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,6 +4,7 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit + ARGS="$@" ; echo "$ARGS" | sed -e 's/[:space:]\?\-\-self\-update[:space:]\?//' SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") From 48d71ffc2e4d3ab17b33d4be10c83100178c8adc Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:00:51 -0600 Subject: [PATCH 043/352] fix space --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 3daae58d..b148a01d 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -5,7 +5,7 @@ -ARGS="$@" ; echo "$ARGS" | sed -e 's/[:space:]\?\-\-self\-update[:space:]\?//' +ARGS="$@" ; echo "$ARGS" | sed -e 's/[[:space:]]\?\-\-self\-update[[:space:]]\?//' SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" From af6d65d0d50da00e4f53e9b64261ee08668191bc Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:01:51 -0600 Subject: [PATCH 044/352] reg --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index b148a01d..a5a708ef 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -5,7 +5,7 @@ -ARGS="$@" ; echo "$ARGS" | sed -e 's/[[:space:]]\?\-\-self\-update[[:space:]]\?//' +ARGS="$@" ; echo "$ARGS" | sed -e 's/[[:space:]]\?--self-update[[:space:]]\?//' SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" From a17ba00666285229245500b1c838b5ac7315b7bb Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:02:25 -0600 Subject: [PATCH 045/352] test --- heavy_script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index a5a708ef..a440bec7 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,6 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit - ARGS="$@" ; echo "$ARGS" | sed -e 's/[[:space:]]\?--self-update[[:space:]]\?//' SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") From d111b214139bcd821c3d7cee60ea030957f99935 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:03:10 -0600 Subject: [PATCH 046/352] reg --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index a440bec7..28931d09 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,7 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit -ARGS="$@" ; echo "$ARGS" | sed -e 's/[[:space:]]\?--self-update[[:space:]]\?//' +ARGS="$@" ; echo "$ARGS" | sed -e 's/[[:space:]]?--self-update[[:space:]]?//' SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" From 05906fee686cf2244fc533d6b700c12b9aff9e1c Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:03:28 -0600 Subject: [PATCH 047/352] test --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index 28931d09..2f3623fa 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,6 +4,7 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit + ARGS="$@" ; echo "$ARGS" | sed -e 's/[[:space:]]?--self-update[[:space:]]?//' SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") From a0f83bc66a9129417f427b216f5d388295df552f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:05:31 -0600 Subject: [PATCH 048/352] :L --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 2f3623fa..3431c131 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -5,7 +5,7 @@ -ARGS="$@" ; echo "$ARGS" | sed -e 's/[[:space:]]?--self-update[[:space:]]?//' +ARGS="$@" ; echo "$ARGS" | sed -E 's/[[:space:]]?--self-update[[:space:]]?//g' SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" From fec89db940a98d0576128d80c8d4cdd500673b67 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:05:59 -0600 Subject: [PATCH 049/352] test --- heavy_script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 3431c131..e0211266 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,6 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit - ARGS="$@" ; echo "$ARGS" | sed -E 's/[[:space:]]?--self-update[[:space:]]?//g' SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") From f289cdf76b3d51f0e4da3b6911cc3f8a21f9d7ee Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:07:28 -0600 Subject: [PATCH 050/352] test --- heavy_script.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index e0211266..62d8373b 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,8 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit -ARGS="$@" ; echo "$ARGS" | sed -E 's/[[:space:]]?--self-update[[:space:]]?//g' +ARGS=( echo "$@" | sed -E 's/[[:space:]]?--self-update[[:space:]]?//g') + SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" From 8030dbf2b5de0f3404fc9fa4686271982f24778d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:08:30 -0600 Subject: [PATCH 051/352] fix --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 62d8373b..6eb77eb7 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,7 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit -ARGS=( echo "$@" | sed -E 's/[[:space:]]?--self-update[[:space:]]?//g') +ARGS=$(echo "$@" | sed -E 's/[[:space:]]?--self-update[[:space:]]?//g') SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") From 3bd1013b3d03166d2bebb5f965d29a50bb6ed087 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:10:05 -0600 Subject: [PATCH 052/352] non array --- heavy_script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 6eb77eb7..edbca1b6 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,7 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit -ARGS=$(echo "$@" | sed -E 's/[[:space:]]?--self-update[[:space:]]?//g') +ARGS=$(echo "$*" | sed -E 's/[[:space:]]?--self-update[[:space:]]?//g') SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") @@ -22,7 +22,7 @@ git fetch git checkout $BRANCH git pull --force echo "Running the new version..." - exec bash "$SCRIPTNAME" ${ARGS[@]} + exec bash "$SCRIPTNAME" "$ARGS" # Now exit this old instance exit 1 From 83b1e286e800ff82212e5dd0cd2ba7f7eb7f4925 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:10:24 -0600 Subject: [PATCH 053/352] test --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index edbca1b6..8825fcca 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,6 +4,7 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit + ARGS=$(echo "$*" | sed -E 's/[[:space:]]?--self-update[[:space:]]?//g') SCRIPT=$(readlink -f "$0") From 4c8cc6bb2c1070c9f5e74a1f853a99d42624a60f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:10:57 -0600 Subject: [PATCH 054/352] test --- heavy_script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 8825fcca..edbca1b6 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,6 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit - ARGS=$(echo "$*" | sed -E 's/[[:space:]]?--self-update[[:space:]]?//g') SCRIPT=$(readlink -f "$0") From 2ad456b905169bf57291868481f167042b9ff00e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:13:46 -0600 Subject: [PATCH 055/352] test --- heavy_script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index edbca1b6..89022099 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,7 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit -ARGS=$(echo "$*" | sed -E 's/[[:space:]]?--self-update[[:space:]]?//g') +ARGS=$( "$@" ) SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") @@ -22,7 +22,7 @@ git fetch git checkout $BRANCH git pull --force echo "Running the new version..." - exec bash "$SCRIPTNAME" "$ARGS" + exec bash "$SCRIPTNAME" "${ARGS[@]/[[:space:]]?--self-update[[:space:]]?}" # Now exit this old instance exit 1 From 41f49eb4ff587633c64178e74fdd9345f06e7752 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:14:05 -0600 Subject: [PATCH 056/352] test --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index 89022099..221eb93d 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,6 +4,7 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit + ARGS=$( "$@" ) SCRIPT=$(readlink -f "$0") From 113fc93d913e671668bd35f5dd338c8a1d5d16d9 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:16:40 -0600 Subject: [PATCH 057/352] test --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 221eb93d..afa51e61 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -23,7 +23,7 @@ git fetch git checkout $BRANCH git pull --force echo "Running the new version..." - exec bash "$SCRIPTNAME" "${ARGS[@]/[[:space:]]?--self-update[[:space:]]?}" + exec bash "$SCRIPTNAME" "${ARGS[@]//[[:space:]]?--self-update[[:space:]]?}" # Now exit this old instance exit 1 From e4c54be187a64b0b70f1176f09a7e3d68706e242 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:16:56 -0600 Subject: [PATCH 058/352] test --- heavy_script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index afa51e61..f5792fc7 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,6 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit - ARGS=$( "$@" ) SCRIPT=$(readlink -f "$0") From 7b07ea3a33278ede33498a1b4aa363761ddb3a45 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:22:53 -0600 Subject: [PATCH 059/352] for --- heavy_script.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index f5792fc7..774b0ce7 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -22,7 +22,13 @@ git fetch git checkout $BRANCH git pull --force echo "Running the new version..." - exec bash "$SCRIPTNAME" "${ARGS[@]//[[:space:]]?--self-update[[:space:]]?}" + count=0 + for i in ${ARGS[@]} + do + [[ "$i" == "//[[:space:]]?--self-update[[:space:]]?" ]] && unset "${ARGS[$count]}" + ((count++)) + done + exec bash "$SCRIPTNAME" "${ARGS[@]}" # Now exit this old instance exit 1 From de661f0ef0c7d9d54af28fc756ebaac647d2eb11 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:23:11 -0600 Subject: [PATCH 060/352] test --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index 774b0ce7..c43390ca 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,6 +4,7 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit + ARGS=$( "$@" ) SCRIPT=$(readlink -f "$0") From 1a46cb1ffd8d88ef58543f4250f091c827764507 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:28:47 -0600 Subject: [PATCH 061/352] test --- heavy_script.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index c43390ca..ab9b8eb6 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -5,7 +5,8 @@ -ARGS=$( "$@" ) +ARGS=("$@") + SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") From 2e8a4dbdaa14166187b6a34456a0334ec75a30a0 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:29:16 -0600 Subject: [PATCH 062/352] test --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index ab9b8eb6..ca77e300 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -8,6 +8,7 @@ ARGS=("$@") + SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" From 338499585bf730f8c0b359db9cf457d043f2b639 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:30:19 -0600 Subject: [PATCH 063/352] test --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index ca77e300..02799f99 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -28,7 +28,7 @@ git fetch count=0 for i in ${ARGS[@]} do - [[ "$i" == "//[[:space:]]?--self-update[[:space:]]?" ]] && unset "${ARGS[$count]}" + [[ "$i" == "--self-update" ]] && unset "${ARGS[$count]}" ((count++)) done exec bash "$SCRIPTNAME" "${ARGS[@]}" From 64d3371c21148cff4882aace0aea35a0cb975ff9 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:30:39 -0600 Subject: [PATCH 064/352] test --- heavy_script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 02799f99..409f2dbf 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -8,7 +8,6 @@ ARGS=("$@") - SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" From 2309076a709d25b35b71da1f04a168521312f264 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:34:07 -0600 Subject: [PATCH 065/352] syntax --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 409f2dbf..5de1f109 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -27,7 +27,7 @@ git fetch count=0 for i in ${ARGS[@]} do - [[ "$i" == "--self-update" ]] && unset "${ARGS[$count]}" + [[ "$i" == "--self-update" ]] && unset "ARGS[$count]" ((count++)) done exec bash "$SCRIPTNAME" "${ARGS[@]}" From 54a96475fc6428020670f0c6003306bcf5684b74 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:34:33 -0600 Subject: [PATCH 066/352] test --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index 5de1f109..82590268 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -8,6 +8,7 @@ ARGS=("$@") + SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" From 749c033a68d3222fa2d82ff902584d77feb614a1 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:35:50 -0600 Subject: [PATCH 067/352] ooooo --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 82590268..ef62901a 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -28,7 +28,7 @@ git fetch count=0 for i in ${ARGS[@]} do - [[ "$i" == "--self-update" ]] && unset "ARGS[$count]" + [[ "$i" == "--self-update" ]] && unset "ARGS[$count]" && break ((count++)) done exec bash "$SCRIPTNAME" "${ARGS[@]}" From b99cb44b7ab420e32ba7d6ee2bf05233231b4796 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:40:09 -0600 Subject: [PATCH 068/352] lowercase --- heavy_script.sh | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index ef62901a..dcff7967 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -5,17 +5,13 @@ -ARGS=("$@") - - +args=("$@") +self_update() { SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" BRANCH="beta" - -self_update() { - cd $SCRIPTPATH git fetch @@ -26,12 +22,12 @@ git fetch git pull --force echo "Running the new version..." count=0 - for i in ${ARGS[@]} + for i in "${args[@]}" do - [[ "$i" == "--self-update" ]] && unset "ARGS[$count]" && break + [[ "$i" == "--self-update" ]] && unset "args[$count]" && break ((count++)) done - exec bash "$SCRIPTNAME" "${ARGS[@]}" + exec bash "$SCRIPTNAME" "${args[@]}" # Now exit this old instance exit 1 From 5f028225ccba2a5408ad87dbb33f148f1160e58d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:41:16 -0600 Subject: [PATCH 069/352] almost done --- heavy_script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index dcff7967..54361cdb 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,6 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit - args=("$@") self_update() { From 01fc4f6c9101a210eac4432baf32740d46f92f1f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:42:24 -0600 Subject: [PATCH 070/352] test --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index 54361cdb..dcff7967 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,6 +4,7 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit + args=("$@") self_update() { From 6658586651e514929dc9de67d5bea0cd699bd4a4 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:45:22 -0600 Subject: [PATCH 071/352] delete branch --- heavy_script.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index dcff7967..3ebd69e2 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -11,15 +11,12 @@ self_update() { SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" -BRANCH="beta" cd $SCRIPTPATH git fetch [[ -n $(git diff --name-only origin/$BRANCH | grep $SCRIPTNAME) ]] && { echo "Found a new version of me, updating myself..." git pull --force - git checkout $BRANCH - git pull --force echo "Running the new version..." count=0 for i in "${args[@]}" From bf5f1a0dc212cf42529d9d4c60192dca080af36d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:50:20 -0600 Subject: [PATCH 072/352] test --- heavy_script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 3ebd69e2..575bc6c3 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -14,9 +14,9 @@ SCRIPTNAME="$0" cd $SCRIPTPATH git fetch -[[ -n $(git diff --name-only origin/$BRANCH | grep $SCRIPTNAME) ]] && { +[[ -n $(git diff --name-only origin/beta | grep $SCRIPTNAME) ]] && { echo "Found a new version of me, updating myself..." - git pull --force + git pull --force &> /dev/null echo "Running the new version..." count=0 for i in "${args[@]}" From 546cb6892f42199b52ebc2963e7defe1cb99027b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:52:22 -0600 Subject: [PATCH 073/352] test --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 575bc6c3..7c2ed973 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -12,7 +12,7 @@ SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") SCRIPTNAME="$0" cd $SCRIPTPATH -git fetch +git fetch &> /dev/null [[ -n $(git diff --name-only origin/beta | grep $SCRIPTNAME) ]] && { echo "Found a new version of me, updating myself..." From 083269cdffe933fb38809c56ecf143e5e406ee2e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:55:14 -0600 Subject: [PATCH 074/352] test --- heavy_script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 7c2ed973..90d45d44 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,6 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit - args=("$@") self_update() { From 7f99e9e46e1779ccd3bcf0cc9de35fbb20025cef Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:56:01 -0600 Subject: [PATCH 075/352] formatting --- heavy_script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 90d45d44..d1e26776 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -16,7 +16,7 @@ git fetch &> /dev/null [[ -n $(git diff --name-only origin/beta | grep $SCRIPTNAME) ]] && { echo "Found a new version of me, updating myself..." git pull --force &> /dev/null - echo "Running the new version..." + echo -e "Running the new version...\n" count=0 for i in "${args[@]}" do @@ -28,7 +28,7 @@ git fetch &> /dev/null # Now exit this old instance exit 1 } - echo "Already the latest version." + echo -e "Already the latest version.\n" } From 799629013b7bc90ce859e4c39541638b1838cc82 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:56:50 -0600 Subject: [PATCH 076/352] test --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index d1e26776..8efd5417 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -23,7 +23,7 @@ git fetch &> /dev/null [[ "$i" == "--self-update" ]] && unset "args[$count]" && break ((count++)) done - exec bash "$SCRIPTNAME" "${args[@]}" + bash "$SCRIPTNAME" "${args[@]}" # Now exit this old instance exit 1 From 455ab485393d2f937c44af120b6936b8210083bc Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:57:13 -0600 Subject: [PATCH 077/352] test --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index 8efd5417..5b0dd8b6 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,6 +4,7 @@ [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit + args=("$@") self_update() { From 2c7cf84674bc78600af59a9780fbc61c4d235649 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:57:42 -0600 Subject: [PATCH 078/352] test --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 5b0dd8b6..22bf5103 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -3,7 +3,7 @@ #If no argument is passed, kill the script. [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit - +echo "yep" args=("$@") From 97b0236def42b41be9ca1ce915d213b877cdb251 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:58:32 -0600 Subject: [PATCH 079/352] test --- heavy_script.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 22bf5103..2462458d 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -3,7 +3,6 @@ #If no argument is passed, kill the script. [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit -echo "yep" args=("$@") @@ -15,7 +14,7 @@ cd $SCRIPTPATH git fetch &> /dev/null [[ -n $(git diff --name-only origin/beta | grep $SCRIPTNAME) ]] && { - echo "Found a new version of me, updating myself..." + echo "Found a new version of HeavyScript, updating myself..." git pull --force &> /dev/null echo -e "Running the new version...\n" count=0 From 27516ff497c6b78dc8912f221b3b46ae1a66a22a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:59:08 -0600 Subject: [PATCH 080/352] sleep --- heavy_script.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 2462458d..9b1c290e 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -23,7 +23,8 @@ git fetch &> /dev/null [[ "$i" == "--self-update" ]] && unset "args[$count]" && break ((count++)) done - bash "$SCRIPTNAME" "${args[@]}" + sleep 5 + exec bash "$SCRIPTNAME" "${args[@]}" # Now exit this old instance exit 1 From 993475135b9394b2fb104a551e4198b768240c73 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 13 Jun 2022 15:59:42 -0600 Subject: [PATCH 081/352] test --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index 9b1c290e..176a0582 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -3,6 +3,7 @@ #If no argument is passed, kill the script. [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit +echo "yep" args=("$@") From ec6e0884ef1ce5067895a25385975b37cca55ae8 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 20 Jul 2022 05:52:34 -0600 Subject: [PATCH 082/352] testing new self update --- heavy_script.sh | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 176a0582..f52fb90e 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -3,8 +3,6 @@ #If no argument is passed, kill the script. [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit -echo "yep" - args=("$@") self_update() { @@ -14,23 +12,27 @@ SCRIPTNAME="$0" cd $SCRIPTPATH git fetch &> /dev/null -[[ -n $(git diff --name-only origin/beta | grep $SCRIPTNAME) ]] && { +if [[ -n $(git diff --name-only origin/main | grep $SCRIPTNAME) ]]; then echo "Found a new version of HeavyScript, updating myself..." - git pull --force &> /dev/null + git reset --hard -q + git pull --force -q echo -e "Running the new version...\n" count=0 for i in "${args[@]}" do - [[ "$i" == "--self-update" ]] && unset "args[$count]" && break - ((count++)) + [[ "$i" == "--self-update" ]] && unset "args[$count]" && args+=("--updated") && break + ((count++)) done sleep 5 exec bash "$SCRIPTNAME" "${args[@]}" # Now exit this old instance - exit 1 - } - echo -e "Already the latest version.\n" + exit +elif [[ $self_update == "true" ]]; then + echo -e "HeavyScript has been updated\n" +else + echo -e "HeavyScript is already the latest version\n" +fi } @@ -59,7 +61,7 @@ echo "Examples" echo "bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vrsUp" echo "bash /mnt/tank/scripts/heavy_script.sh -t 150 --mount" echo "bash /mnt/tank/scripts/heavy_script.sh --dns" -echo "bash /mnt/tank/scripts/heavy_script.sh --restore" +echo "bash heavy_script.sh --restore" echo "bash /mnt/tank/scripts/heavy_script.sh --delete-backup" echo exit @@ -218,7 +220,7 @@ export -f sync update_apps(){ -mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep -E ",true(,|$)" | sort) +mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep -E ",true(,|\b)" | sort) [[ -z $array ]] && echo -e "\nThere are no updates available" && return 0 || echo -e "\n${#array[@]} update(s) available" [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" @@ -269,7 +271,7 @@ do else #user must not be using -S, just update echo -e "\n$app_name" [[ "$verbose" == "true" ]] && echo "Updating.." - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || { echo "FAILED"; continue; } + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "FAILED" fi else echo -e "\n$app_name\nMajor Release, update manually" @@ -372,10 +374,10 @@ do case $opt in -) case "${OPTARG}" in - help) + help) help="true" ;; - self-update) + self-update) self_update="true" ;; dns) @@ -390,6 +392,9 @@ do delete-backup) deleteBackup="true" ;; + updated) + self_update="true" + ;; *) echo -e "Invalid Option \"--$OPTARG\"\n" && help exit @@ -455,8 +460,8 @@ done [[ "$update_all_apps" == "true" && "$update_apps" == "true" ]] && echo -e "-U and -u cannot BOTH be called" && exit #Continue to call functions in specific order -[[ "$self_update" == "true" ]] && self_update [[ "$help" == "true" ]] && help +[[ "$self_update" == "true" ]] && self_update [[ "$deleteBackup" == "true" ]] && deleteBackup && exit [[ "$dns" == "true" ]] && dns && exit [[ "$restore" == "true" ]] && restore && exit @@ -464,4 +469,4 @@ done [[ "$number_of_backups" -ge 1 ]] && backup [[ "$sync" == "true" ]] && sync [[ "$update_all_apps" == "true" || "$update_apps" == "true" ]] && update_apps -[[ "$prune" == "true" ]] && prune \ No newline at end of file +[[ "$prune" == "true" ]] && prune From cf004dd928faa0f627fc23b2d84e5889e31e52a3 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 20 Jul 2022 05:54:30 -0600 Subject: [PATCH 083/352] beta --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index f52fb90e..f04acab5 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -12,7 +12,7 @@ SCRIPTNAME="$0" cd $SCRIPTPATH git fetch &> /dev/null -if [[ -n $(git diff --name-only origin/main | grep $SCRIPTNAME) ]]; then +if [[ -n $(git diff --name-only origin/beta | grep $SCRIPTNAME) ]]; then echo "Found a new version of HeavyScript, updating myself..." git reset --hard -q git pull --force -q From 0237617ba2bf9e31ef7ab9296e767e62a1496647 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 20 Jul 2022 05:56:59 -0600 Subject: [PATCH 084/352] var name --- heavy_script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index f04acab5..042d0d0c 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -28,7 +28,7 @@ if [[ -n $(git diff --name-only origin/beta | grep $SCRIPTNAME) ]]; then # Now exit this old instance exit -elif [[ $self_update == "true" ]]; then +elif [[ $self_updated == "true" ]]; then echo -e "HeavyScript has been updated\n" else echo -e "HeavyScript is already the latest version\n" @@ -393,7 +393,7 @@ do deleteBackup="true" ;; updated) - self_update="true" + self_updated="true" ;; *) echo -e "Invalid Option \"--$OPTARG\"\n" && help From 8d410dfb2e48390a76f11dd37220c7e497c7508b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 20 Jul 2022 05:59:54 -0600 Subject: [PATCH 085/352] null change --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index 042d0d0c..078b570c 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -36,6 +36,7 @@ fi } + help(){ [[ $help == "true" ]] && clear -x echo "Basic Utilities" From 9468664baec6684b231d5bc25808bd1023afac52 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 20 Jul 2022 06:04:16 -0600 Subject: [PATCH 086/352] test --- heavy_script.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 078b570c..6baba984 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -28,8 +28,6 @@ if [[ -n $(git diff --name-only origin/beta | grep $SCRIPTNAME) ]]; then # Now exit this old instance exit -elif [[ $self_updated == "true" ]]; then - echo -e "HeavyScript has been updated\n" else echo -e "HeavyScript is already the latest version\n" fi @@ -462,6 +460,7 @@ done #Continue to call functions in specific order [[ "$help" == "true" ]] && help +[[ $self_updated == "true" ]] && echo -e "HeavyScript has been updated\n" [[ "$self_update" == "true" ]] && self_update [[ "$deleteBackup" == "true" ]] && deleteBackup && exit [[ "$dns" == "true" ]] && dns && exit From 1af355a8f6fa112210f576cc736c4b235291eac3 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 24 Jul 2022 19:15:56 -0600 Subject: [PATCH 087/352] bring in changes from stable --- heavy_script.sh | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 176a0582..8f38bfad 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -3,34 +3,34 @@ #If no argument is passed, kill the script. [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit -echo "yep" - args=("$@") self_update() { -SCRIPT=$(readlink -f "$0") -SCRIPTPATH=$(dirname "$SCRIPT") -SCRIPTNAME="$0" -cd $SCRIPTPATH +script=$(readlink -f "$0") +script_path=$(dirname "$script") +script_name="heavy_script.sh" +cd "$script_path" || exit git fetch &> /dev/null -[[ -n $(git diff --name-only origin/beta | grep $SCRIPTNAME) ]] && { +if git diff --name-only origin/main | grep -q "$script_name" ; then echo "Found a new version of HeavyScript, updating myself..." - git pull --force &> /dev/null + git reset --hard -q + git pull --force -q echo -e "Running the new version...\n" count=0 for i in "${args[@]}" do - [[ "$i" == "--self-update" ]] && unset "args[$count]" && break - ((count++)) + [[ "$i" == "--self-update" ]] && unset "args[$count]" && break + ((count++)) done sleep 5 - exec bash "$SCRIPTNAME" "${args[@]}" + exec bash "$script_name" "${args[@]}" # Now exit this old instance - exit 1 - } - echo -e "Already the latest version.\n" + exit +else + echo -e "HeavyScript is already the latest version\n" +fi } @@ -59,7 +59,7 @@ echo "Examples" echo "bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vrsUp" echo "bash /mnt/tank/scripts/heavy_script.sh -t 150 --mount" echo "bash /mnt/tank/scripts/heavy_script.sh --dns" -echo "bash /mnt/tank/scripts/heavy_script.sh --restore" +echo "bash heavy_script.sh --restore" echo "bash /mnt/tank/scripts/heavy_script.sh --delete-backup" echo exit @@ -218,7 +218,9 @@ export -f sync update_apps(){ -mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep -E ",true(,|$)" | sort) +# Replace with line below after testing +# cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | tr -d " \t\r" | grep -E ",true($|,)" | sort +mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep -E ",true(,|\b)" | sort) [[ -z $array ]] && echo -e "\nThere are no updates available" && return 0 || echo -e "\n${#array[@]} update(s) available" [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" @@ -269,7 +271,7 @@ do else #user must not be using -S, just update echo -e "\n$app_name" [[ "$verbose" == "true" ]] && echo "Updating.." - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || { echo "FAILED"; continue; } + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "FAILED" fi else echo -e "\n$app_name\nMajor Release, update manually" @@ -372,10 +374,10 @@ do case $opt in -) case "${OPTARG}" in - help) + help) help="true" ;; - self-update) + self-update) self_update="true" ;; dns) @@ -455,8 +457,8 @@ done [[ "$update_all_apps" == "true" && "$update_apps" == "true" ]] && echo -e "-U and -u cannot BOTH be called" && exit #Continue to call functions in specific order -[[ "$self_update" == "true" ]] && self_update [[ "$help" == "true" ]] && help +[[ "$self_update" == "true" ]] && self_update [[ "$deleteBackup" == "true" ]] && deleteBackup && exit [[ "$dns" == "true" ]] && dns && exit [[ "$restore" == "true" ]] && restore && exit From 8c762f436b8f3b0ea74cd3ca0e9d529931112ec0 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 24 Jul 2022 19:22:10 -0600 Subject: [PATCH 088/352] update to stable --- heavy_script.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 41a001f4..8f38bfad 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -34,7 +34,6 @@ fi } - help(){ [[ $help == "true" ]] && clear -x echo "Basic Utilities" @@ -393,9 +392,6 @@ do delete-backup) deleteBackup="true" ;; - updated) - self_updated="true" - ;; *) echo -e "Invalid Option \"--$OPTARG\"\n" && help exit @@ -470,4 +466,4 @@ done [[ "$number_of_backups" -ge 1 ]] && backup [[ "$sync" == "true" ]] && sync [[ "$update_all_apps" == "true" || "$update_apps" == "true" ]] && update_apps -[[ "$prune" == "true" ]] && prune +[[ "$prune" == "true" ]] && prune \ No newline at end of file From 34de2750d8b7a7149911d96ab97f634b9a389cd8 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 24 Jul 2022 20:29:58 -0600 Subject: [PATCH 089/352] refactor --- functions/backup.sh | 74 ++++++++ functions/dns.sh | 27 +++ functions/misc.sh | 57 ++++++ functions/mount.sh | 63 +++++++ functions/self_update.sh | 32 ++++ functions/update_apps.sh | 132 ++++++++++++++ heavy_script.sh | 374 ++------------------------------------- 7 files changed, 397 insertions(+), 362 deletions(-) create mode 100644 functions/backup.sh create mode 100644 functions/dns.sh create mode 100644 functions/misc.sh create mode 100644 functions/mount.sh create mode 100644 functions/self_update.sh create mode 100644 functions/update_apps.sh diff --git a/functions/backup.sh b/functions/backup.sh new file mode 100644 index 00000000..a4684ca1 --- /dev/null +++ b/functions/backup.sh @@ -0,0 +1,74 @@ +#!/bin/bash + + +backup(){ +echo -e "\nNumber of backups was set to $number_of_backups" +date=$(date '+%Y_%m_%d_%H_%M_%S') +[[ "$verbose" == "true" ]] && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' +[[ -z "$verbose" ]] && echo -e "\nNew Backup Name:" && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' | tail -n 1 +mapfile -t list_backups < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r") +if [[ ${#list_backups[@]} -gt "number_of_backups" ]]; then + echo -e "\nDeleting the oldest backup(s) for exceeding limit:" + overflow=$(( ${#list_backups[@]} - "$number_of_backups" )) + mapfile -t list_overflow < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -V -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r" | head -n "$overflow") + for i in "${list_overflow[@]}" + do + cli -c 'app kubernetes delete_backup backup_name=''"'"$i"'"' &> /dev/null || echo "Failed to delete $i" + echo "$i" + done +fi +} +export -f backup + + + +deleteBackup(){ +clear -x && echo "pulling all restore points.." +list_backups=$(cli -c 'app kubernetes list_backups' | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t) +clear -x +[[ -z "$list_backups" ]] && echo "No restore points available" && exit +title +echo -e "Choose a restore point to delete\nThese may be out of order if they are not all HeavyScript backups" +echo "$list_backups" +read -pr -t 600 "Please type a number: " selection +restore_point=$(echo "$list_backups" | grep ^"$selection " | awk '{print $2}') +if [[ -z "$selection" ]]; then #Check for valid selection. If none, kill script + echo "Your selection cannot be empty" + exit +elif [[ -z "$restore_point" ]]; then #Check for valid selection. If none, kill script + echo "Invalid Selection: $selection, was not an option" + exit +fi +echo -e "\nWARNING:\nYou CANNOT go back after deleting your restore point" +echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" && echo -e "1 Yes\n2 No" +read -rp -t 120 "Please type a number: " yesno || { echo "Failed to make a valid selection"; exit; } +if [[ $yesno == "1" ]]; then + echo -e "\nDeleting $restore_point" && cli -c 'app kubernetes delete_backup backup_name=''"'"$restore_point"'"' &>/dev/null && echo "Sucessfully deleted" || echo "Deletion Failed" +elif [[ $yesno == "2" ]]; then + echo "You've chosen NO, killing script." +else + echo "Invalid Selection" +fi +} +export -f deleteBackup + + +restore(){ +clear -x && echo "pulling restore points.." +list_backups=$(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t) +clear -x +[[ -z "$list_backups" ]] && echo "No HeavyScript restore points available" && exit || { title; echo "Choose a restore point" ; } +echo "$list_backups" && read -t 600 -p "Please type a number: " selection && restore_point=$(echo "$list_backups" | grep ^"$selection " | awk '{print $2}') +[[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script +[[ -z "$restore_point" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script +echo -e "\nWARNING:\nThis is NOT guranteed to work\nThis is ONLY supposed to be used as a LAST RESORT\nConsider rolling back your applications instead if possible" || { echo "FAILED"; exit; } +echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" && echo -e "1 Yes\n2 No" && read -t 120 -p "Please type a number: " yesno || { echo "FAILED"; exit; } +if [[ $yesno == "1" ]]; then + echo -e "\nStarting Backup, this will take a LONG time." && cli -c 'app kubernetes restore_backup backup_name=''"'"$restore_point"'"' || echo "Restore FAILED" +elif [[ $yesno == "2" ]]; then + echo "You've chosen NO, killing script. Good luck." +else + echo "Invalid Selection" +fi +} +export -f restore \ No newline at end of file diff --git a/functions/dns.sh b/functions/dns.sh new file mode 100644 index 00000000..c4316139 --- /dev/null +++ b/functions/dns.sh @@ -0,0 +1,27 @@ +#!/bin/bash + + +dns(){ +clear -x +echo "Generating DNS Names.." +#ignored dependency pods, may need to add more in the future. +dep_ignore="\-cronjob\-|^kube-system|\ssvclb|NAME|\-memcached\-.[^custom\-app]|\-postgresql\-.[^custom\-app]|\-redis\-.[^custom\-app]|\-mariadb\-.[^custom\-app]|\-promtail\-.[^custom\-app]" + +# Pulling pod names +mapfile -t main < <(k3s kubectl get pods -A | grep -Ev "$dep_ignore" | sort) + +# Pulling all ports +all_ports=$(k3s kubectl get service -A) + +clear -x +count=0 +for i in "${main[@]}" +do + [[ count -le 0 ]] && echo -e "\n" && ((count++)) + appName=$(echo "$i" | awk '{print $2}' | sed 's/-[^-]*-[^-]*$//' | sed 's/-0//') + ixName=$(echo "$i" | awk '{print $1}') + port=$(echo "$all_ports" | grep -E "\s$appName\s" | awk '{print $6}' | grep -Eo "^[[:digit:]]+{1}") + echo -e "$appName.$ixName.svc.cluster.local $port" +done | uniq | nl -b t | sed 's/\s\s\s$/- -------- ----/' | column -t -R 1 -N "#,DNS_Name,Port" -L +} +export -f dns \ No newline at end of file diff --git a/functions/misc.sh b/functions/misc.sh new file mode 100644 index 00000000..f854381b --- /dev/null +++ b/functions/misc.sh @@ -0,0 +1,57 @@ +#!/bin/bash + + +sync(){ +echo -e "\nSyncing all catalogs, please wait.." && cli -c 'app catalog sync_all' &> /dev/null && echo -e "Catalog sync complete" +} +export -f sync + +prune(){ +echo -e "\nPruning Docker Images" && docker image prune -af | grep "^Total" || echo "Failed to Prune Docker Images" +} +export -f prune + +title(){ +echo ' _ _ _____ _ _ ' +echo '| | | | / ___| (_) | | ' +echo '| |_| | ___ __ ___ ___ _\ `--. ___ _ __ _ _ __ | |_' +echo "| _ |/ _ \/ _\` \ \ / / | | |\`--. \/ __| '__| | '_ \| __|" +echo '| | | | __/ (_| |\ V /| |_| /\__/ / (__| | | | |_) | |_ ' +echo '\_| |_/\___|\__,_| \_/ \__, \____/ \___|_| |_| .__/ \__|' +echo ' __/ | | | ' +echo ' |___/ |_| ' +echo +} +export -f title + +help(){ +[[ $help == "true" ]] && clear -x +echo "Basic Utilities" +echo "--mount | Initiates mounting feature, choose between unmounting and mounting PVC data" +echo "--restore | Opens a menu to restore a \"heavy_script\" backup that was taken on your \"ix-applications\" dataset" +echo "--delete-backup | Opens a menu to delete backups on your system" +echo "--dns | list all of your applications DNS names and their web ports" +echo +echo "Update Options" +echo "-U | Update all applications, ignores versions" +echo "-u | Update all applications, does not update Major releases" +echo "-b | Back-up your ix-applications dataset, specify a number after -b" +echo "-i | Add application to ignore list, one by one, see example below." +echo "-R | THIS OPTION WILL DEPRICATE SOON, USE \"-r\" instead. Roll-back applications if they fail to update" +echo "-r | Roll-back applications if they fail to update" +echo "-S | Shutdown applications prior to updating" +echo "-v | verbose output" +echo "-t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" +echo "-s | sync catalog" +echo "-p | Prune unused/old docker images" +echo +echo "Examples" +echo "bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vrsUp" +echo "bash /mnt/tank/scripts/heavy_script.sh -t 150 --mount" +echo "bash /mnt/tank/scripts/heavy_script.sh --dns" +echo "bash heavy_script.sh --restore" +echo "bash /mnt/tank/scripts/heavy_script.sh --delete-backup" +echo +exit +} +export -f help \ No newline at end of file diff --git a/functions/mount.sh b/functions/mount.sh new file mode 100644 index 00000000..88d9af21 --- /dev/null +++ b/functions/mount.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +mount(){ +clear -x +title +echo -e "1 Mount\n2 Unmount All" && read -t 600 -p "Please type a number: " selection +[[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script +if [[ $selection == "1" ]]; then + list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") + echo "$list" && read -t 120 -p "Please type a number: " selection + [[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script + app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) + [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script + pvc=$(echo -e "$list" | grep ^"$selection ") + status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") + if [[ "$status" != "STOPPED" ]]; then + [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" + SECONDS=0 && echo -e "\nScaling down $app" && midclt call chart.release.scale "$app" '{"replica_count": 0}' &> /dev/null + else + echo -e "\n$app is already stopped" + fi + while [[ "$SECONDS" -le "$timeout" && "$status" != "STOPPED" ]] + do + status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") + echo -e "Waiting $((timeout-SECONDS)) more seconds for $app to be STOPPED" && sleep 5 + done + data_name=$(echo "$pvc" | awk '{print $3}') + mount=$(echo "$pvc" | awk '{print $4}') + volume_name=$(echo "$pvc" | awk '{print $4}') + mapfile -t full_path < <(zfs list | grep "$volume_name" | awk '{print $1}') + if [[ "${#full_path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. + echo "$app is a name used on more than one pool.. attempting to use your current kubernetes apps pool" + pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") + full_path=$(zfs list | grep "$volume_name" | grep "$pool" | awk '{print $1}') + fi + echo -e "\nMounting\n$full_path\nTo\n/mnt/heavyscript/$data_name" + zfs set mountpoint=/heavyscript/"$data_name" "$full_path" || echo "Failed to mount $app" + echo -e "Mounted\n\nUnmount with:\nzfs set mountpoint=legacy $full_path && rmdir /mnt/heavyscript/$data_name\n\nOr use the Unmount All option\n" + exit +elif [[ $selection == "2" ]]; then + mapfile -t unmount_array < <(basename -a /mnt/heavyscript/* | sed "s/*//") + [[ -z $unmount_array ]] && echo "Theres nothing to unmount" && exit + for i in "${unmount_array[@]}" + do + main=$(k3s kubectl get pvc -A | grep -E "\s$i\s" | awk '{print $1, $2, $4}') + app=$(echo "$main" | awk '{print $1}' | cut -c 4-) + pvc=$(echo "$main" | awk '{print $3}') + mapfile -t path < <(find /mnt/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) + if [[ "${#path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. + echo "$i is a name used on more than one pool.. attempting to use your current kubernetes apps pool" + pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") + full_path=$(find /mnt/"$pool"/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) + zfs set mountpoint=legacy "$full_path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" + else + zfs set mountpoint=legacy "$path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" + fi + done + rmdir /mnt/heavyscript +else + echo "Invalid selection, \"$selection\" was not an option" +fi +} +export -f mount \ No newline at end of file diff --git a/functions/self_update.sh b/functions/self_update.sh new file mode 100644 index 00000000..340d5a5d --- /dev/null +++ b/functions/self_update.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +args=("$@") + +self_update() { +script=$(readlink -f "$0") +script_path=$(dirname "$script") +script_name="heavy_script.sh" +cd "$script_path" || exit +git fetch &> /dev/null + +if git diff --name-only origin/main | grep -q "$script_name" ; then + echo "Found a new version of HeavyScript, updating myself..." + git reset --hard -q + git pull --force -q + echo -e "Running the new version...\n" + count=0 + for i in "${args[@]}" + do + [[ "$i" == "--self-update" ]] && unset "args[$count]" && break + ((count++)) + done + sleep 5 + exec bash "$script_name" "${args[@]}" + + # Now exit this old instance + exit +else + echo -e "HeavyScript is already the latest version\n" +fi +} +export -f self_update \ No newline at end of file diff --git a/functions/update_apps.sh b/functions/update_apps.sh new file mode 100644 index 00000000..a406e46d --- /dev/null +++ b/functions/update_apps.sh @@ -0,0 +1,132 @@ +#!/bin/bash + + +update_apps(){ +# Replace with line below after testing +# cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | tr -d " \t\r" | grep -E ",true($|,)" | sort +mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep -E ",true(,|\b)" | sort) +[[ -z $array ]] && echo -e "\nThere are no updates available" && return 0 || echo -e "\n${#array[@]} update(s) available" +[[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" +[[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" +for i in "${array[@]}" +do + app_name=$(echo "$i" | awk -F ',' '{print $1}') #print out first catagory, name. + old_app_ver=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version + new_app_ver=$(echo "$i" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version + old_chart_ver=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version + new_chart_ver=$(echo "$i" | awk -F ',' '{print $5}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # New Chart MAJOR version + status=$(echo "$i" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE + startstatus=$status + diff_app=$(diff <(echo "$old_app_ver") <(echo "$new_app_ver")) #caluclating difference in major app versions + diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclating difference in Chart versions + old_full_ver=$(echo "$i" | awk -F ',' '{print $4}') #Upgraded From + new_full_ver=$(echo "$i" | awk -F ',' '{print $5}') #Upraded To + rollback_version=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') + printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && continue #If application is on ignore list, skip + if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update + if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not + if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop + echo -e "\n$app_name" + [[ "$verbose" == "true" ]] && echo "Updating.." + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "FAILED" + continue + else # if status was not STOPPED, stop the app prior to updating + echo -e "\n$app_name" + [[ "$verbose" == "true" ]] && echo "Stopping prior to update.." + midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && SECONDS=0 || echo -e "FAILED" + while [[ "$status" != "STOPPED" ]] + do + status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') + if [[ "$status" == "STOPPED" ]]; then + echo "Stopped" + [[ "$verbose" == "true" ]] && echo "Updating.." + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "Failed to update" + break + elif [[ "$SECONDS" -ge "$timeout" ]]; then + echo "Error: Run Time($SECONDS) has exceeded Timeout($timeout)" + break + elif [[ "$status" != "STOPPED" ]]; then + [[ "$verbose" == "true" ]] && echo "Waiting $((timeout-SECONDS)) more seconds for $app_name to be STOPPED" + sleep 10 + continue + fi + done + fi + else #user must not be using -S, just update + echo -e "\n$app_name" + [[ "$verbose" == "true" ]] && echo "Updating.." + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "FAILED" + fi + else + echo -e "\n$app_name\nMajor Release, update manually" + continue + fi +done +} +export -f update_apps + + +after_update_actions(){ +SECONDS=0 +count=0 +if [[ $rollback == "true" ]]; then + while true + do + (( count++ )) + status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') + if [[ "$status" == "ACTIVE" && "$startstatus" == "STOPPED" ]]; then + [[ "$verbose" == "true" ]] && echo "Returing to STOPPED state.." + midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && echo "Stopped"|| echo "FAILED" + break + elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" && "$failed" != "true" ]]; then + echo -e "Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)\nIf this is a slow starting application, set a higher timeout with -t\nIf this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration\nReverting update.." + midclt call chart.release.rollback "$app_name" "{\"item_version\": \"$rollback_version\"}" &> /dev/null + [[ "$startstatus" == "STOPPED" ]] && failed="true" && after_update_actions && unset failed #run back after_update_actions function if the app was stopped prior to update + break + elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" && "$failed" == "true" ]]; then + echo -e "Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)\nThe application failed to be ACTIVE even after a rollback,\nManual intervention is required\nAbandoning" + break + elif [[ "$status" == "STOPPED" ]]; then + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo "Verifying Stopped.." && sleep 15 && continue #if reports stopped on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check + echo "Stopped" && break #if reports stopped any time after the first loop, assume its extermal services. + elif [[ "$status" == "ACTIVE" ]]; then + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo "Verifying Active.." && sleep 15 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check + echo "Active" && break #if reports active any time after the first loop, assume actually active. + else + [[ "$verbose" == "true" ]] && echo "Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE" + sleep 15 + continue + fi + done +else + if [[ "$startstatus" == "STOPPED" ]]; then + while true #using a constant while loop, then breaking out of the loop with break commands below. + do + (( count++ )) + status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') + if [[ "$status" == "STOPPED" ]]; then + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo "Verifying Stopped.." && sleep 15 && continue #if reports stopped on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check + echo "Stopped" && break #assume actually stopped anytime AFTER the first loop + break + elif [[ "$status" == "ACTIVE" ]]; then + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo "Verifying Active.." && sleep 15 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check + [[ "$verbose" == "true" ]] && echo "Returing to STOPPED state.." + midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && echo "Stopped"|| echo "FAILED" + break + elif [[ "$SECONDS" -ge "$timeout" ]]; then + echo "Error: Run Time($SECONDS) has exceeded Timeout($timeout)" + break + else + [[ "$verbose" == "true" ]] && echo "Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE" + sleep 10 + continue + fi + done + fi +fi +} +export -f after_update_actions \ No newline at end of file diff --git a/heavy_script.sh b/heavy_script.sh index 8f38bfad..90eb0575 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -3,369 +3,19 @@ #If no argument is passed, kill the script. [[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit -args=("$@") -self_update() { -script=$(readlink -f "$0") -script_path=$(dirname "$script") -script_name="heavy_script.sh" -cd "$script_path" || exit -git fetch &> /dev/null - -if git diff --name-only origin/main | grep -q "$script_name" ; then - echo "Found a new version of HeavyScript, updating myself..." - git reset --hard -q - git pull --force -q - echo -e "Running the new version...\n" - count=0 - for i in "${args[@]}" - do - [[ "$i" == "--self-update" ]] && unset "args[$count]" && break - ((count++)) - done - sleep 5 - exec bash "$script_name" "${args[@]}" - - # Now exit this old instance - exit -else - echo -e "HeavyScript is already the latest version\n" -fi -} - - -help(){ -[[ $help == "true" ]] && clear -x -echo "Basic Utilities" -echo "--mount | Initiates mounting feature, choose between unmounting and mounting PVC data" -echo "--restore | Opens a menu to restore a \"heavy_script\" backup that was taken on your \"ix-applications\" dataset" -echo "--delete-backup | Opens a menu to delete backups on your system" -echo "--dns | list all of your applications DNS names and their web ports" -echo -echo "Update Options" -echo "-U | Update all applications, ignores versions" -echo "-u | Update all applications, does not update Major releases" -echo "-b | Back-up your ix-applications dataset, specify a number after -b" -echo "-i | Add application to ignore list, one by one, see example below." -echo "-R | THIS OPTION WILL DEPRICATE SOON, USE \"-r\" instead. Roll-back applications if they fail to update" -echo "-r | Roll-back applications if they fail to update" -echo "-S | Shutdown applications prior to updating" -echo "-v | verbose output" -echo "-t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" -echo "-s | sync catalog" -echo "-p | Prune unused/old docker images" -echo -echo "Examples" -echo "bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vrsUp" -echo "bash /mnt/tank/scripts/heavy_script.sh -t 150 --mount" -echo "bash /mnt/tank/scripts/heavy_script.sh --dns" -echo "bash heavy_script.sh --restore" -echo "bash /mnt/tank/scripts/heavy_script.sh --delete-backup" -echo -exit -} -export -f help - - -deleteBackup(){ -clear -x && echo "pulling all restore points.." -list_backups=$(cli -c 'app kubernetes list_backups' | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t) -clear -x -[[ -z "$list_backups" ]] && echo "No restore points available" && exit || { title; echo -e "Choose a restore point to delete\nThese may be out of order if they are not HeavyScript backups" ; } -echo "$list_backups" && read -t 600 -p "Please type a number: " selection && restore_point=$(echo "$list_backups" | grep ^"$selection " | awk '{print $2}') -[[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script -[[ -z "$restore_point" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script -echo -e "\nWARNING:\nYou CANNOT go back after deleting your restore point" || { echo "FAILED"; exit; } -echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" && echo -e "1 Yes\n2 No" && read -t 120 -p "Please type a number: " yesno || { echo "FAILED"; exit; } -if [[ $yesno == "1" ]]; then - echo -e "\nDeleting $restore_point" && cli -c 'app kubernetes delete_backup backup_name=''"'"$restore_point"'"' &>/dev/null && echo "Sucessfully deleted" || echo "Deletion Failed" -elif [[ $yesno == "2" ]]; then - echo "You've chosen NO, killing script." -else - echo "Invalid Selection" -fi -} -export -f deleteBackup - - -backup(){ -echo -e "\nNumber of backups was set to $number_of_backups" -date=$(date '+%Y_%m_%d_%H_%M_%S') -[[ "$verbose" == "true" ]] && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' -[[ -z "$verbose" ]] && echo -e "\nNew Backup Name:" && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' | tail -n 1 -mapfile -t list_backups < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r") -if [[ ${#list_backups[@]} -gt "number_of_backups" ]]; then - echo -e "\nDeleting the oldest backup(s) for exceeding limit:" - overflow=$(( ${#list_backups[@]} - "$number_of_backups" )) - mapfile -t list_overflow < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -V -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r" | head -n "$overflow") - for i in "${list_overflow[@]}" - do - cli -c 'app kubernetes delete_backup backup_name=''"'"$i"'"' &> /dev/null || echo "Failed to delete $i" - echo "$i" - done -fi -} -export -f backup - - -restore(){ -clear -x && echo "pulling restore points.." -list_backups=$(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t) -clear -x -[[ -z "$list_backups" ]] && echo "No HeavyScript restore points available" && exit || { title; echo "Choose a restore point" ; } -echo "$list_backups" && read -t 600 -p "Please type a number: " selection && restore_point=$(echo "$list_backups" | grep ^"$selection " | awk '{print $2}') -[[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script -[[ -z "$restore_point" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script -echo -e "\nWARNING:\nThis is NOT guranteed to work\nThis is ONLY supposed to be used as a LAST RESORT\nConsider rolling back your applications instead if possible" || { echo "FAILED"; exit; } -echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" && echo -e "1 Yes\n2 No" && read -t 120 -p "Please type a number: " yesno || { echo "FAILED"; exit; } -if [[ $yesno == "1" ]]; then - echo -e "\nStarting Backup, this will take a LONG time." && cli -c 'app kubernetes restore_backup backup_name=''"'"$restore_point"'"' || echo "Restore FAILED" -elif [[ $yesno == "2" ]]; then - echo "You've chosen NO, killing script. Good luck." -else - echo "Invalid Selection" -fi -} -export -f restore - - -dns(){ -clear -x -echo "Generating DNS Names.." -#ignored dependency pods, may need to add more in the future. -dep_ignore="\-cronjob\-|^kube-system|\ssvclb|NAME|\-memcached\-.[^custom\-app]|\-postgresql\-.[^custom\-app]|\-redis\-.[^custom\-app]|\-mariadb\-.[^custom\-app]|\-promtail\-.[^custom\-app]" - -# Pulling pod names -mapfile -t main < <(k3s kubectl get pods -A | grep -Ev "$dep_ignore" | sort) - -# Pulling all ports -all_ports=$(k3s kubectl get service -A) - -clear -x -count=0 -for i in "${main[@]}" -do - [[ count -le 0 ]] && echo -e "\n" && ((count++)) - appName=$(echo "$i" | awk '{print $2}' | sed 's/-[^-]*-[^-]*$//' | sed 's/-0//') - ixName=$(echo "$i" | awk '{print $1}') - port=$(echo "$all_ports" | grep -E "\s$appName\s" | awk '{print $6}' | grep -Eo "^[[:digit:]]+{1}") - echo -e "$appName.$ixName.svc.cluster.local $port" -done | uniq | nl -b t | sed 's/\s\s\s$/- -------- ----/' | column -t -R 1 -N "#,DNS_Name,Port" -L -} -export -f dns - - -mount(){ -clear -x -title -echo -e "1 Mount\n2 Unmount All" && read -t 600 -p "Please type a number: " selection -[[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script -if [[ $selection == "1" ]]; then - list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") - echo "$list" && read -t 120 -p "Please type a number: " selection - [[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script - app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) - [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script - pvc=$(echo -e "$list" | grep ^"$selection ") - status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") - if [[ "$status" != "STOPPED" ]]; then - [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" - SECONDS=0 && echo -e "\nScaling down $app" && midclt call chart.release.scale "$app" '{"replica_count": 0}' &> /dev/null - else - echo -e "\n$app is already stopped" - fi - while [[ "$SECONDS" -le "$timeout" && "$status" != "STOPPED" ]] - do - status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") - echo -e "Waiting $((timeout-SECONDS)) more seconds for $app to be STOPPED" && sleep 5 - done - data_name=$(echo "$pvc" | awk '{print $3}') - mount=$(echo "$pvc" | awk '{print $4}') - volume_name=$(echo "$pvc" | awk '{print $4}') - full_path=$(zfs list | grep "$volume_name" | awk '{print $1}') - echo -e "\nMounting\n$full_path\nTo\n/mnt/heavyscript/$data_name" && zfs set mountpoint=/heavyscript/"$data_name" "$full_path" && echo -e "Mounted\n\nUnmount with:\nzfs set mountpoint=legacy "$full_path" && rmdir /mnt/heavyscript/"$data_name"\n\nOr use the Unmount All option\n" - exit -elif [[ $selection == "2" ]]; then - mapfile -t unmount_array < <(basename -a /mnt/heavyscript/* | sed "s/*//") - [[ -z $unmount_array ]] && echo "Theres nothing to unmount" && exit - for i in "${unmount_array[@]}" - do - main=$(k3s kubectl get pvc -A | grep -E "\s$i\s" | awk '{print $1, $2, $4}') - app=$(echo "$main" | awk '{print $1}' | cut -c 4-) - pvc=$(echo "$main" | awk '{print $3}') - mapfile -t path < <(find /mnt/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) - if [[ "${#path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused. - echo "$i is a name used on more than one pool.. attempting to use your current kubernetes apps pool" - pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") - full_path=$(find /mnt/"$pool"/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) - zfs set mountpoint=legacy "$full_path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" - else - zfs set mountpoint=legacy "$path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" - fi - done - rmdir /mnt/heavyscript -else - echo "Invalid selection, \"$selection\" was not an option" -fi -} -export -f mount - - -sync(){ -echo -e "\nSyncing all catalogs, please wait.." && cli -c 'app catalog sync_all' &> /dev/null && echo -e "Catalog sync complete" -} -export -f sync - - -update_apps(){ -# Replace with line below after testing -# cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | tr -d " \t\r" | grep -E ",true($|,)" | sort -mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep -E ",true(,|\b)" | sort) -[[ -z $array ]] && echo -e "\nThere are no updates available" && return 0 || echo -e "\n${#array[@]} update(s) available" -[[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" -[[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" -for i in "${array[@]}" -do - app_name=$(echo "$i" | awk -F ',' '{print $1}') #print out first catagory, name. - old_app_ver=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version - new_app_ver=$(echo "$i" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version - old_chart_ver=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version - new_chart_ver=$(echo "$i" | awk -F ',' '{print $5}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # New Chart MAJOR version - status=$(echo "$i" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE - startstatus=$status - diff_app=$(diff <(echo "$old_app_ver") <(echo "$new_app_ver")) #caluclating difference in major app versions - diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclating difference in Chart versions - old_full_ver=$(echo "$i" | awk -F ',' '{print $4}') #Upgraded From - new_full_ver=$(echo "$i" | awk -F ',' '{print $5}') #Upraded To - rollback_version=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') - printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && continue #If application is on ignore list, skip - if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update - if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not - if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop - echo -e "\n$app_name" - [[ "$verbose" == "true" ]] && echo "Updating.." - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "FAILED" - continue - else # if status was not STOPPED, stop the app prior to updating - echo -e "\n$app_name" - [[ "$verbose" == "true" ]] && echo "Stopping prior to update.." - midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && SECONDS=0 || echo -e "FAILED" - while [[ "$status" != "STOPPED" ]] - do - status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') - if [[ "$status" == "STOPPED" ]]; then - echo "Stopped" - [[ "$verbose" == "true" ]] && echo "Updating.." - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "Failed to update" - break - elif [[ "$SECONDS" -ge "$timeout" ]]; then - echo "Error: Run Time($SECONDS) has exceeded Timeout($timeout)" - break - elif [[ "$status" != "STOPPED" ]]; then - [[ "$verbose" == "true" ]] && echo "Waiting $((timeout-SECONDS)) more seconds for $app_name to be STOPPED" - sleep 10 - continue - fi - done - fi - else #user must not be using -S, just update - echo -e "\n$app_name" - [[ "$verbose" == "true" ]] && echo "Updating.." - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "FAILED" - fi - else - echo -e "\n$app_name\nMajor Release, update manually" - continue - fi -done -} -export -f update_apps - - -after_update_actions(){ -SECONDS=0 -count=0 -if [[ $rollback == "true" ]]; then - while [[ "0" != "1" ]] - do - (( count++ )) - status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') - if [[ "$status" == "ACTIVE" && "$startstatus" == "STOPPED" ]]; then - [[ "$verbose" == "true" ]] && echo "Returing to STOPPED state.." - midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && echo "Stopped"|| echo "FAILED" - break - elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" && "$failed" != "true" ]]; then - echo -e "Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)\nIf this is a slow starting application, set a higher timeout with -t\nIf this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration\nReverting update.." - midclt call chart.release.rollback "$app_name" "{\"item_version\": \"$rollback_version\"}" &> /dev/null - [[ "$startstatus" == "STOPPED" ]] && failed="true" && after_update_actions && unset failed #run back after_update_actions function if the app was stopped prior to update - break - elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" && "$failed" == "true" ]]; then - echo -e "Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)\nThe application failed to be ACTIVE even after a rollback,\nManual intervention is required\nAbandoning" - break - elif [[ "$status" == "STOPPED" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo "Verifying Stopped.." && sleep 15 && continue #if reports stopped on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check - echo "Stopped" && break #if reports stopped any time after the first loop, assume its extermal services. - elif [[ "$status" == "ACTIVE" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo "Verifying Active.." && sleep 15 && continue #if reports active on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check - echo "Active" && break #if reports active any time after the first loop, assume actually active. - else - [[ "$verbose" == "true" ]] && echo "Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE" - sleep 15 - continue - fi - done -else - if [[ "$startstatus" == "STOPPED" ]]; then - while [[ "0" != "1" ]] #using a constant while loop, then breaking out of the loop with break commands below. - do - (( count++ )) - status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') - if [[ "$status" == "STOPPED" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo "Verifying Stopped.." && sleep 15 && continue #if reports stopped on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check - echo "Stopped" && break #assume actually stopped anytime AFTER the first loop - break - elif [[ "$status" == "ACTIVE" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo "Verifying Active.." && sleep 15 && continue #if reports active on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check - [[ "$verbose" == "true" ]] && echo "Returing to STOPPED state.." - midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && echo "Stopped"|| echo "FAILED" - break - elif [[ "$SECONDS" -ge "$timeout" ]]; then - echo "Error: Run Time($SECONDS) has exceeded Timeout($timeout)" - break - else - [[ "$verbose" == "true" ]] && echo "Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE" - sleep 10 - continue - fi - done - fi -fi -} -export -f after_update_actions - - -prune(){ -echo -e "\nPruning Docker Images" && docker image prune -af | grep "^Total" || echo "Failed to Prune Docker Images" -} -export -f prune - - -title(){ -echo ' _ _ _____ _ _ ' -echo '| | | | / ___| (_) | | ' -echo '| |_| | ___ __ ___ ___ _\ `--. ___ _ __ _ _ __ | |_' -echo "| _ |/ _ \/ _\` \ \ / / | | |\`--. \/ __| '__| | '_ \| __|" -echo '| | | | __/ (_| |\ V /| |_| /\__/ / (__| | | | |_) | |_ ' -echo '\_| |_/\___|\__,_| \_/ \__, \____/ \___|_| |_| .__/ \__|' -echo ' __/ | | | ' -echo ' |___/ |_| ' -echo -} -export -f title +# shellcheck source=functions/backup.sh +source functions/backup.sh +# shellcheck source=functions/dns.sh +source functions/dns.sh +# shellcheck source=functions/misc.sh +source functions/misc.sh +# shellcheck source=functions/mount.sh +source functions/mount.sh +# shellcheck source=functions/self_update.sh +source functions/self_update.sh +# shellcheck source=functions/update_apps.sh +source functions/update_apps.sh # Parse script options From d7136fe270da807791f0fdf10312b422e48e0cc0 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 24 Jul 2022 22:03:57 -0600 Subject: [PATCH 090/352] test --- functions/update_apps.sh | 54 +++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index a406e46d..dcce0351 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -1,35 +1,45 @@ #!/bin/bash -update_apps(){ -# Replace with line below after testing -# cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | tr -d " \t\r" | grep -E ",true($|,)" | sort -mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep -E ",true(,|\b)" | sort) +mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | tr -d " \t\r" | grep -E ",true($|,)" | sort) [[ -z $array ]] && echo -e "\nThere are no updates available" && return 0 || echo -e "\n${#array[@]} update(s) available" [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" -for i in "${array[@]}" -do - app_name=$(echo "$i" | awk -F ',' '{print $1}') #print out first catagory, name. - old_app_ver=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version - new_app_ver=$(echo "$i" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version - old_chart_ver=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version - new_chart_ver=$(echo "$i" | awk -F ',' '{print $5}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # New Chart MAJOR version - status=$(echo "$i" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE - startstatus=$status - diff_app=$(diff <(echo "$old_app_ver") <(echo "$new_app_ver")) #caluclating difference in major app versions - diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclating difference in Chart versions - old_full_ver=$(echo "$i" | awk -F ',' '{print $4}') #Upgraded From - new_full_ver=$(echo "$i" | awk -F ',' '{print $5}') #Upraded To - rollback_version=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') - printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && continue #If application is on ignore list, skip + +update_limit=5 +count=0 + for i in "${array[@]}" + do + update_apps "$i" & + (( count++ )) + while [[ "$count" -ge "$update_limit" ]] + do + wait + done + done + + +update_apps(){ +app_name=$(echo "$i" | awk -F ',' '{print $1}') #print out first catagory, name. +old_app_ver=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version +new_app_ver=$(echo "$i" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version +old_chart_ver=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version +new_chart_ver=$(echo "$i" | awk -F ',' '{print $5}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # New Chart MAJOR version +status=$(echo "$i" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE +startstatus=$status +diff_app=$(diff <(echo "$old_app_ver") <(echo "$new_app_ver")) #caluclating difference in major app versions +diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclating difference in Chart versions +old_full_ver=$(echo "$i" | awk -F ',' '{print $4}') #Upgraded From +new_full_ver=$(echo "$i" | awk -F ',' '{print $5}') #Upraded To +rollback_version=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') +printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && return #If application is on ignore list, skip if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop echo -e "\n$app_name" [[ "$verbose" == "true" ]] && echo "Updating.." cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "FAILED" - continue + return else # if status was not STOPPED, stop the app prior to updating echo -e "\n$app_name" [[ "$verbose" == "true" ]] && echo "Stopping prior to update.." @@ -48,7 +58,6 @@ do elif [[ "$status" != "STOPPED" ]]; then [[ "$verbose" == "true" ]] && echo "Waiting $((timeout-SECONDS)) more seconds for $app_name to be STOPPED" sleep 10 - continue fi done fi @@ -59,9 +68,8 @@ do fi else echo -e "\n$app_name\nMajor Release, update manually" - continue + return fi -done } export -f update_apps From a0104e65e2f1aae45444c168f92af3a8b66aab9e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 24 Jul 2022 22:07:24 -0600 Subject: [PATCH 091/352] waiting --- functions/update_apps.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index dcce0351..dea780d6 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -14,6 +14,7 @@ count=0 (( count++ )) while [[ "$count" -ge "$update_limit" ]] do + echo "waiting for free space" wait done done From 63ec2b586adc3a585f9dc2d36600e1282cdf9605 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 24 Jul 2022 22:11:04 -0600 Subject: [PATCH 092/352] commander func --- functions/update_apps.sh | 5 +++-- heavy_script.sh | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index dea780d6..e5691bce 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -1,6 +1,6 @@ #!/bin/bash - +commander(){ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | tr -d " \t\r" | grep -E ",true($|,)" | sort) [[ -z $array ]] && echo -e "\nThere are no updates available" && return 0 || echo -e "\n${#array[@]} update(s) available" [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" @@ -18,7 +18,8 @@ count=0 wait done done - +} +export -f commander update_apps(){ app_name=$(echo "$i" | awk -F ',' '{print $1}') #print out first catagory, name. diff --git a/heavy_script.sh b/heavy_script.sh index 90eb0575..905e50de 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -115,5 +115,5 @@ done [[ "$mount" == "true" ]] && mount && exit [[ "$number_of_backups" -ge 1 ]] && backup [[ "$sync" == "true" ]] && sync -[[ "$update_all_apps" == "true" || "$update_apps" == "true" ]] && update_apps +[[ "$update_all_apps" == "true" || "$update_apps" == "true" ]] && commander [[ "$prune" == "true" ]] && prune \ No newline at end of file From c60593da882782789c396e386d352627c6d607a9 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 24 Jul 2022 22:12:46 -0600 Subject: [PATCH 093/352] reset count --- functions/update_apps.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index e5691bce..8bf95187 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -16,6 +16,7 @@ count=0 do echo "waiting for free space" wait + count=0 done done } From 9079cf7a3318ca39e94778af44e1a664f609e370 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 24 Jul 2022 22:19:14 -0600 Subject: [PATCH 094/352] return --- functions/update_apps.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 8bf95187..8b4f3431 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -139,5 +139,6 @@ else done fi fi +return } export -f after_update_actions \ No newline at end of file From 1b89f902302038a39d4a763ec7d39aeef2d15bff Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 24 Jul 2022 22:23:57 -0600 Subject: [PATCH 095/352] wait --- functions/update_apps.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 8b4f3431..5284beab 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -12,6 +12,7 @@ count=0 do update_apps "$i" & (( count++ )) + processes+=($!) while [[ "$count" -ge "$update_limit" ]] do echo "waiting for free space" @@ -19,6 +20,12 @@ count=0 count=0 done done + +for proc in "${processes[@]}" +do + wait "$proc" +done + } export -f commander From 5d17035dffb7c71b99cd8a6e333cd5b317cc39b1 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 24 Jul 2022 22:26:43 -0600 Subject: [PATCH 096/352] wait --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 5284beab..c28f9f55 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -16,7 +16,7 @@ count=0 while [[ "$count" -ge "$update_limit" ]] do echo "waiting for free space" - wait + wait -n "${processes[@]}" count=0 done done From bed013a5840c60dc964bc8ae3244a1082f2fba43 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 24 Jul 2022 22:27:41 -0600 Subject: [PATCH 097/352] count --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index c28f9f55..b91cb9b6 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -17,7 +17,7 @@ count=0 do echo "waiting for free space" wait -n "${processes[@]}" - count=0 + (( count-- )) done done From 7268ae55949b971bac7818f932a04dd2435fb91b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 24 Jul 2022 22:39:27 -0600 Subject: [PATCH 098/352] jobs --- functions/update_apps.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index b91cb9b6..d02ea7c5 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -15,9 +15,11 @@ count=0 processes+=($!) while [[ "$count" -ge "$update_limit" ]] do + jobs -p + pidcount=0 echo "waiting for free space" - wait -n "${processes[@]}" - (( count-- )) + wait -n "${processes[pidcount]}" && (( count-- )) + (( pidcount ++ )) done done From f2143d7330ca6e0fc74d6b71e0a547c628e41d72 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 24 Jul 2022 22:39:53 -0600 Subject: [PATCH 099/352] jobs --- functions/update_apps.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index d02ea7c5..46d647db 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -13,6 +13,7 @@ count=0 update_apps "$i" & (( count++ )) processes+=($!) + jobs -p while [[ "$count" -ge "$update_limit" ]] do jobs -p From 9cf49ed6c32c656115435acfe6e8c28ec365f83e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 24 Jul 2022 22:45:38 -0600 Subject: [PATCH 100/352] output supress --- functions/update_apps.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 46d647db..7af4f387 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -13,14 +13,10 @@ count=0 update_apps "$i" & (( count++ )) processes+=($!) - jobs -p while [[ "$count" -ge "$update_limit" ]] do - jobs -p - pidcount=0 echo "waiting for free space" - wait -n "${processes[pidcount]}" && (( count-- )) - (( pidcount ++ )) + wait -n "${processes[@]}" &> /dev/null && (( count-- )) done done From 4fe1589aef2d62ab4550d7fd1e253f8f8080bb58 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 24 Jul 2022 23:12:15 -0600 Subject: [PATCH 101/352] proccount --- functions/update_apps.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 7af4f387..2c01edb0 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -11,12 +11,14 @@ count=0 for i in "${array[@]}" do update_apps "$i" & - (( count++ )) processes+=($!) - while [[ "$count" -ge "$update_limit" ]] + proc_count=0 + while [[ "${#processes[@]}" -ge "$update_limit" ]] do echo "waiting for free space" - wait -n "${processes[@]}" &> /dev/null && (( count-- )) + wait -n "${processes[$proc_count]}" &> /dev/null + (( proc_count++ )) + unset "processes[$proc_count]" done done From 9000d47a18af80d5f21519182643c8224e65238f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 24 Jul 2022 23:34:20 -0600 Subject: [PATCH 102/352] revamp --- functions/update_apps.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 2c01edb0..027d53d5 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -13,12 +13,14 @@ count=0 update_apps "$i" & processes+=($!) proc_count=0 + count=$(jobs -p | wc -l) while [[ "${#processes[@]}" -ge "$update_limit" ]] do - echo "waiting for free space" - wait -n "${processes[$proc_count]}" &> /dev/null - (( proc_count++ )) - unset "processes[$proc_count]" + for proc in "${processes[@]}" + do + kill -0 "$proc" || unset "processes[$proc_count]" + (( proc_count++ )) + done done done From c347a7c5f8dc84ace276af4ac3bfd0fa16bb3c09 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 24 Jul 2022 23:35:03 -0600 Subject: [PATCH 103/352] lower app limit for test --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 027d53d5..ebd6aa51 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -6,7 +6,7 @@ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_availabl [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" -update_limit=5 +update_limit=2 count=0 for i in "${array[@]}" do From 7cd8de351af27118ecd65d1a301cc124c346d908 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 24 Jul 2022 23:38:14 -0600 Subject: [PATCH 104/352] test --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index ebd6aa51..f3e8d22d 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -18,7 +18,7 @@ count=0 do for proc in "${processes[@]}" do - kill -0 "$proc" || unset "processes[$proc_count]" + kill -0 "$proc" || { unset "processes[$proc_count]"; break; } (( proc_count++ )) done done From b6ec4d4c67fd62bc8d72998147c5218f26859666 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 14:06:40 -0600 Subject: [PATCH 105/352] new method --- functions/update_apps.sh | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index f3e8d22d..db857f38 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -7,20 +7,15 @@ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_availabl [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" update_limit=2 -count=0 +current_updates=0 for i in "${array[@]}" do update_apps "$i" & + (( current_updates++ )) processes+=($!) - proc_count=0 - count=$(jobs -p | wc -l) - while [[ "${#processes[@]}" -ge "$update_limit" ]] + while [[ current_updates -ge "$update_limit" ]] do - for proc in "${processes[@]}" - do - kill -0 "$proc" || { unset "processes[$proc_count]"; break; } - (( proc_count++ )) - done + sleep 5 done done @@ -45,13 +40,14 @@ diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclatin old_full_ver=$(echo "$i" | awk -F ',' '{print $4}') #Upgraded From new_full_ver=$(echo "$i" | awk -F ',' '{print $5}') #Upraded To rollback_version=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') -printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && return #If application is on ignore list, skip +printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && (( current_updates-- )) && return #If application is on ignore list, skip if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop echo -e "\n$app_name" [[ "$verbose" == "true" ]] && echo "Updating.." cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "FAILED" + (( current_updates-- )) return else # if status was not STOPPED, stop the app prior to updating echo -e "\n$app_name" @@ -81,8 +77,10 @@ printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name fi else echo -e "\n$app_name\nMajor Release, update manually" + (( current_updates-- )) return fi +(( current_updates-- )) } export -f update_apps @@ -149,6 +147,5 @@ else done fi fi -return } export -f after_update_actions \ No newline at end of file From 96a412387ce703490d34f1ad8fbdbaef19957e37 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 14:10:57 -0600 Subject: [PATCH 106/352] uhh --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index db857f38..3d6b125b 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -13,7 +13,7 @@ current_updates=0 update_apps "$i" & (( current_updates++ )) processes+=($!) - while [[ current_updates -ge "$update_limit" ]] + while [[ "$current_updates" -ge "$update_limit" ]] do sleep 5 done From 53a7048dc4e7270927db0193b13f4125266e2516 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 14:16:08 -0600 Subject: [PATCH 107/352] global --- functions/update_apps.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 3d6b125b..a4f3ff49 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -1,13 +1,14 @@ #!/bin/bash +current_updates=0 + commander(){ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | tr -d " \t\r" | grep -E ",true($|,)" | sort) [[ -z $array ]] && echo -e "\nThere are no updates available" && return 0 || echo -e "\n${#array[@]} update(s) available" [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" - update_limit=2 -current_updates=0 + for i in "${array[@]}" do update_apps "$i" & From 13a13cdbd7a796e22d32ccc3242821d92a83946a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 14:28:04 -0600 Subject: [PATCH 108/352] who knowws --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index a4f3ff49..092609e4 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -11,7 +11,7 @@ update_limit=2 for i in "${array[@]}" do - update_apps "$i" & + update_apps "$i" && (( current_updates-- )) & (( current_updates++ )) processes+=($!) while [[ "$current_updates" -ge "$update_limit" ]] From a12ead1bef8742997e210c1110a3c213c5da0fcf Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 14:42:57 -0600 Subject: [PATCH 109/352] huih --- functions/update_apps.sh | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 092609e4..28758d57 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -1,6 +1,5 @@ #!/bin/bash -current_updates=0 commander(){ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | tr -d " \t\r" | grep -E ",true($|,)" | sort) @@ -8,17 +7,33 @@ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_availabl [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" update_limit=2 +current_updates=0 - for i in "${array[@]}" - do - update_apps "$i" && (( current_updates-- )) & - (( current_updates++ )) - processes+=($!) - while [[ "$current_updates" -ge "$update_limit" ]] + +while true +do + if [[ current_updates -ge "$update_limit" ]]; then + sleep 5 + else + for i in "${array[@]}" do - sleep 5 + update_apps "$i" && (( current_updates-- )) & (( current_updates++ )) + processes+=($!) done - done + fi +done + + + + + + + + + + + + for proc in "${processes[@]}" do From 2d5987229be8813178de55cd41387a85a196b1a1 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 14:45:43 -0600 Subject: [PATCH 110/352] test --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 28758d57..f013b78c 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -17,7 +17,7 @@ do else for i in "${array[@]}" do - update_apps "$i" && (( current_updates-- )) & (( current_updates++ )) + { update_apps "$i"; (( current_updates-- )) ;} & (( current_updates++ )) processes+=($!) done fi From 10cb46633b2839772a679aea3b303643024f7c89 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 15:02:47 -0600 Subject: [PATCH 111/352] while loop --- functions/update_apps.sh | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index f013b78c..29770ad2 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -9,32 +9,22 @@ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_availabl update_limit=2 current_updates=0 - -while true +it=0 +while [[ $it -lt ${#array[@]} ]] do - if [[ current_updates -ge "$update_limit" ]]; then - sleep 5 + jobs=$(jobs -p | wc -l) + if [[ "$jobs" -ge "$update_limit" ]]; then + sleep 3 else - for i in "${array[@]}" - do - { update_apps "$i"; (( current_updates-- )) ;} & (( current_updates++ )) - processes+=($!) - done + update_apps "${#array[$it]}" & + processes+=($!) + ((it++)) fi done - - - - - - - - - for proc in "${processes[@]}" do wait "$proc" From f0e7624c51bbdd468a13131d8f691859aaf711e3 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 15:06:18 -0600 Subject: [PATCH 112/352] whoops --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 29770ad2..b5cf1632 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -16,7 +16,7 @@ do if [[ "$jobs" -ge "$update_limit" ]]; then sleep 3 else - update_apps "${#array[$it]}" & + update_apps "${array[$it]}" & processes+=($!) ((it++)) fi From 69875f8fda58ddb19cfa3aa7e1424471241d482e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 15:15:25 -0600 Subject: [PATCH 113/352] huh --- functions/update_apps.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index b5cf1632..6344be3b 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -7,7 +7,6 @@ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_availabl [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" update_limit=2 -current_updates=0 it=0 while [[ $it -lt ${#array[@]} ]] @@ -16,15 +15,14 @@ do if [[ "$jobs" -ge "$update_limit" ]]; then sleep 3 else - update_apps "${array[$it]}" & + application="${array[$it]}" + update_apps "$application" & processes+=($!) ((it++)) fi done - - for proc in "${processes[@]}" do wait "$proc" From 26bfaf5306a8de5bb94bfaacfe282bf46c8e8667 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 15:17:35 -0600 Subject: [PATCH 114/352] update --- functions/update_apps.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 6344be3b..6651e331 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -15,8 +15,7 @@ do if [[ "$jobs" -ge "$update_limit" ]]; then sleep 3 else - application="${array[$it]}" - update_apps "$application" & + update_apps "${array[$it]}" & processes+=($!) ((it++)) fi @@ -32,6 +31,7 @@ done export -f commander update_apps(){ +i=${array[$it]} app_name=$(echo "$i" | awk -F ',' '{print $1}') #print out first catagory, name. old_app_ver=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version new_app_ver=$(echo "$i" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version From 36cc4c1143a08db3c4267a8ed6835943167a9cab Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 15:20:32 -0600 Subject: [PATCH 115/352] async --- functions/update_apps.sh | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 6651e331..6ff12b6f 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -31,27 +31,25 @@ done export -f commander update_apps(){ -i=${array[$it]} -app_name=$(echo "$i" | awk -F ',' '{print $1}') #print out first catagory, name. -old_app_ver=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version -new_app_ver=$(echo "$i" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version -old_chart_ver=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version -new_chart_ver=$(echo "$i" | awk -F ',' '{print $5}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # New Chart MAJOR version -status=$(echo "$i" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE +app_name=$(echo "${array[$it]}" | awk -F ',' '{print $1}') #print out first catagory, name. +old_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version +new_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version +old_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version +new_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # New Chart MAJOR version +status=$(echo "${array[$it]}" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE startstatus=$status diff_app=$(diff <(echo "$old_app_ver") <(echo "$new_app_ver")) #caluclating difference in major app versions diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclating difference in Chart versions -old_full_ver=$(echo "$i" | awk -F ',' '{print $4}') #Upgraded From -new_full_ver=$(echo "$i" | awk -F ',' '{print $5}') #Upraded To -rollback_version=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') -printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && (( current_updates-- )) && return #If application is on ignore list, skip +old_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}') #Upgraded From +new_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}') #Upraded To +rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') +printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && return #If application is on ignore list, skip if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop echo -e "\n$app_name" [[ "$verbose" == "true" ]] && echo "Updating.." cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "FAILED" - (( current_updates-- )) return else # if status was not STOPPED, stop the app prior to updating echo -e "\n$app_name" @@ -81,10 +79,8 @@ printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name fi else echo -e "\n$app_name\nMajor Release, update manually" - (( current_updates-- )) return fi -(( current_updates-- )) } export -f update_apps From 71dca98533faf4c21bb9b361ee48cdd4397256c0 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 15:21:26 -0600 Subject: [PATCH 116/352] update limit --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 6ff12b6f..e0b813ba 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -6,7 +6,7 @@ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_availabl [[ -z $array ]] && echo -e "\nThere are no updates available" && return 0 || echo -e "\n${#array[@]} update(s) available" [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" -update_limit=2 +update_limit=4 it=0 while [[ $it -lt ${#array[@]} ]] From 0de879ef38f0bca88d77fe2f56b448fa70658fb7 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 15:59:51 -0600 Subject: [PATCH 117/352] idk --- functions/update_apps.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index e0b813ba..84221570 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -15,18 +15,20 @@ do if [[ "$jobs" -ge "$update_limit" ]]; then sleep 3 else - update_apps "${array[$it]}" & + output=$(update_apps "${array[$it]}" &) processes+=($!) ((it++)) fi done - +echo "$output" for proc in "${processes[@]}" do wait "$proc" done + + } export -f commander From 8f3b9e99228499fc9905866cb148d0ab51832b52 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 16:04:43 -0600 Subject: [PATCH 118/352] array? --- functions/update_apps.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 84221570..bdf438e0 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -15,12 +15,16 @@ do if [[ "$jobs" -ge "$update_limit" ]]; then sleep 3 else - output=$(update_apps "${array[$it]}" &) + mapfile -t output < <(update_apps "${array[$it]}" &) processes+=($!) ((it++)) fi done -echo "$output" + +for i in "${output[@]}" +do + echo "$i" +done for proc in "${processes[@]}" do From 017edabaf0a0f0184cd3d5236d9f39fbd5f213df Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 16:05:37 -0600 Subject: [PATCH 119/352] wait for processes first --- functions/update_apps.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index bdf438e0..8fb9a588 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -21,15 +21,17 @@ do fi done +for proc in "${processes[@]}" +do + wait "$proc" +done + + for i in "${output[@]}" do echo "$i" done -for proc in "${processes[@]}" -do - wait "$proc" -done From a8d26c072ee878ea7cc6421d4579682c0fca4d7c Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 16:08:05 -0600 Subject: [PATCH 120/352] hmm --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 8fb9a588..d3239c49 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -15,7 +15,7 @@ do if [[ "$jobs" -ge "$update_limit" ]]; then sleep 3 else - mapfile -t output < <(update_apps "${array[$it]}" &) + mapfile -t output < <(update_apps "${array[$it]}") & processes+=($!) ((it++)) fi From b499b87dc177f0734d540f9dbb40e9deb6639001 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 16:23:50 -0600 Subject: [PATCH 121/352] uh --- functions/update_apps.sh | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index d3239c49..a97238ff 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -15,7 +15,7 @@ do if [[ "$jobs" -ge "$update_limit" ]]; then sleep 3 else - mapfile -t output < <(update_apps "${array[$it]}") & + coproc update_appsfd { update_apps "${array[$it]}" ; } processes+=($!) ((it++)) fi @@ -26,13 +26,9 @@ do wait "$proc" done +IFS= read -r -d '' -u "${update_appsfd[0]}" update_output -for i in "${output[@]}" -do - echo "$i" -done - - +echo "$update_output" } From 749b591c46070ae63c583ac3fa09b9749a9c7797 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 16:46:05 -0600 Subject: [PATCH 122/352] test --- functions/update_apps.sh | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index a97238ff..23a8eee2 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -9,13 +9,14 @@ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_availabl update_limit=4 it=0 + while [[ $it -lt ${#array[@]} ]] do jobs=$(jobs -p | wc -l) if [[ "$jobs" -ge "$update_limit" ]]; then sleep 3 else - coproc update_appsfd { update_apps "${array[$it]}" ; } + update_apps "${array[$it]}" processes+=($!) ((it++)) fi @@ -26,10 +27,6 @@ do wait "$proc" done -IFS= read -r -d '' -u "${update_appsfd[0]}" update_output - -echo "$update_output" - } export -f commander @@ -85,7 +82,7 @@ printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name echo -e "\n$app_name\nMajor Release, update manually" return fi -} +} | sort export -f update_apps From 143326d0cb5152b649048c54ff88007c64454fa0 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 16:48:17 -0600 Subject: [PATCH 123/352] asdf --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 23a8eee2..2544c030 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -16,7 +16,7 @@ do if [[ "$jobs" -ge "$update_limit" ]]; then sleep 3 else - update_apps "${array[$it]}" + update_apps "${array[$it]}" & processes+=($!) ((it++)) fi From 0bc4d50e777c94e7390f121c312ef6d86379e159 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 16:50:44 -0600 Subject: [PATCH 124/352] append output to array --- functions/update_apps.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 2544c030..dd6d80fd 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -44,7 +44,7 @@ diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclatin old_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}') #Upgraded From new_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}') #Upraded To rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') -printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && return #If application is on ignore list, skip +printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo_array+=(echo -e "\n$app_name\nIgnored, skipping") && return #If application is on ignore list, skip if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop @@ -82,7 +82,7 @@ printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name echo -e "\n$app_name\nMajor Release, update manually" return fi -} | sort +} export -f update_apps From 394486c7a32e5bc541a6436ceb3dced8b3b8b5a7 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 16:52:51 -0600 Subject: [PATCH 125/352] dump array --- functions/update_apps.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index dd6d80fd..476078f1 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -82,6 +82,13 @@ printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo_array+=(echo -e echo -e "\n$app_name\nMajor Release, update manually" return fi + +#dump array +for i in "${echo_array[@]}" +do + echo "$i" +done + } export -f update_apps From 015f0df2c121a32c0bf3588006668796e4ebf76e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 16:56:40 -0600 Subject: [PATCH 126/352] array --- functions/update_apps.sh | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 476078f1..93ae1598 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -44,42 +44,42 @@ diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclatin old_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}') #Upgraded From new_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}') #Upraded To rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') -printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo_array+=(echo -e "\n$app_name\nIgnored, skipping") && return #If application is on ignore list, skip +printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && return #If application is on ignore list, skip if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop - echo -e "\n$app_name" - [[ "$verbose" == "true" ]] && echo "Updating.." - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "FAILED" + echo_array+=(echo -e "\n$app_name") + [[ "$verbose" == "true" ]] && echo_array+=(echo "Updating..") + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=(echo -e "Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo_array+=(echo "FAILED") return else # if status was not STOPPED, stop the app prior to updating - echo -e "\n$app_name" - [[ "$verbose" == "true" ]] && echo "Stopping prior to update.." - midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && SECONDS=0 || echo -e "FAILED" + echo_array+=(echo -e "\n$app_name") + [[ "$verbose" == "true" ]] && echo_array+=(echo "Stopping prior to update..") + midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && SECONDS=0 || echo_array+=(echo -e "FAILED") while [[ "$status" != "STOPPED" ]] do status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') if [[ "$status" == "STOPPED" ]]; then - echo "Stopped" - [[ "$verbose" == "true" ]] && echo "Updating.." - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "Failed to update" + echo_array+=(echo "Stopped") + [[ "$verbose" == "true" ]] && echo_array+=(echo "Updating..") + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=(echo -e "Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo "Failed to update" break elif [[ "$SECONDS" -ge "$timeout" ]]; then - echo "Error: Run Time($SECONDS) has exceeded Timeout($timeout)" + echo_array+=(echo "Error: Run Time($SECONDS) has exceeded Timeout($timeout)") break elif [[ "$status" != "STOPPED" ]]; then - [[ "$verbose" == "true" ]] && echo "Waiting $((timeout-SECONDS)) more seconds for $app_name to be STOPPED" + [[ "$verbose" == "true" ]] && echo_array+=(echo "Waiting $((timeout-SECONDS)) more seconds for $app_name to be STOPPED") sleep 10 fi done fi else #user must not be using -S, just update - echo -e "\n$app_name" - [[ "$verbose" == "true" ]] && echo "Updating.." - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "FAILED" + echo_array+=(echo -e "\n$app_name") + [[ "$verbose" == "true" ]] && echo_array+=(echo "Updating..") + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=(echo -e "Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo "FAILED" fi else - echo -e "\n$app_name\nMajor Release, update manually" + echo_array+=(echo -e "\n$app_name\nMajor Release, update manually") return fi From 337c6faa9e3e10408e1c240571f119385e48ea39 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 16:57:56 -0600 Subject: [PATCH 127/352] huh --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 93ae1598..a69ddfe7 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -86,7 +86,7 @@ printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name #dump array for i in "${echo_array[@]}" do - echo "$i" + echo -e "$i" done } From 25236e8b15c2e955915415a04ea4dbd5db4b7ec2 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 17:06:59 -0600 Subject: [PATCH 128/352] remove echo --- functions/update_apps.sh | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index a69ddfe7..a274a3b5 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -48,38 +48,38 @@ printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop - echo_array+=(echo -e "\n$app_name") - [[ "$verbose" == "true" ]] && echo_array+=(echo "Updating..") - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=(echo -e "Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo_array+=(echo "FAILED") + echo_array+=("\n$app_name") + [[ "$verbose" == "true" ]] && echo_array+=("Updating..") + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=("Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo_array+=("FAILED") return else # if status was not STOPPED, stop the app prior to updating - echo_array+=(echo -e "\n$app_name") - [[ "$verbose" == "true" ]] && echo_array+=(echo "Stopping prior to update..") - midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && SECONDS=0 || echo_array+=(echo -e "FAILED") + echo_array+=("\n$app_name") + [[ "$verbose" == "true" ]] && echo_array+=("Stopping prior to update..") + midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && SECONDS=0 || echo_array+=("FAILED") while [[ "$status" != "STOPPED" ]] do status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') if [[ "$status" == "STOPPED" ]]; then - echo_array+=(echo "Stopped") - [[ "$verbose" == "true" ]] && echo_array+=(echo "Updating..") - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=(echo -e "Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo "Failed to update" + echo_array+=("Stopped") + [[ "$verbose" == "true" ]] && echo_array+=("Updating..") + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=("Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo "Failed to update" break elif [[ "$SECONDS" -ge "$timeout" ]]; then - echo_array+=(echo "Error: Run Time($SECONDS) has exceeded Timeout($timeout)") + echo_array+=("Error: Run Time($SECONDS) has exceeded Timeout($timeout)") break elif [[ "$status" != "STOPPED" ]]; then - [[ "$verbose" == "true" ]] && echo_array+=(echo "Waiting $((timeout-SECONDS)) more seconds for $app_name to be STOPPED") + [[ "$verbose" == "true" ]] && echo_array+=("Waiting $((timeout-SECONDS)) more seconds for $app_name to be STOPPED") sleep 10 fi done fi else #user must not be using -S, just update - echo_array+=(echo -e "\n$app_name") - [[ "$verbose" == "true" ]] && echo_array+=(echo "Updating..") - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=(echo -e "Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo "FAILED" + echo_array+=("\n$app_name") + [[ "$verbose" == "true" ]] && echo_array+=("Updating..") + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=("Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo "FAILED" fi else - echo_array+=(echo -e "\n$app_name\nMajor Release, update manually") + echo_array+=("\n$app_name\nMajor Release, update manually") return fi From 3e125a009ef4b6eb081745b36606c49645b3df3e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 17:11:56 -0600 Subject: [PATCH 129/352] losing --- functions/update_apps.sh | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index a274a3b5..503ef0b3 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -62,7 +62,7 @@ printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name if [[ "$status" == "STOPPED" ]]; then echo_array+=("Stopped") [[ "$verbose" == "true" ]] && echo_array+=("Updating..") - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=("Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo "Failed to update" + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=("Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo_array+=("Failed to update") break elif [[ "$SECONDS" -ge "$timeout" ]]; then echo_array+=("Error: Run Time($SECONDS) has exceeded Timeout($timeout)") @@ -76,7 +76,7 @@ printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name else #user must not be using -S, just update echo_array+=("\n$app_name") [[ "$verbose" == "true" ]] && echo_array+=("Updating..") - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=("Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo "FAILED" + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=("Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo_array+=("FAILED") fi else echo_array+=("\n$app_name\nMajor Release, update manually") @@ -102,27 +102,27 @@ if [[ $rollback == "true" ]]; then (( count++ )) status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') if [[ "$status" == "ACTIVE" && "$startstatus" == "STOPPED" ]]; then - [[ "$verbose" == "true" ]] && echo "Returing to STOPPED state.." - midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && echo "Stopped"|| echo "FAILED" + [[ "$verbose" == "true" ]] && echo_array+=("Returing to STOPPED state..") + midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && echo_array+=("Stopped")|| echo_array+=("FAILED") break elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" && "$failed" != "true" ]]; then - echo -e "Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)\nIf this is a slow starting application, set a higher timeout with -t\nIf this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration\nReverting update.." + echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)\nIf this is a slow starting application, set a higher timeout with -t\nIf this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration\nReverting update..") midclt call chart.release.rollback "$app_name" "{\"item_version\": \"$rollback_version\"}" &> /dev/null [[ "$startstatus" == "STOPPED" ]] && failed="true" && after_update_actions && unset failed #run back after_update_actions function if the app was stopped prior to update break elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" && "$failed" == "true" ]]; then - echo -e "Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)\nThe application failed to be ACTIVE even after a rollback,\nManual intervention is required\nAbandoning" + echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)\nThe application failed to be ACTIVE even after a rollback,\nManual intervention is required\nAbandoning") break elif [[ "$status" == "STOPPED" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo "Verifying Stopped.." && sleep 15 && continue #if reports stopped on FIRST time through loop, double check + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 15 && continue #if reports stopped on FIRST time through loop, double check [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check - echo "Stopped" && break #if reports stopped any time after the first loop, assume its extermal services. + echo_array+=("Stopped") && break #if reports stopped any time after the first loop, assume its extermal services. elif [[ "$status" == "ACTIVE" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo "Verifying Active.." && sleep 15 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 15 && continue #if reports active on FIRST time through loop, double check [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check echo "Active" && break #if reports active any time after the first loop, assume actually active. else - [[ "$verbose" == "true" ]] && echo "Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE" + [[ "$verbose" == "true" ]] && echo_array+=("Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE") sleep 15 continue fi @@ -134,21 +134,21 @@ else (( count++ )) status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') if [[ "$status" == "STOPPED" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo "Verifying Stopped.." && sleep 15 && continue #if reports stopped on FIRST time through loop, double check + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 15 && continue #if reports stopped on FIRST time through loop, double check [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check - echo "Stopped" && break #assume actually stopped anytime AFTER the first loop + echo_array+=("Stopped") && break #assume actually stopped anytime AFTER the first loop break elif [[ "$status" == "ACTIVE" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo "Verifying Active.." && sleep 15 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 15 && continue #if reports active on FIRST time through loop, double check [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check - [[ "$verbose" == "true" ]] && echo "Returing to STOPPED state.." - midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && echo "Stopped"|| echo "FAILED" + [[ "$verbose" == "true" ]] && echo_array+=("Returing to STOPPED state..") + midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && echo_array+=("Stopped")|| echo_array+=("FAILED") break elif [[ "$SECONDS" -ge "$timeout" ]]; then - echo "Error: Run Time($SECONDS) has exceeded Timeout($timeout)" + echo_array+=("Error: Run Time($SECONDS) has exceeded Timeout($timeout)") break else - [[ "$verbose" == "true" ]] && echo "Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE" + [[ "$verbose" == "true" ]] && echo_array+=("Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE") sleep 10 continue fi From b0c122098b99eda6a519e5486a840fb1f6a72292 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 17:21:41 -0600 Subject: [PATCH 130/352] move dunmp to after action --- functions/update_apps.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 503ef0b3..dc13a2ff 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -83,11 +83,6 @@ printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name return fi -#dump array -for i in "${echo_array[@]}" -do - echo -e "$i" -done } export -f update_apps @@ -155,5 +150,13 @@ else done fi fi + +#dump array +for i in "${echo_array[@]}" +do + echo -e "$i" +done + + } export -f after_update_actions \ No newline at end of file From ee7608b1da88f6ad7f9e8c075ab88982a4618666 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 17:38:10 -0600 Subject: [PATCH 131/352] forgot echo --- functions/update_apps.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index dc13a2ff..ed1a11f2 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -115,7 +115,7 @@ if [[ $rollback == "true" ]]; then elif [[ "$status" == "ACTIVE" ]]; then [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 15 && continue #if reports active on FIRST time through loop, double check [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check - echo "Active" && break #if reports active any time after the first loop, assume actually active. + echo_array+=(echo "Active") && break #if reports active any time after the first loop, assume actually active. else [[ "$verbose" == "true" ]] && echo_array+=("Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE") sleep 15 @@ -151,7 +151,7 @@ else fi fi -#dump array +#Dump the echo_array, ensures all output is in a neat order. for i in "${echo_array[@]}" do echo -e "$i" From c13153959049d97b26585e0b738355fa3167da31 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 17:40:05 -0600 Subject: [PATCH 132/352] remove redun echo --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index ed1a11f2..df93a344 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -115,7 +115,7 @@ if [[ $rollback == "true" ]]; then elif [[ "$status" == "ACTIVE" ]]; then [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 15 && continue #if reports active on FIRST time through loop, double check [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check - echo_array+=(echo "Active") && break #if reports active any time after the first loop, assume actually active. + echo_array+=("Active") && break #if reports active any time after the first loop, assume actually active. else [[ "$verbose" == "true" ]] && echo_array+=("Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE") sleep 15 From 02aa8b6c22eb5ebb911a33f51fa3e495b453a0b3 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 17:45:35 -0600 Subject: [PATCH 133/352] enhance --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index df93a344..917fbfdf 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -14,7 +14,7 @@ while [[ $it -lt ${#array[@]} ]] do jobs=$(jobs -p | wc -l) if [[ "$jobs" -ge "$update_limit" ]]; then - sleep 3 + sleep 1 else update_apps "${array[$it]}" & processes+=($!) From 7f41fd1d8d50deaa6e06a6ddee22256e0550df7a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 21:47:14 -0600 Subject: [PATCH 134/352] test --- heavy_script.sh | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 905e50de..d0df8bed 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -52,10 +52,10 @@ do echo -e "Invalid Option \"-$OPTARG\"\n" && help exit ;; - :) - echo -e "Option: \"-$OPTARG\" requires an argument\n" && help - exit - ;; + # :) + # echo -e "Option: \"-$OPTARG\" requires an argument\n" && help + # exit + # ;; b) re='^[0-9]+$' number_of_backups=$OPTARG @@ -66,6 +66,7 @@ do rollback="true" ;; i) + [[ -z "$OPTARG" ]] && echo "\"-i\" requires an argument" && exit ignore+=("$OPTARG") ;; t) @@ -88,10 +89,6 @@ do p) prune="true" ;; - R) - rollback="true" - echo "WARNING: -R is being transisitioned to -r, this is due to a refactor in the script. Please Make the change ASAP!" - ;; v) verbose="true" ;; From 00e765a14d84ea41a3b94b37a0008370766712d1 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 21:49:47 -0600 Subject: [PATCH 135/352] test --- heavy_script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index d0df8bed..5ee2afcc 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -66,8 +66,8 @@ do rollback="true" ;; i) - [[ -z "$OPTARG" ]] && echo "\"-i\" requires an argument" && exit ignore+=("$OPTARG") + [[ -z "$ignore" ]] && echo "\"-i\" requires an argument" && exit ;; t) re='^[0-9]+$' @@ -93,7 +93,7 @@ do verbose="true" ;; *) - echo -e "Invalid Option \"--$OPTARG\"\n" && help + echo -e "Invalid Option \"-$OPTARG\"\n" && help exit ;; esac From eec9afa5dffdca56ead282df07d48fd9a7bb2282 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 21:55:46 -0600 Subject: [PATCH 136/352] test --- heavy_script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 5ee2afcc..1edaf814 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -19,7 +19,7 @@ source functions/update_apps.sh # Parse script options -while getopts ":si:rb:t:uUpSRv-:" opt +while getopts ":sii:rb:t:uUpSRv-:" opt do case $opt in -) @@ -67,7 +67,7 @@ do ;; i) ignore+=("$OPTARG") - [[ -z "$ignore" ]] && echo "\"-i\" requires an argument" && exit + [[ -z "$OPTARG" ]] && echo "\"-i\" requires an argument" && exit ;; t) re='^[0-9]+$' From 54dc8969e5afc7ea96cdc7d3ca37f4d63a3403e5 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 21:59:00 -0600 Subject: [PATCH 137/352] test --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 1edaf814..89eef577 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -67,7 +67,7 @@ do ;; i) ignore+=("$OPTARG") - [[ -z "$OPTARG" ]] && echo "\"-i\" requires an argument" && exit + [[ -z "$ignore" ]] && echo "\"-i\" requires an argument" && exit ;; t) re='^[0-9]+$' From b92627c77f45de4c9fcf836f760cb1faee8fff69 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 22:02:19 -0600 Subject: [PATCH 138/352] test --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 89eef577..5ee2afcc 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -19,7 +19,7 @@ source functions/update_apps.sh # Parse script options -while getopts ":sii:rb:t:uUpSRv-:" opt +while getopts ":si:rb:t:uUpSRv-:" opt do case $opt in -) From 0367588c65bea5d4f4be839e7149bd4fd4c52c23 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 22:05:55 -0600 Subject: [PATCH 139/352] test --- heavy_script.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 5ee2afcc..3c453ca6 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -48,10 +48,6 @@ do ;; esac ;; - \?) - echo -e "Invalid Option \"-$OPTARG\"\n" && help - exit - ;; # :) # echo -e "Option: \"-$OPTARG\" requires an argument\n" && help # exit @@ -92,6 +88,10 @@ do v) verbose="true" ;; + \?) + echo -e "Invalid Option \"-$OPTARG\"\n" && help + exit + ;; *) echo -e "Invalid Option \"-$OPTARG\"\n" && help exit From f468cfbd8227b021794134f76b4a973de7b466a3 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 22:11:51 -0600 Subject: [PATCH 140/352] test --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 3c453ca6..36e82e6f 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -19,7 +19,7 @@ source functions/update_apps.sh # Parse script options -while getopts ":si:rb:t:uUpSRv-:" opt +while getopts ":si::rb:t:uUpSRv-:" opt do case $opt in -) From 07be73ce57c42311cf26a520d9b2af598dbbe21b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 22:19:07 -0600 Subject: [PATCH 141/352] test --- heavy_script.sh | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 36e82e6f..4abeeccb 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -19,7 +19,7 @@ source functions/update_apps.sh # Parse script options -while getopts ":si::rb:t:uUpSRv-:" opt +while getopts ":sirb:t:uUpSRv-:" opt do case $opt in -) @@ -48,10 +48,10 @@ do ;; esac ;; - # :) - # echo -e "Option: \"-$OPTARG\" requires an argument\n" && help - # exit - # ;; + :) + echo -e "Option: \"-$OPTARG\" requires an argument\n" && help + exit + ;; b) re='^[0-9]+$' number_of_backups=$OPTARG @@ -62,8 +62,15 @@ do rollback="true" ;; i) - ignore+=("$OPTARG") - [[ -z "$ignore" ]] && echo "\"-i\" requires an argument" && exit + # Check next positional parameter + eval nextopt=${!OPTIND} + # existing or starting with dash? + if [[ -n $nextopt && $nextopt != -* ]] ; then + OPTIND=$((OPTIND + 1)) + ignore+=("$OPTARG") + else + echo "Option: \"-i\" requires an argument" + fi ;; t) re='^[0-9]+$' From 738765a5f6ee0608e010934804904e4e8e04951d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 22:20:06 -0600 Subject: [PATCH 142/352] forgot exit --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index 4abeeccb..c9ac1957 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -70,6 +70,7 @@ do ignore+=("$OPTARG") else echo "Option: \"-i\" requires an argument" + exit fi ;; t) From d71e2494229380d67ae22ab27ab88e44e8c30802 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 22:24:26 -0600 Subject: [PATCH 143/352] test --- functions/update_apps.sh | 2 +- heavy_script.sh | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 917fbfdf..a4a9d8a7 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -6,7 +6,7 @@ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_availabl [[ -z $array ]] && echo -e "\nThere are no updates available" && return 0 || echo -e "\n${#array[@]} update(s) available" [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" -update_limit=4 +echo "Asynchronous Updates: 1" it=0 diff --git a/heavy_script.sh b/heavy_script.sh index c9ac1957..0b1292c6 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -83,9 +83,27 @@ do ;; U) update_all_apps="true" + # Check next positional parameter + eval nextopt=${!OPTIND} + # existing or starting with dash? + if [[ -n $nextopt && $nextopt != -* ]] ; then + OPTIND=$((OPTIND + 1)) + update_limit=("$OPTARG") + else + update_limit=1 + fi ;; u) update_apps="true" + # Check next positional parameter + eval nextopt=${!OPTIND} + # existing or starting with dash? + if [[ -n $nextopt && $nextopt != -* ]] ; then + OPTIND=$((OPTIND + 1)) + update_limit=("$OPTARG") + else + update_limit=1 + fi ;; S) stop_before_update="true" From d511df4fb4d08f09dd0077579b5520ba5776c8e9 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 22:25:14 -0600 Subject: [PATCH 144/352] reporting --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index a4a9d8a7..55b772fc 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -6,7 +6,7 @@ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_availabl [[ -z $array ]] && echo -e "\nThere are no updates available" && return 0 || echo -e "\n${#array[@]} update(s) available" [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" -echo "Asynchronous Updates: 1" +echo "Asynchronous Updates: $update_limit" it=0 From 5b1b0a73d903d358b149a7d1b5613d6046b823ef Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 22:28:16 -0600 Subject: [PATCH 145/352] fix --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 0b1292c6..7f319681 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -100,7 +100,7 @@ do # existing or starting with dash? if [[ -n $nextopt && $nextopt != -* ]] ; then OPTIND=$((OPTIND + 1)) - update_limit=("$OPTARG") + update_limit=$OPTARG else update_limit=1 fi From c3fcc5a10d1ee50a7b5c3855e028fd1dd88549cc Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 22:34:07 -0600 Subject: [PATCH 146/352] hmm --- functions/update_apps.sh | 1 - heavy_script.sh | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 55b772fc..2dba0fab 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -9,7 +9,6 @@ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_availabl echo "Asynchronous Updates: $update_limit" it=0 - while [[ $it -lt ${#array[@]} ]] do jobs=$(jobs -p | wc -l) diff --git a/heavy_script.sh b/heavy_script.sh index 7f319681..82087420 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -88,7 +88,7 @@ do # existing or starting with dash? if [[ -n $nextopt && $nextopt != -* ]] ; then OPTIND=$((OPTIND + 1)) - update_limit=("$OPTARG") + update_limit="$OPTARG" else update_limit=1 fi @@ -100,7 +100,7 @@ do # existing or starting with dash? if [[ -n $nextopt && $nextopt != -* ]] ; then OPTIND=$((OPTIND + 1)) - update_limit=$OPTARG + update_limit="$OPTARG" else update_limit=1 fi From 3547a67f0193c9387a6b2935bc4bfda90d54cbb6 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 22:37:21 -0600 Subject: [PATCH 147/352] test --- heavy_script.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 82087420..29f90c3e 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -87,8 +87,8 @@ do eval nextopt=${!OPTIND} # existing or starting with dash? if [[ -n $nextopt && $nextopt != -* ]] ; then - OPTIND=$((OPTIND + 1)) - update_limit="$OPTARG" + OPTIND=$((OPTIND++)) + update_limit="$nextopt" else update_limit=1 fi @@ -99,8 +99,8 @@ do eval nextopt=${!OPTIND} # existing or starting with dash? if [[ -n $nextopt && $nextopt != -* ]] ; then - OPTIND=$((OPTIND + 1)) - update_limit="$OPTARG" + OPTIND=$((OPTIND++)) + update_limit="$nextopt" else update_limit=1 fi From 6c24507dd71274a7f06c56f819b3c65b61182f96 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 22:40:05 -0600 Subject: [PATCH 148/352] woo --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 29f90c3e..a452cbd8 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -67,7 +67,7 @@ do # existing or starting with dash? if [[ -n $nextopt && $nextopt != -* ]] ; then OPTIND=$((OPTIND + 1)) - ignore+=("$OPTARG") + ignore+=("$nextopt") else echo "Option: \"-i\" requires an argument" exit From dc083bf59f913e168ab4d042ba76fa9cdad59ab7 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 22:45:19 -0600 Subject: [PATCH 149/352] ignore return code --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 2dba0fab..81b3acd9 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -43,7 +43,7 @@ diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclatin old_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}') #Upgraded From new_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}') #Upraded To rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') -printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && return #If application is on ignore list, skip +printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && return 0 #If application is on ignore list, skip if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop From 118e921306682efb84ad6fc67b95de0bbed9126f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 22:47:08 -0600 Subject: [PATCH 150/352] uhh --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 81b3acd9..b712d348 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -43,7 +43,7 @@ diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclatin old_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}') #Upgraded From new_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}') #Upraded To rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') -printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && return 0 #If application is on ignore list, skip +printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && exit #If application is on ignore list, skip if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop From 11dfd4a1a7981e45a7c6461bd6a279aa9d53163e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 22:51:54 -0600 Subject: [PATCH 151/352] test --- functions/update_apps.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index b712d348..fff889fa 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -43,14 +43,14 @@ diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclatin old_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}') #Upgraded From new_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}') #Upraded To rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') -printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && exit #If application is on ignore list, skip +printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && return 1 #If application is on ignore list, skip if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop echo_array+=("\n$app_name") [[ "$verbose" == "true" ]] && echo_array+=("Updating..") cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=("Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo_array+=("FAILED") - return + return 0 else # if status was not STOPPED, stop the app prior to updating echo_array+=("\n$app_name") [[ "$verbose" == "true" ]] && echo_array+=("Stopping prior to update..") @@ -79,7 +79,7 @@ printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name fi else echo_array+=("\n$app_name\nMajor Release, update manually") - return + return 0 fi From 355ab29b0bfe4aac1565d35209ce88513593fd77 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 22:59:13 -0600 Subject: [PATCH 152/352] idk --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index fff889fa..997a2adb 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -32,6 +32,7 @@ export -f commander update_apps(){ app_name=$(echo "${array[$it]}" | awk -F ',' '{print $1}') #print out first catagory, name. +printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && return 0 #If application is on ignore list, skip old_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version new_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version old_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version @@ -43,7 +44,6 @@ diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclatin old_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}') #Upgraded From new_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}') #Upraded To rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') -printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && return 1 #If application is on ignore list, skip if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop From 0517819e654ae6422f83a2cffc973d25dfef5d5e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 23:01:40 -0600 Subject: [PATCH 153/352] sadf --- functions/update_apps.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 997a2adb..db9fb9a8 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -32,7 +32,13 @@ export -f commander update_apps(){ app_name=$(echo "${array[$it]}" | awk -F ',' '{print $1}') #print out first catagory, name. -printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && return 0 #If application is on ignore list, skip + +if printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" ; then + echo -e "\n$app_name\nIgnored, skipping" + return 0 #If application is on ignore list, skip + +fi + old_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version new_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version old_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version From 545f57b8e8fe5fc1f54662b6c0c3b1af7c2578e9 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 23:06:08 -0600 Subject: [PATCH 154/352] idk --- functions/update_apps.sh | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index db9fb9a8..cbf7193c 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -15,7 +15,7 @@ do if [[ "$jobs" -ge "$update_limit" ]]; then sleep 1 else - update_apps "${array[$it]}" & + { update_apps "${array[$it]}" ;} & processes+=($!) ((it++)) fi @@ -32,13 +32,7 @@ export -f commander update_apps(){ app_name=$(echo "${array[$it]}" | awk -F ',' '{print $1}') #print out first catagory, name. - -if printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" ; then - echo -e "\n$app_name\nIgnored, skipping" - return 0 #If application is on ignore list, skip - -fi - +printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && return 0 #If application is on ignore list, skip old_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version new_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version old_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version From 54ba3685c9448f43060175c1c02190bb2319aa30 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 23:12:36 -0600 Subject: [PATCH 155/352] testing --- functions/update_apps.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index cbf7193c..08d84581 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -15,9 +15,10 @@ do if [[ "$jobs" -ge "$update_limit" ]]; then sleep 1 else - { update_apps "${array[$it]}" ;} & + update_apps "${array[$it]}" & processes+=($!) ((it++)) + echo "$processes" fi done From 4cb021f97979a3c36378fbff64cdac3f7de74537 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 23:17:04 -0600 Subject: [PATCH 156/352] a --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 08d84581..e03aa7a3 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -33,7 +33,7 @@ export -f commander update_apps(){ app_name=$(echo "${array[$it]}" | awk -F ',' '{print $1}') #print out first catagory, name. -printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && return 0 #If application is on ignore list, skip +printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && disown && return 0 #If application is on ignore list, skip old_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version new_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version old_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version From 27b8d258cf85ec1ef6783a49018ee6368ebd7ba1 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 23:19:18 -0600 Subject: [PATCH 157/352] test --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index e03aa7a3..e4fbcc71 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -33,7 +33,7 @@ export -f commander update_apps(){ app_name=$(echo "${array[$it]}" | awk -F ',' '{print $1}') #print out first catagory, name. -printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && disown && return 0 #If application is on ignore list, skip +printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && exit 0 #If application is on ignore list, skip old_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version new_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version old_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version From 51eacf44a2653c6e62dd87397549437033cfabd1 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 23:38:29 -0600 Subject: [PATCH 158/352] test --- functions/update_apps.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index e4fbcc71..460e9169 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -11,14 +11,18 @@ echo "Asynchronous Updates: $update_limit" it=0 while [[ $it -lt ${#array[@]} ]] do - jobs=$(jobs -p | wc -l) - if [[ "$jobs" -ge "$update_limit" ]]; then + proc_count=${#processes[@]} + for proc in "${processes[@]}" + do + kill -0 "$proc" || ((proc_count--)) + done + #jobs=$(jobs -p | wc -l) + if [[ "$proc_count" -ge "$update_limit" ]]; then sleep 1 else update_apps "${array[$it]}" & processes+=($!) ((it++)) - echo "$processes" fi done @@ -33,7 +37,7 @@ export -f commander update_apps(){ app_name=$(echo "${array[$it]}" | awk -F ',' '{print $1}') #print out first catagory, name. -printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && exit 0 #If application is on ignore list, skip +printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && return 0 #If application is on ignore list, skip old_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version new_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version old_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version From a498bfe6cda96266a041967b67ec45f0cb0c78df Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 23:40:32 -0600 Subject: [PATCH 159/352] hide output --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 460e9169..427a131b 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -14,7 +14,7 @@ do proc_count=${#processes[@]} for proc in "${processes[@]}" do - kill -0 "$proc" || ((proc_count--)) + kill -0 "$proc" &> /dev/null || ((proc_count--)) done #jobs=$(jobs -p | wc -l) if [[ "$proc_count" -ge "$update_limit" ]]; then From 5889438cbdfab70e7ee220e9d23ae231f25c0a97 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 23:44:09 -0600 Subject: [PATCH 160/352] lop --- functions/update_apps.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 427a131b..94db2c24 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -12,9 +12,10 @@ it=0 while [[ $it -lt ${#array[@]} ]] do proc_count=${#processes[@]} + count=0 for proc in "${processes[@]}" do - kill -0 "$proc" &> /dev/null || ((proc_count--)) + kill -0 "$proc" &> /dev/null || { ((proc_count--)) ; unset "processes[$count]" ;} done #jobs=$(jobs -p | wc -l) if [[ "$proc_count" -ge "$update_limit" ]]; then From 2d0388d9b5d889e0a3778a18950a901c844e09bc Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 23:44:55 -0600 Subject: [PATCH 161/352] best --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 94db2c24..4664de1b 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -15,7 +15,7 @@ do count=0 for proc in "${processes[@]}" do - kill -0 "$proc" &> /dev/null || { ((proc_count--)) ; unset "processes[$count]" ;} + kill -0 "$proc" &> /dev/null || { unset "processes[$count]"; ((proc_count--)); } done #jobs=$(jobs -p | wc -l) if [[ "$proc_count" -ge "$update_limit" ]]; then From 682ead72a71ca5ca68d2ad34a4f4c01cfabdb097 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 23:53:45 -0600 Subject: [PATCH 162/352] ignore --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index a452cbd8..49786818 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -66,7 +66,7 @@ do eval nextopt=${!OPTIND} # existing or starting with dash? if [[ -n $nextopt && $nextopt != -* ]] ; then - OPTIND=$((OPTIND + 1)) + OPTIND=$((OPTIND++)) ignore+=("$nextopt") else echo "Option: \"-i\" requires an argument" From 0fde7bf999dff3705ff673ad9af93266c844e964 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 00:04:39 -0600 Subject: [PATCH 163/352] not sure --- heavy_script.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 49786818..5e82664f 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -66,7 +66,7 @@ do eval nextopt=${!OPTIND} # existing or starting with dash? if [[ -n $nextopt && $nextopt != -* ]] ; then - OPTIND=$((OPTIND++)) + OPTIND=$((OPTIND + 1)) ignore+=("$nextopt") else echo "Option: \"-i\" requires an argument" @@ -87,7 +87,7 @@ do eval nextopt=${!OPTIND} # existing or starting with dash? if [[ -n $nextopt && $nextopt != -* ]] ; then - OPTIND=$((OPTIND++)) + OPTIND=$((OPTIND + 1)) update_limit="$nextopt" else update_limit=1 @@ -99,7 +99,7 @@ do eval nextopt=${!OPTIND} # existing or starting with dash? if [[ -n $nextopt && $nextopt != -* ]] ; then - OPTIND=$((OPTIND++)) + OPTIND=$((OPTIND + 1)) update_limit="$nextopt" else update_limit=1 From 221e06317f6a1946bccc929c0ec22801589df634 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 00:23:27 -0600 Subject: [PATCH 164/352] sync and backup --- heavy_script.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 5e82664f..7015f348 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -136,7 +136,12 @@ done [[ "$dns" == "true" ]] && dns && exit [[ "$restore" == "true" ]] && restore && exit [[ "$mount" == "true" ]] && mount && exit -[[ "$number_of_backups" -ge 1 ]] && backup -[[ "$sync" == "true" ]] && sync +if [[ "$number_of_backups" -ge 1 && "$sync" == "true" ]]; then # Run backup and sync at the same time + backup & + sync & + wait +fi +[[ "$number_of_backups" -ge 1 && "$sync" == "false" ]] && backup +[[ "$sync" == "true" && "$number_of_backups" -le 1 ]] && sync [[ "$update_all_apps" == "true" || "$update_apps" == "true" ]] && commander [[ "$prune" == "true" ]] && prune \ No newline at end of file From 70109420c985eafd51acdc852e84a11c493ef78a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 00:32:37 -0600 Subject: [PATCH 165/352] more async --- functions/backup.sh | 16 +++++++++++----- functions/misc.sh | 8 +++++++- heavy_script.sh | 1 + 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index a4684ca1..58409915 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -2,21 +2,27 @@ backup(){ -echo -e "\nNumber of backups was set to $number_of_backups" +echo_backup+=("\nNumber of backups was set to $number_of_backups") date=$(date '+%Y_%m_%d_%H_%M_%S') [[ "$verbose" == "true" ]] && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' -[[ -z "$verbose" ]] && echo -e "\nNew Backup Name:" && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' | tail -n 1 +[[ -z "$verbose" ]] && echo_backup+=("\nNew Backup Name:") && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' | tail -n 1 mapfile -t list_backups < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r") if [[ ${#list_backups[@]} -gt "number_of_backups" ]]; then - echo -e "\nDeleting the oldest backup(s) for exceeding limit:" + echo_backup+=("\nDeleting the oldest backup(s) for exceeding limit:") overflow=$(( ${#list_backups[@]} - "$number_of_backups" )) mapfile -t list_overflow < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -V -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r" | head -n "$overflow") for i in "${list_overflow[@]}" do - cli -c 'app kubernetes delete_backup backup_name=''"'"$i"'"' &> /dev/null || echo "Failed to delete $i" - echo "$i" + cli -c 'app kubernetes delete_backup backup_name=''"'"$i"'"' &> /dev/null || echo_backup+=("Failed to delete $i") + echo_backup+=("$i") done fi + +#Dump the echo_array, ensures all output is in a neat order. +for i in "${echo_backup[@]}" +do + echo -e "$i" +done } export -f backup diff --git a/functions/misc.sh b/functions/misc.sh index f854381b..d0d9a410 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -2,7 +2,13 @@ sync(){ -echo -e "\nSyncing all catalogs, please wait.." && cli -c 'app catalog sync_all' &> /dev/null && echo -e "Catalog sync complete" +echo_sync+=("\nSyncing all catalogs, please wait..") && cli -c 'app catalog sync_all' &> /dev/null && echo_sync+=("Catalog sync complete") + +#Dump the echo_array, ensures all output is in a neat order. +for i in "${echo_sync[@]}" +do + echo -e "$i" +done } export -f sync diff --git a/heavy_script.sh b/heavy_script.sh index 7015f348..9e810ab6 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -137,6 +137,7 @@ done [[ "$restore" == "true" ]] && restore && exit [[ "$mount" == "true" ]] && mount && exit if [[ "$number_of_backups" -ge 1 && "$sync" == "true" ]]; then # Run backup and sync at the same time + echo "Backing up and syncing catalogs at the same time, please wait for output.." backup & sync & wait From 8456f40fd2651661e994fb41db6f01c73e60d6dc Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 00:39:25 -0600 Subject: [PATCH 166/352] output --- functions/backup.sh | 4 ++-- heavy_script.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index 58409915..03c0003b 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -4,8 +4,8 @@ backup(){ echo_backup+=("\nNumber of backups was set to $number_of_backups") date=$(date '+%Y_%m_%d_%H_%M_%S') -[[ "$verbose" == "true" ]] && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' -[[ -z "$verbose" ]] && echo_backup+=("\nNew Backup Name:") && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' | tail -n 1 +[[ "$verbose" == "true" ]] && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' &> /dev/null && echo_backup+=(HeavyScript_"$date") +[[ -z "$verbose" ]] && echo_backup+=("\nNew Backup Name:") && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' | tail -n 1 &> /dev/null && echo_backup+=(HeavyScript_"$date") mapfile -t list_backups < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r") if [[ ${#list_backups[@]} -gt "number_of_backups" ]]; then echo_backup+=("\nDeleting the oldest backup(s) for exceeding limit:") diff --git a/heavy_script.sh b/heavy_script.sh index 9e810ab6..ac01dbac 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -137,7 +137,7 @@ done [[ "$restore" == "true" ]] && restore && exit [[ "$mount" == "true" ]] && mount && exit if [[ "$number_of_backups" -ge 1 && "$sync" == "true" ]]; then # Run backup and sync at the same time - echo "Backing up and syncing catalogs at the same time, please wait for output.." + echo -e "Backing up and syncing catalogs at the same time, please wait for output..\n" backup & sync & wait From 88a655f9443650435b7922bd62eaa86bd72ec6f4 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 00:42:58 -0600 Subject: [PATCH 167/352] message --- heavy_script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index ac01dbac..72628b77 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -142,7 +142,7 @@ if [[ "$number_of_backups" -ge 1 && "$sync" == "true" ]]; then # Run backup and sync & wait fi -[[ "$number_of_backups" -ge 1 && "$sync" == "false" ]] && backup -[[ "$sync" == "true" && "$number_of_backups" -le 1 ]] && sync +[[ "$number_of_backups" -ge 1 && "$sync" == "false" ]] && echo "Please wait for output, this could take a while.." && backup +[[ "$sync" == "true" && "$number_of_backups" -le 1 ]] && echo "Please wait for output, this could take a while.." && sync [[ "$update_all_apps" == "true" || "$update_apps" == "true" ]] && commander [[ "$prune" == "true" ]] && prune \ No newline at end of file From f80be88a71ee52459ff25903fc7b9b89edb79303 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 00:53:53 -0600 Subject: [PATCH 168/352] lt instead of le --- heavy_script.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 72628b77..51c0c16a 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -143,6 +143,6 @@ if [[ "$number_of_backups" -ge 1 && "$sync" == "true" ]]; then # Run backup and wait fi [[ "$number_of_backups" -ge 1 && "$sync" == "false" ]] && echo "Please wait for output, this could take a while.." && backup -[[ "$sync" == "true" && "$number_of_backups" -le 1 ]] && echo "Please wait for output, this could take a while.." && sync +[[ "$sync" == "true" && "$number_of_backups" -lt 1 ]] && echo "Please wait for output, this could take a while.." && sync [[ "$update_all_apps" == "true" || "$update_apps" == "true" ]] && commander -[[ "$prune" == "true" ]] && prune \ No newline at end of file +[[ "$prune" == "true" ]] && prune From 3888aef71bf261d0f71ed7aa69dd134359d8cd61 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 13:08:33 -0600 Subject: [PATCH 169/352] menu --- functions/menu.sh | 56 +++++++++++++++++++++++++++++++++++++++++++++++ heavy_script.sh | 4 +++- 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 functions/menu.sh diff --git a/functions/menu.sh b/functions/menu.sh new file mode 100644 index 00000000..2dc39f69 --- /dev/null +++ b/functions/menu.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +menu(){ + echo "0 Help" + echo "1 List DNS Names" + echo "2 Mount and Unmount PVC storage" + echo "3 Create a Backup" + echo "4 Restore a Backup" + echo "5 Delete a Backup" + echo "6 Update All Apps" + read -rt 600 -p "Please select an option by number: " selection + + case $selection in + 0) + help="true" + ;; + 1) + dns="true" + ;; + 2) + mount="true" + ;; + 4) + read -rt 600 -p "Please type the max number of backups to keep: " number_of_backups + re='^[0-9]+$' + number_of_backups=$number_of_backups + ! [[ $number_of_backups =~ $re ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit + [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit + backup "$number_of_backups" + ;; + 5) + restore="true" + ;; + 6) + deleteBackup="true" + ;; + 9) + echo "" + echo "1 Update Apps Excluding likely breaking major changes" + echo "2 Update Apps Including likely breaking major changes" + read -rt 600 -p "Please select an option by number: " updateType + if [[ "$updateType" == "1" ]]; then + update_apps="true" + elif [[ "$updateType" == "2" ]]; then + update_all_apps="true" + else + echo "INVALID ENTRY" && exit 1 + fi + ;; + *) + echo "Unknown option" && exit 1 + ;; + esac + echo "" +} +export -f menu \ No newline at end of file diff --git a/heavy_script.sh b/heavy_script.sh index 72628b77..d136c8c8 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -1,13 +1,15 @@ #!/bin/bash #If no argument is passed, kill the script. -[[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && echo "This script requires an argument, use --help for help" && exit +[[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && menu # shellcheck source=functions/backup.sh source functions/backup.sh # shellcheck source=functions/dns.sh source functions/dns.sh +# shellcheck source=functions/menu.sh +source functions/menu.sh # shellcheck source=functions/misc.sh source functions/misc.sh # shellcheck source=functions/mount.sh From 7a4622b3e37d727722f9fe0d590ee6cbde72b465 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 13:10:09 -0600 Subject: [PATCH 170/352] re-arrange --- functions/menu.sh | 2 +- heavy_script.sh | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 2dc39f69..72e3df90 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -34,7 +34,7 @@ menu(){ 6) deleteBackup="true" ;; - 9) + 7) echo "" echo "1 Update Apps Excluding likely breaking major changes" echo "2 Update Apps Including likely breaking major changes" diff --git a/heavy_script.sh b/heavy_script.sh index 1428a86e..0977b086 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -1,9 +1,5 @@ #!/bin/bash -#If no argument is passed, kill the script. -[[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && menu - - # shellcheck source=functions/backup.sh source functions/backup.sh # shellcheck source=functions/dns.sh @@ -20,6 +16,10 @@ source functions/self_update.sh source functions/update_apps.sh +#If no argument is passed, kill the script. +[[ -z "$*" || "-" == "$*" || "--" == "$*" ]] && menu + + # Parse script options while getopts ":sirb:t:uUpSRv-:" opt do From 813396df2adf44a8f982985aa54de18e1c4c8bb3 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 13:11:14 -0600 Subject: [PATCH 171/352] number order --- functions/menu.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 72e3df90..8e127ca9 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -20,7 +20,7 @@ menu(){ 2) mount="true" ;; - 4) + 3) read -rt 600 -p "Please type the max number of backups to keep: " number_of_backups re='^[0-9]+$' number_of_backups=$number_of_backups @@ -28,13 +28,13 @@ menu(){ [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit backup "$number_of_backups" ;; - 5) + 4) restore="true" ;; - 6) + 5) deleteBackup="true" ;; - 7) + 6) echo "" echo "1 Update Apps Excluding likely breaking major changes" echo "2 Update Apps Including likely breaking major changes" From 064fecfb33fb533fe51e10762bc36eb09113e157 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 13:12:21 -0600 Subject: [PATCH 172/352] text --- functions/menu.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/menu.sh b/functions/menu.sh index 8e127ca9..c19d9eb1 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -26,6 +26,7 @@ menu(){ number_of_backups=$number_of_backups ! [[ $number_of_backups =~ $re ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit + echo "Generating backup, please be patient for output.." backup "$number_of_backups" ;; 4) From 08a86ad238658599ba9dbcf3ecbbf874dc2c86c6 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 13:15:49 -0600 Subject: [PATCH 173/352] title --- functions/menu.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/menu.sh b/functions/menu.sh index c19d9eb1..9b6cae17 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -1,6 +1,7 @@ #!/bin/bash menu(){ + title echo "0 Help" echo "1 List DNS Names" echo "2 Mount and Unmount PVC storage" From 5f31a134936cc10e8d36a49a8b33f590d3e4addc Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 13:16:15 -0600 Subject: [PATCH 174/352] clear --- functions/menu.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/menu.sh b/functions/menu.sh index 9b6cae17..9903aa33 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -1,6 +1,7 @@ #!/bin/bash menu(){ + clear -x title echo "0 Help" echo "1 List DNS Names" From 666c1e81682ced372d2b2c064620fa91ee9674a5 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 13:29:30 -0600 Subject: [PATCH 175/352] maybe --- functions/menu.sh | 34 +++++++++++++++++++++++----------- functions/misc.sh | 1 - 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 9903aa33..5a9aa0a6 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -38,17 +38,29 @@ menu(){ deleteBackup="true" ;; 6) - echo "" - echo "1 Update Apps Excluding likely breaking major changes" - echo "2 Update Apps Including likely breaking major changes" - read -rt 600 -p "Please select an option by number: " updateType - if [[ "$updateType" == "1" ]]; then - update_apps="true" - elif [[ "$updateType" == "2" ]]; then - update_all_apps="true" - else - echo "INVALID ENTRY" && exit 1 - fi + script=$(readlink -f "$0") + script_path=$(dirname "$script") + script_name="heavy_script.sh" + cd "$script_path" || exit + clear -x + echo "Choose your update options" + echo + echo "-U | Update all applications, ignores versions" + echo "-u | Update all applications, does not update Major releases" + echo "-b | Back-up your ix-applications dataset, specify a number after -b" + echo "-i | Add application to ignore list, one by one, see example below." + echo "-r | Roll-back applications if they fail to update" + echo "-S | Shutdown applications prior to updating" + echo "-v | verbose output" + echo "-t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" + echo "-s | sync catalog" + echo "-p | Prune unused/old docker images" + echo + echo "Example: -u 3 -b 14 -rSvsp -i nextcloud" + + read -rt 600 -p "Please type the flags you wish, with options above: " update_selection + exec bash "$script_name" "$update_selection" + ;; *) echo "Unknown option" && exit 1 diff --git a/functions/misc.sh b/functions/misc.sh index d0d9a410..8fcdbbed 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -43,7 +43,6 @@ echo "-U | Update all applications, ignores versions" echo "-u | Update all applications, does not update Major releases" echo "-b | Back-up your ix-applications dataset, specify a number after -b" echo "-i | Add application to ignore list, one by one, see example below." -echo "-R | THIS OPTION WILL DEPRICATE SOON, USE \"-r\" instead. Roll-back applications if they fail to update" echo "-r | Roll-back applications if they fail to update" echo "-S | Shutdown applications prior to updating" echo "-v | verbose output" From a04d928c1ceda320ce221c006e4e81c4b53b9e24 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 13:33:59 -0600 Subject: [PATCH 176/352] test --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index 5a9aa0a6..9b59e1ee 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -59,7 +59,7 @@ menu(){ echo "Example: -u 3 -b 14 -rSvsp -i nextcloud" read -rt 600 -p "Please type the flags you wish, with options above: " update_selection - exec bash "$script_name" "$update_selection" + exec bash "$script_name" "${update_selection[@]}" ;; *) From 15147eccc72c28d4f9e86d81c300da2818339d2d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 13:35:16 -0600 Subject: [PATCH 177/352] self update beta --- functions/self_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 340d5a5d..024630d1 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -9,7 +9,7 @@ script_name="heavy_script.sh" cd "$script_path" || exit git fetch &> /dev/null -if git diff --name-only origin/main | grep -q "$script_name" ; then +if git diff --name-only origin/beta | grep -q "$script_name" ; then echo "Found a new version of HeavyScript, updating myself..." git reset --hard -q git pull --force -q From 3c11bb4f54c170f2a7c56cadb146bbb778393669 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 13:35:52 -0600 Subject: [PATCH 178/352] test --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index 9b59e1ee..3198e7f7 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -43,7 +43,7 @@ menu(){ script_name="heavy_script.sh" cd "$script_path" || exit clear -x - echo "Choose your update options" + echo "Choose your update options " echo echo "-U | Update all applications, ignores versions" echo "-u | Update all applications, does not update Major releases" From 1e92da6db0a920992bafea06fadc55325157cedc Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 13:36:22 -0600 Subject: [PATCH 179/352] test --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 0977b086..fef23378 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -128,7 +128,7 @@ do done -#exit if incompatable functions are called +#exit if incompatable functions are called [[ "$update_all_apps" == "true" && "$update_apps" == "true" ]] && echo -e "-U and -u cannot BOTH be called" && exit #Continue to call functions in specific order From c52502a04d820d0f7a83905fae406e53bd044c08 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 13:37:38 -0600 Subject: [PATCH 180/352] test --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index fef23378..dcfcb1e0 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -144,7 +144,7 @@ if [[ "$number_of_backups" -ge 1 && "$sync" == "true" ]]; then # Run backup and sync & wait fi -[[ "$number_of_backups" -ge 1 && "$sync" == "false" ]] && echo "Please wait for output, this could take a while.." && backup +[[ "$number_of_backups" -ge 1 && -z "$sync" ]] && echo "Please wait for output, this could take a while.." && backup [[ "$sync" == "true" && "$number_of_backups" -lt 1 ]] && echo "Please wait for output, this could take a while.." && sync [[ "$update_all_apps" == "true" || "$update_apps" == "true" ]] && commander [[ "$prune" == "true" ]] && prune From e0fb20b14df9f24fe46a20bf7c0695c9bb8977e7 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 13:39:06 -0600 Subject: [PATCH 181/352] test --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index 3198e7f7..45ce389c 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -59,7 +59,7 @@ menu(){ echo "Example: -u 3 -b 14 -rSvsp -i nextcloud" read -rt 600 -p "Please type the flags you wish, with options above: " update_selection - exec bash "$script_name" "${update_selection[@]}" + exec bash "$script_name" $update_selection ;; *) From 702325b8c152a100c19bff1145314bbdb1ba6ba3 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 13:41:02 -0600 Subject: [PATCH 182/352] array --- functions/menu.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index 45ce389c..25b3e5af 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -59,7 +59,8 @@ menu(){ echo "Example: -u 3 -b 14 -rSvsp -i nextcloud" read -rt 600 -p "Please type the flags you wish, with options above: " update_selection - exec bash "$script_name" $update_selection + args=("$update_selection") + exec bash "$script_name" "${args[@]}" ;; *) From 48bb34fdfdc8993ee30912318ea2397359745324 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 13:49:58 -0600 Subject: [PATCH 183/352] test while --- functions/menu.sh | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 25b3e5af..1e178b3c 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -43,25 +43,32 @@ menu(){ script_name="heavy_script.sh" cd "$script_path" || exit clear -x + while true + do echo "Choose your update options " echo - echo "-U | Update all applications, ignores versions" - echo "-u | Update all applications, does not update Major releases" - echo "-b | Back-up your ix-applications dataset, specify a number after -b" - echo "-i | Add application to ignore list, one by one, see example below." - echo "-r | Roll-back applications if they fail to update" - echo "-S | Shutdown applications prior to updating" - echo "-v | verbose output" - echo "-t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" - echo "-s | sync catalog" - echo "-p | Prune unused/old docker images" + echo "1) -U | Update all applications, ignores versions" + echo "2) -u | Update all applications, does not update Major releases" + echo "3) -b | Back-up your ix-applications dataset, specify a number after -b" + echo "4) -i | Add application to ignore list, one by one, see example below." + echo "5) -r | Roll-back applications if they fail to update" + echo "6) -S | Shutdown applications prior to updating" + echo "7) -v | verbose output" + echo "8) -t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" + echo "9) -s | sync catalog" + echo "10) -p | Prune unused/old docker images" + echo + echo "0) Done making selections, proceed with update" echo - echo "Example: -u 3 -b 14 -rSvsp -i nextcloud" - read -rt 600 -p "Please type the flags you wish, with options above: " update_selection - args=("$update_selection") - exec bash "$script_name" "${args[@]}" + read -rt 600 -p "Please type the number associated with the flag above: " current_selection + if [[ $current_selection == 0 ]]; then + exec bash "$script_name" "${args[@]}" + else + update_selection+=("$current_selection") + fi + done ;; *) echo "Unknown option" && exit 1 From eab21168b3d8ebea5e5a50f6650ec3a99cd048c0 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 13:50:56 -0600 Subject: [PATCH 184/352] fix --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index 1e178b3c..76276bf7 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -63,7 +63,7 @@ menu(){ read -rt 600 -p "Please type the number associated with the flag above: " current_selection if [[ $current_selection == 0 ]]; then - exec bash "$script_name" "${args[@]}" + exec bash "$script_name" "${update_selection[@]}" else update_selection+=("$current_selection") From ad20acf844a17885353d8b2ac3fdf5bc9fab79fc Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 13:52:09 -0600 Subject: [PATCH 185/352] test --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index 76276bf7..7fef071d 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -64,7 +64,7 @@ menu(){ read -rt 600 -p "Please type the number associated with the flag above: " current_selection if [[ $current_selection == 0 ]]; then exec bash "$script_name" "${update_selection[@]}" - + exit else update_selection+=("$current_selection") fi From b37870370916efabe7a99623f3cbbb773c2cd528 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 14:04:31 -0600 Subject: [PATCH 186/352] test sloppy --- functions/menu.sh | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index 7fef071d..469cd581 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -66,7 +66,30 @@ menu(){ exec bash "$script_name" "${update_selection[@]}" exit else - update_selection+=("$current_selection") + if [[ $current_selection == 1 ]]; then + update_selection+=("-U") + elif [[ $current_selection == 2 ]]; then + update_selection+=("-u") + elif [[ $current_selection == 3 ]]; then + read -rt 600 -p "Up to how many backups should we keep?\n Please type an integer: " up_backups + update_selection+=("-b $up_backups") + elif [[ $current_selection == 4 ]]; then + read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore + update_selection+=("-i $up_ignore") + elif [[ $current_selection == 5 ]]; then + update_selection+=("-r") + elif [[ $current_selection == 6 ]]; then + update_selection+=("-S") + elif [[ $current_selection == 7 ]]; then + update_selection+=("-v") + elif [[ $current_selection == 8 ]]; then + read -rt 600 -p "What do you want your timeout to be?: " up_timeout + update_selection+=("-t $up_timeout") + elif [[ $current_selection == 9 ]]; then + update_selection+=("-s") + elif [[ $current_selection == 10 ]]; then + update_selection+=("-p") + fi fi done ;; From 9db9c1d4be88cf534357c93ba44f114b747485e6 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 14:07:04 -0600 Subject: [PATCH 187/352] test --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index 469cd581..8b60b7c4 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -75,7 +75,7 @@ menu(){ update_selection+=("-b $up_backups") elif [[ $current_selection == 4 ]]; then read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore - update_selection+=("-i $up_ignore") + update_selection+=("-i" "$up_ignore") elif [[ $current_selection == 5 ]]; then update_selection+=("-r") elif [[ $current_selection == 6 ]]; then From e3f8dc954217d8a522fcb65811df8821ce8c34ed Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 14:15:42 -0600 Subject: [PATCH 188/352] improved --- functions/menu.sh | 85 ++++++++++++++++++++++++++--------------------- 1 file changed, 47 insertions(+), 38 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 8b60b7c4..136da234 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -9,7 +9,7 @@ menu(){ echo "3 Create a Backup" echo "4 Restore a Backup" echo "5 Delete a Backup" - echo "6 Update All Apps" + echo "6 Update Applications" read -rt 600 -p "Please select an option by number: " selection case $selection in @@ -43,20 +43,35 @@ menu(){ script_name="heavy_script.sh" cd "$script_path" || exit clear -x - while true - do - echo "Choose your update options " - echo + + echo "What type of update would you like?" echo "1) -U | Update all applications, ignores versions" echo "2) -u | Update all applications, does not update Major releases" - echo "3) -b | Back-up your ix-applications dataset, specify a number after -b" - echo "4) -i | Add application to ignore list, one by one, see example below." - echo "5) -r | Roll-back applications if they fail to update" - echo "6) -S | Shutdown applications prior to updating" - echo "7) -v | verbose output" - echo "8) -t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" - echo "9) -s | sync catalog" - echo "10) -p | Prune unused/old docker images" + echo "0) Exit" + read -rt 600 -p "Please type the number associated with the flag above: " current_selection + if [[ $current_selection == 1 ]]; then + update_selection+=("-U") + elif [[ $current_selection == 2 ]]; then + update_selection+=("-u") + elif [[ $current_selection == 0 ]]; then + echo "Exiting.." + exit + else + echo "$current_selection was not an option, try again" + fi + while true + do + clear -x + echo "Choose your update options " + echo + echo "1) -b | Back-up your ix-applications dataset, specify a number after -b" + echo "2) -i | Add application to ignore list, one by one, see example below." + echo "3) -r | Roll-back applications if they fail to update" + echo "4) -S | Shutdown applications prior to updating" + echo "5) -v | verbose output" + echo "6) -t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" + echo "7) -s | sync catalog" + echo "8) -p | Prune unused/old docker images" echo echo "0) Done making selections, proceed with update" echo @@ -65,31 +80,25 @@ menu(){ if [[ $current_selection == 0 ]]; then exec bash "$script_name" "${update_selection[@]}" exit - else - if [[ $current_selection == 1 ]]; then - update_selection+=("-U") - elif [[ $current_selection == 2 ]]; then - update_selection+=("-u") - elif [[ $current_selection == 3 ]]; then - read -rt 600 -p "Up to how many backups should we keep?\n Please type an integer: " up_backups - update_selection+=("-b $up_backups") - elif [[ $current_selection == 4 ]]; then - read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore - update_selection+=("-i" "$up_ignore") - elif [[ $current_selection == 5 ]]; then - update_selection+=("-r") - elif [[ $current_selection == 6 ]]; then - update_selection+=("-S") - elif [[ $current_selection == 7 ]]; then - update_selection+=("-v") - elif [[ $current_selection == 8 ]]; then - read -rt 600 -p "What do you want your timeout to be?: " up_timeout - update_selection+=("-t $up_timeout") - elif [[ $current_selection == 9 ]]; then - update_selection+=("-s") - elif [[ $current_selection == 10 ]]; then - update_selection+=("-p") - fi + elif [[ $current_selection == 3 ]]; then + read -rt 600 -p "Up to how many backups should we keep?\n Please type an integer: " up_backups + update_selection+=("-b" "$up_backups") + elif [[ $current_selection == 4 ]]; then + read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore + update_selection+=("-i" "$up_ignore") + elif [[ $current_selection == 5 ]]; then + update_selection+=("-r") + elif [[ $current_selection == 6 ]]; then + update_selection+=("-S") + elif [[ $current_selection == 7 ]]; then + update_selection+=("-v") + elif [[ $current_selection == 8 ]]; then + read -rt 600 -p "What do you want your timeout to be?: " up_timeout + update_selection+=("-t" "$up_timeout") + elif [[ $current_selection == 9 ]]; then + update_selection+=("-s") + elif [[ $current_selection == 10 ]]; then + update_selection+=("-p") fi done ;; From ee366875809ef538f55a5447a65aa912aceab760 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 14:16:51 -0600 Subject: [PATCH 189/352] fix --- functions/menu.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 136da234..0f17f205 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -80,24 +80,24 @@ menu(){ if [[ $current_selection == 0 ]]; then exec bash "$script_name" "${update_selection[@]}" exit - elif [[ $current_selection == 3 ]]; then + elif [[ $current_selection == 1 ]]; then read -rt 600 -p "Up to how many backups should we keep?\n Please type an integer: " up_backups update_selection+=("-b" "$up_backups") - elif [[ $current_selection == 4 ]]; then + elif [[ $current_selection == 2 ]]; then read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore update_selection+=("-i" "$up_ignore") - elif [[ $current_selection == 5 ]]; then + elif [[ $current_selection == 3 ]]; then update_selection+=("-r") - elif [[ $current_selection == 6 ]]; then + elif [[ $current_selection == 4 ]]; then update_selection+=("-S") - elif [[ $current_selection == 7 ]]; then + elif [[ $current_selection == 5 ]]; then update_selection+=("-v") - elif [[ $current_selection == 8 ]]; then + elif [[ $current_selection == 6 ]]; then read -rt 600 -p "What do you want your timeout to be?: " up_timeout update_selection+=("-t" "$up_timeout") - elif [[ $current_selection == 9 ]]; then + elif [[ $current_selection == 7 ]]; then update_selection+=("-s") - elif [[ $current_selection == 10 ]]; then + elif [[ $current_selection == 8 ]]; then update_selection+=("-p") fi done From c60b8d168bbbd2ffa1aa8c3b8d8b8dc5b1e66a07 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 14:26:19 -0600 Subject: [PATCH 190/352] async in menu --- functions/menu.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 0f17f205..a92b6660 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -50,9 +50,11 @@ menu(){ echo "0) Exit" read -rt 600 -p "Please type the number associated with the flag above: " current_selection if [[ $current_selection == 1 ]]; then - update_selection+=("-U") - elif [[ $current_selection == 2 ]]; then - update_selection+=("-u") + read -rt 600 -p "How many applications do you want updating at the same time?\n Please type an integer: " up_async + update_selection+=("-U" "$up_async") + elif [[ $current_selection == 2 ]]; then + read -rt 600 -p "How many applications do you want updating at the same time?\n Please type an integer: " up_async + update_selection+=("-u" "$up_async") elif [[ $current_selection == 0 ]]; then echo "Exiting.." exit From 36aa0cfec37e01b4784c35216abf754ae51251e1 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 14:29:59 -0600 Subject: [PATCH 191/352] fixes --- functions/menu.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index a92b6660..1cfa8148 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -47,13 +47,16 @@ menu(){ echo "What type of update would you like?" echo "1) -U | Update all applications, ignores versions" echo "2) -u | Update all applications, does not update Major releases" + echo echo "0) Exit" read -rt 600 -p "Please type the number associated with the flag above: " current_selection if [[ $current_selection == 1 ]]; then - read -rt 600 -p "How many applications do you want updating at the same time?\n Please type an integer: " up_async + echo "How many applications do you want updating at the same time?" + read -rt 600 -p "Please type an integer greater than 0: " up_async update_selection+=("-U" "$up_async") elif [[ $current_selection == 2 ]]; then - read -rt 600 -p "How many applications do you want updating at the same time?\n Please type an integer: " up_async + echo "How many applications do you want updating at the same time?" + read -rt 600 -p "Please type an integer greater than 0: " up_async update_selection+=("-u" "$up_async") elif [[ $current_selection == 0 ]]; then echo "Exiting.." From 09acdf6ac26860ffdae0e5816a88dbbb57bca85e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 14:30:41 -0600 Subject: [PATCH 192/352] exit --- functions/menu.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/menu.sh b/functions/menu.sh index 1cfa8148..d8f65618 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -63,6 +63,7 @@ menu(){ exit else echo "$current_selection was not an option, try again" + exit fi while true do From 218ff297fceed85fd741d606bc3b783120207f46 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 14:31:30 -0600 Subject: [PATCH 193/352] title of course --- functions/menu.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index d8f65618..574e1c16 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -43,7 +43,7 @@ menu(){ script_name="heavy_script.sh" cd "$script_path" || exit clear -x - + title echo "What type of update would you like?" echo "1) -U | Update all applications, ignores versions" echo "2) -u | Update all applications, does not update Major releases" @@ -68,6 +68,7 @@ menu(){ while true do clear -x + title echo "Choose your update options " echo echo "1) -b | Back-up your ix-applications dataset, specify a number after -b" From d46a128fcd061586e5b2a927acd4e72f0f369d79 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 14:32:21 -0600 Subject: [PATCH 194/352] newlines --- functions/menu.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 574e1c16..a2c247bd 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -51,11 +51,11 @@ menu(){ echo "0) Exit" read -rt 600 -p "Please type the number associated with the flag above: " current_selection if [[ $current_selection == 1 ]]; then - echo "How many applications do you want updating at the same time?" + echo -e "\nHow many applications do you want updating at the same time?" read -rt 600 -p "Please type an integer greater than 0: " up_async update_selection+=("-U" "$up_async") elif [[ $current_selection == 2 ]]; then - echo "How many applications do you want updating at the same time?" + echo -e "\nHow many applications do you want updating at the same time?" read -rt 600 -p "Please type an integer greater than 0: " up_async update_selection+=("-u" "$up_async") elif [[ $current_selection == 0 ]]; then From 3f939f6b1e7229247d8c258513702eb2cc2872cf Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 14:35:25 -0600 Subject: [PATCH 195/352] polish --- functions/menu.sh | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index a2c247bd..5695a4f6 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -3,26 +3,27 @@ menu(){ clear -x title - echo "0 Help" - echo "1 List DNS Names" - echo "2 Mount and Unmount PVC storage" - echo "3 Create a Backup" - echo "4 Restore a Backup" - echo "5 Delete a Backup" - echo "6 Update Applications" + echo "1 Help" + echo "2 List DNS Names" + echo "3 Mount and Unmount PVC storage" + echo "4 Create a Backup" + echo "5 Restore a Backup" + echo "6 Delete a Backup" + echo "7 Update HeavyScript" + echo "8 Update Applications" read -rt 600 -p "Please select an option by number: " selection case $selection in - 0) + 1) help="true" ;; - 1) + 2) dns="true" ;; - 2) + 3) mount="true" ;; - 3) + 4) read -rt 600 -p "Please type the max number of backups to keep: " number_of_backups re='^[0-9]+$' number_of_backups=$number_of_backups @@ -31,13 +32,16 @@ menu(){ echo "Generating backup, please be patient for output.." backup "$number_of_backups" ;; - 4) + 5) restore="true" ;; - 5) + 6) deleteBackup="true" ;; - 6) + 7) + self_update="true" + ;; + 8) script=$(readlink -f "$0") script_path=$(dirname "$script") script_name="heavy_script.sh" From 07058f5a0bf1520b8f68cc8d13e5bef7231199cb Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 14:36:48 -0600 Subject: [PATCH 196/352] exit --- functions/menu.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/functions/menu.sh b/functions/menu.sh index 5695a4f6..5910f92e 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -11,9 +11,14 @@ menu(){ echo "6 Delete a Backup" echo "7 Update HeavyScript" echo "8 Update Applications" + echo + echo "0 Exit" read -rt 600 -p "Please select an option by number: " selection case $selection in + 0) + exit + ;; 1) help="true" ;; From 064e90a44c37c3ec719fcb7fe7ea798bc90c44ac Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 14:37:46 -0600 Subject: [PATCH 197/352] more polishing --- functions/menu.sh | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 5910f92e..20fbc2ec 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -3,16 +3,16 @@ menu(){ clear -x title - echo "1 Help" - echo "2 List DNS Names" - echo "3 Mount and Unmount PVC storage" - echo "4 Create a Backup" - echo "5 Restore a Backup" - echo "6 Delete a Backup" - echo "7 Update HeavyScript" - echo "8 Update Applications" + echo "1) Help" + echo "2) List DNS Names" + echo "3) Mount and Unmount PVC storage" + echo "4) Create a Backup" + echo "5) Restore a Backup" + echo "6) Delete a Backup" + echo "7) Update HeavyScript" + echo "8) Update Applications" echo - echo "0 Exit" + echo "0) Exit" read -rt 600 -p "Please select an option by number: " selection case $selection in @@ -58,6 +58,7 @@ menu(){ echo "2) -u | Update all applications, does not update Major releases" echo echo "0) Exit" + echo read -rt 600 -p "Please type the number associated with the flag above: " current_selection if [[ $current_selection == 1 ]]; then echo -e "\nHow many applications do you want updating at the same time?" From 15697089988cd0de4516b73d6edeba1f8fb81bbe Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 14:43:02 -0600 Subject: [PATCH 198/352] ez --- functions/menu.sh | 83 ++++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 41 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 20fbc2ec..4c65a68e 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -53,7 +53,7 @@ menu(){ cd "$script_path" || exit clear -x title - echo "What type of update would you like?" + echo "--Choose your update type--" echo "1) -U | Update all applications, ignores versions" echo "2) -u | Update all applications, does not update Major releases" echo @@ -77,46 +77,47 @@ menu(){ fi while true do - clear -x - title - echo "Choose your update options " - echo - echo "1) -b | Back-up your ix-applications dataset, specify a number after -b" - echo "2) -i | Add application to ignore list, one by one, see example below." - echo "3) -r | Roll-back applications if they fail to update" - echo "4) -S | Shutdown applications prior to updating" - echo "5) -v | verbose output" - echo "6) -t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" - echo "7) -s | sync catalog" - echo "8) -p | Prune unused/old docker images" - echo - echo "0) Done making selections, proceed with update" - echo - - read -rt 600 -p "Please type the number associated with the flag above: " current_selection - if [[ $current_selection == 0 ]]; then - exec bash "$script_name" "${update_selection[@]}" - exit - elif [[ $current_selection == 1 ]]; then - read -rt 600 -p "Up to how many backups should we keep?\n Please type an integer: " up_backups - update_selection+=("-b" "$up_backups") - elif [[ $current_selection == 2 ]]; then - read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore - update_selection+=("-i" "$up_ignore") - elif [[ $current_selection == 3 ]]; then - update_selection+=("-r") - elif [[ $current_selection == 4 ]]; then - update_selection+=("-S") - elif [[ $current_selection == 5 ]]; then - update_selection+=("-v") - elif [[ $current_selection == 6 ]]; then - read -rt 600 -p "What do you want your timeout to be?: " up_timeout - update_selection+=("-t" "$up_timeout") - elif [[ $current_selection == 7 ]]; then - update_selection+=("-s") - elif [[ $current_selection == 8 ]]; then - update_selection+=("-p") - fi + clear -x + title + echo "--Choose your update options--" + echo + echo "1) -b | Back-up your ix-applications dataset, specify a number after -b" + echo "2) -i | Add application to ignore list, one by one, see example below." + echo "3) -r | Roll-back applications if they fail to update" + echo "4) -S | Shutdown applications prior to updating" + echo "5) -v | verbose output" + echo "6) -t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" + echo "7) -s | sync catalog" + echo "8) -p | Prune unused/old docker images" + echo + echo "0) Done making selections, proceed with update" + echo + read -rt 600 -p "Please type the number associated with the flag above: " current_selection + if [[ $current_selection == 0 ]]; then + exec bash "$script_name" "${update_selection[@]}" + exit + elif [[ $current_selection == 1 ]]; then + echo "Up to how many backups should we keep?" + read -rt 600 -p "Please type an integer: " up_backups + update_selection+=("-b" "$up_backups") + elif [[ $current_selection == 2 ]]; then + read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore + update_selection+=("-i" "$up_ignore") + elif [[ $current_selection == 3 ]]; then + update_selection+=("-r") + elif [[ $current_selection == 4 ]]; then + update_selection+=("-S") + elif [[ $current_selection == 5 ]]; then + update_selection+=("-v") + elif [[ $current_selection == 6 ]]; then + echo "What do you want your timeout to be?" + read -rt 600 -p "Please type an integer: " up_timeout + update_selection+=("-t" "$up_timeout") + elif [[ $current_selection == 7 ]]; then + update_selection+=("-s") + elif [[ $current_selection == 8 ]]; then + update_selection+=("-p") + fi done ;; *) From 340b5b7e6dd2cd9ac27f4afeb8592cddd39d7471 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 14:44:29 -0600 Subject: [PATCH 199/352] formatting --- functions/menu.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 4c65a68e..bc79d7b8 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -53,7 +53,8 @@ menu(){ cd "$script_path" || exit clear -x title - echo "--Choose your update type--" + echo "Choose your update type" + echo "_______________________" echo "1) -U | Update all applications, ignores versions" echo "2) -u | Update all applications, does not update Major releases" echo @@ -79,8 +80,8 @@ menu(){ do clear -x title - echo "--Choose your update options--" - echo + echo "Choose your update options" + echo "__________________________" echo "1) -b | Back-up your ix-applications dataset, specify a number after -b" echo "2) -i | Add application to ignore list, one by one, see example below." echo "3) -r | Roll-back applications if they fail to update" From 1b329c0661548a7733fdbebcb89f1519b4da7265 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 15:02:20 -0600 Subject: [PATCH 200/352] null --- heavy_script.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/heavy_script.sh b/heavy_script.sh index dcfcb1e0..28f111fb 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -128,6 +128,7 @@ do done + #exit if incompatable functions are called [[ "$update_all_apps" == "true" && "$update_apps" == "true" ]] && echo -e "-U and -u cannot BOTH be called" && exit From a748bb3fa5c1b1fe40ec0d603191b94538b11c09 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 15:06:30 -0600 Subject: [PATCH 201/352] version --- heavy_script.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/heavy_script.sh b/heavy_script.sh index 28f111fb..9708cf1f 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -1,5 +1,7 @@ #!/bin/bash +# Version 0.1 + # shellcheck source=functions/backup.sh source functions/backup.sh # shellcheck source=functions/dns.sh From 2e06b25dd62fd3f0934b5ef55ed88b3eaf1d7583 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 16:21:03 -0600 Subject: [PATCH 202/352] else statement --- functions/menu.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index bc79d7b8..ec2e57c9 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -117,7 +117,9 @@ menu(){ elif [[ $current_selection == 7 ]]; then update_selection+=("-s") elif [[ $current_selection == 8 ]]; then - update_selection+=("-p") + update_selection+=("-p") + else + echo "$current_selection was not an option, try again" fi done ;; From c9db9cfc3e2cdcaf4b1b0d441b5bd5f753b22a33 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 16:21:41 -0600 Subject: [PATCH 203/352] test self --- functions/self_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 024630d1..34319a4f 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -9,7 +9,7 @@ script_name="heavy_script.sh" cd "$script_path" || exit git fetch &> /dev/null -if git diff --name-only origin/beta | grep -q "$script_name" ; then +if git diff --name-only origin/beta ; then #| grep -q "$script_name" echo "Found a new version of HeavyScript, updating myself..." git reset --hard -q git pull --force -q From 5e6f6a7ea070f0d5b7829e59f92879d07935c269 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 16:23:41 -0600 Subject: [PATCH 204/352] test --- functions/self_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 34319a4f..197e5440 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -9,7 +9,7 @@ script_name="heavy_script.sh" cd "$script_path" || exit git fetch &> /dev/null -if git diff --name-only origin/beta ; then #| grep -q "$script_name" +if git diff --name-only origin/beta | grep -eq ".sh" ; then echo "Found a new version of HeavyScript, updating myself..." git reset --hard -q git pull --force -q From f907cf746a30d4f6f3db29076d90b58917e31176 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 16:24:22 -0600 Subject: [PATCH 205/352] quiet? --- functions/self_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 197e5440..c52875f5 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -9,7 +9,7 @@ script_name="heavy_script.sh" cd "$script_path" || exit git fetch &> /dev/null -if git diff --name-only origin/beta | grep -eq ".sh" ; then +if git diff --name-only origin/beta | grep -e -q ".sh" ; then echo "Found a new version of HeavyScript, updating myself..." git reset --hard -q git pull --force -q From f11e0a4fa74e61104fbfed7579f4810fabbec285 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 16:25:38 -0600 Subject: [PATCH 206/352] asd --- functions/self_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index c52875f5..93543752 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -9,7 +9,7 @@ script_name="heavy_script.sh" cd "$script_path" || exit git fetch &> /dev/null -if git diff --name-only origin/beta | grep -e -q ".sh" ; then +if git diff --name-only origin/beta | grep -qs ".sh" ; then echo "Found a new version of HeavyScript, updating myself..." git reset --hard -q git pull --force -q From 47aaaac2729a2aed0112cd5828c38820ce48e7da Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 16:26:07 -0600 Subject: [PATCH 207/352] asd --- functions/self_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 93543752..b3678e2a 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -8,7 +8,7 @@ script_path=$(dirname "$script") script_name="heavy_script.sh" cd "$script_path" || exit git fetch &> /dev/null - +#update if git diff --name-only origin/beta | grep -qs ".sh" ; then echo "Found a new version of HeavyScript, updating myself..." git reset --hard -q From 929360806e973763266896b60a612d09023ea0b5 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 16:26:43 -0600 Subject: [PATCH 208/352] test --- functions/self_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index b3678e2a..93543752 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -8,7 +8,7 @@ script_path=$(dirname "$script") script_name="heavy_script.sh" cd "$script_path" || exit git fetch &> /dev/null -#update + if git diff --name-only origin/beta | grep -qs ".sh" ; then echo "Found a new version of HeavyScript, updating myself..." git reset --hard -q From 7845b76d2b0274781b73a5dbc77425be3f4d95d0 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 16:27:20 -0600 Subject: [PATCH 209/352] test --- heavy_script.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 9708cf1f..4009f53c 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -1,6 +1,5 @@ #!/bin/bash -# Version 0.1 # shellcheck source=functions/backup.sh source functions/backup.sh From 9df82d6cc995ece1d0ffa1b3d0ead11099a99188 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 16:28:35 -0600 Subject: [PATCH 210/352] format --- functions/menu.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index ec2e57c9..712d580a 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -53,8 +53,8 @@ menu(){ cd "$script_path" || exit clear -x title - echo "Choose your update type" - echo "_______________________" + echo "Choose Your Update Type" + echo "-----------------------" echo "1) -U | Update all applications, ignores versions" echo "2) -u | Update all applications, does not update Major releases" echo @@ -81,7 +81,7 @@ menu(){ clear -x title echo "Choose your update options" - echo "__________________________" + echo "--------------------------" echo "1) -b | Back-up your ix-applications dataset, specify a number after -b" echo "2) -i | Add application to ignore list, one by one, see example below." echo "3) -r | Roll-back applications if they fail to update" From 8a2fd2a976c23c8fef70164d344f0f4c502dde71 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 16:35:31 -0600 Subject: [PATCH 211/352] regex --- functions/menu.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 712d580a..aa024a84 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -64,11 +64,9 @@ menu(){ if [[ $current_selection == 1 ]]; then echo -e "\nHow many applications do you want updating at the same time?" read -rt 600 -p "Please type an integer greater than 0: " up_async - update_selection+=("-U" "$up_async") elif [[ $current_selection == 2 ]]; then echo -e "\nHow many applications do you want updating at the same time?" - read -rt 600 -p "Please type an integer greater than 0: " up_async - update_selection+=("-u" "$up_async") + read -rt 600 -p "Please type an integer greater than 0: " up_async elif [[ $current_selection == 0 ]]; then echo "Exiting.." exit @@ -76,6 +74,15 @@ menu(){ echo "$current_selection was not an option, try again" exit fi + if [[ $up_async == 0 ]]; then + echo "0 was not an option.. exiting" + exit + elif ! [[ $up_async =~ ^[0-9]+$ ]]; then + echo "Error: $up_async is invalid, it needs to be an integer" + exit + else + update_selection+=("-u" "$up_async") + fi while true do clear -x From c44e09e300b06cce7cc19d3e1a27ea8bcf4484ed Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 16:36:16 -0600 Subject: [PATCH 212/352] quotation --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index aa024a84..ba34ac0d 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -78,7 +78,7 @@ menu(){ echo "0 was not an option.. exiting" exit elif ! [[ $up_async =~ ^[0-9]+$ ]]; then - echo "Error: $up_async is invalid, it needs to be an integer" + echo "Error: \"$up_async\" is invalid, it needs to be an integer" exit else update_selection+=("-u" "$up_async") From dd14c6665c179f60a4b15dc84ae36409ad324251 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 16:45:52 -0600 Subject: [PATCH 213/352] input validation --- functions/menu.sh | 5 +++-- heavy_script.sh | 6 ++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index ba34ac0d..90ba29dc 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -30,9 +30,8 @@ menu(){ ;; 4) read -rt 600 -p "Please type the max number of backups to keep: " number_of_backups - re='^[0-9]+$' number_of_backups=$number_of_backups - ! [[ $number_of_backups =~ $re ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit + ! [[ $number_of_backups =~ ^[0-9]+$ ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit echo "Generating backup, please be patient for output.." backup "$number_of_backups" @@ -107,6 +106,7 @@ menu(){ elif [[ $current_selection == 1 ]]; then echo "Up to how many backups should we keep?" read -rt 600 -p "Please type an integer: " up_backups + ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue update_selection+=("-b" "$up_backups") elif [[ $current_selection == 2 ]]; then read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore @@ -120,6 +120,7 @@ menu(){ elif [[ $current_selection == 6 ]]; then echo "What do you want your timeout to be?" read -rt 600 -p "Please type an integer: " up_timeout + ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue update_selection+=("-t" "$up_timeout") elif [[ $current_selection == 7 ]]; then update_selection+=("-s") diff --git a/heavy_script.sh b/heavy_script.sh index 4009f53c..7dff535c 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -56,9 +56,8 @@ do exit ;; b) - re='^[0-9]+$' number_of_backups=$OPTARG - ! [[ $OPTARG =~ $re ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit + ! [[ $OPTARG =~ ^[0-9]+$ ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit ;; r) @@ -77,9 +76,8 @@ do fi ;; t) - re='^[0-9]+$' timeout=$OPTARG - ! [[ $timeout =~ $re ]] && echo -e "Error: -t needs to be assigned an interger\n\"""$timeout""\" is not an interger" >&2 && exit + ! [[ $timeout =~ ^[0-9]+$ ]] && echo -e "Error: -t needs to be assigned an interger\n\"""$timeout""\" is not an interger" >&2 && exit ;; s) sync="true" From cdf7bf640152615c820d2b647ec8cd063d4eafe4 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 16:49:23 -0600 Subject: [PATCH 214/352] check for 0 backups --- functions/menu.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/menu.sh b/functions/menu.sh index 90ba29dc..7821c7aa 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -107,6 +107,7 @@ menu(){ echo "Up to how many backups should we keep?" read -rt 600 -p "Please type an integer: " up_backups ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue + [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 5 && continue update_selection+=("-b" "$up_backups") elif [[ $current_selection == 2 ]]; then read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore From b286877af0d4b2eb8d7f32139d4f296882926b3d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 16:52:32 -0600 Subject: [PATCH 215/352] print current selection --- functions/menu.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/functions/menu.sh b/functions/menu.sh index 7821c7aa..35ae5f4d 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -100,6 +100,11 @@ menu(){ echo "0) Done making selections, proceed with update" echo read -rt 600 -p "Please type the number associated with the flag above: " current_selection + + for i in "${current_selection[@]}" + do + echo "$i" + done if [[ $current_selection == 0 ]]; then exec bash "$script_name" "${update_selection[@]}" exit From 366fbb089821dd36e109ca544e6aabba03e02965 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 16:54:46 -0600 Subject: [PATCH 216/352] fix --- functions/menu.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 35ae5f4d..304c2cd1 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -101,7 +101,7 @@ menu(){ echo read -rt 600 -p "Please type the number associated with the flag above: " current_selection - for i in "${current_selection[@]}" + for i in "${update_selection[@]}" do echo "$i" done @@ -133,7 +133,7 @@ menu(){ elif [[ $current_selection == 8 ]]; then update_selection+=("-p") else - echo "$current_selection was not an option, try again" + echo "$current_selection was not an option, try again" && sleep 5 && continue fi done ;; From 194500bbf0a3fbb637470cf6a8bfb7df9e7c376c Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 17:01:00 -0600 Subject: [PATCH 217/352] test --- functions/menu.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 304c2cd1..d6296e10 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -99,12 +99,15 @@ menu(){ echo echo "0) Done making selections, proceed with update" echo - read -rt 600 -p "Please type the number associated with the flag above: " current_selection - + echo "Current Choices" + echo "---------------" for i in "${update_selection[@]}" do echo "$i" done + read -rt 600 -p "Please type the number associated with the flag above: " current_selection + + if [[ $current_selection == 0 ]]; then exec bash "$script_name" "${update_selection[@]}" exit From e965e5c3cdd9cf663ddbbcfeadc3ac880a693d1a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 17:04:39 -0600 Subject: [PATCH 218/352] new list array --- functions/menu.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index d6296e10..ffb3790d 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -101,10 +101,11 @@ menu(){ echo echo "Current Choices" echo "---------------" - for i in "${update_selection[@]}" + for i in "${update_list[@]}" do echo "$i" done + echo read -rt 600 -p "Please type the number associated with the flag above: " current_selection @@ -116,24 +117,32 @@ menu(){ read -rt 600 -p "Please type an integer: " up_backups ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 5 && continue + update_list+=("-b $up_backups") update_selection+=("-b" "$up_backups") elif [[ $current_selection == 2 ]]; then read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore + update_list+=("-b $up_ignore") update_selection+=("-i" "$up_ignore") elif [[ $current_selection == 3 ]]; then + update_list+=("-r") update_selection+=("-r") elif [[ $current_selection == 4 ]]; then + update_list+=("-S") update_selection+=("-S") elif [[ $current_selection == 5 ]]; then + update_list+=("-v") update_selection+=("-v") elif [[ $current_selection == 6 ]]; then echo "What do you want your timeout to be?" read -rt 600 -p "Please type an integer: " up_timeout ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue + update_list+=("-t $up_timeout") update_selection+=("-t" "$up_timeout") elif [[ $current_selection == 7 ]]; then + update_list+=("-s") update_selection+=("-s") elif [[ $current_selection == 8 ]]; then + update_list+=("-p") update_selection+=("-p") else echo "$current_selection was not an option, try again" && sleep 5 && continue From 0fb6383ce5d10b2973cc62e4a1f8dc4c3e25087d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 17:07:01 -0600 Subject: [PATCH 219/352] test --- functions/menu.sh | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index ffb3790d..9c25d271 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -81,6 +81,7 @@ menu(){ exit else update_selection+=("-u" "$up_async") + update_list+=("-u") fi while true do @@ -101,14 +102,10 @@ menu(){ echo echo "Current Choices" echo "---------------" - for i in "${update_list[@]}" - do - echo "$i" - done + echo "${update_list[*]}" echo read -rt 600 -p "Please type the number associated with the flag above: " current_selection - if [[ $current_selection == 0 ]]; then exec bash "$script_name" "${update_selection[@]}" exit @@ -121,7 +118,7 @@ menu(){ update_selection+=("-b" "$up_backups") elif [[ $current_selection == 2 ]]; then read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore - update_list+=("-b $up_ignore") + update_list+=("-i $up_ignore") update_selection+=("-i" "$up_ignore") elif [[ $current_selection == 3 ]]; then update_list+=("-r") From 3d151ed8578f214988c1be67f3b4fafa8ca37b59 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 17:28:51 -0600 Subject: [PATCH 220/352] testing --- functions/menu.sh | 89 +++++++++++++++++++++++++++++------------------ 1 file changed, 56 insertions(+), 33 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 9c25d271..cef8c1d0 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -50,39 +50,62 @@ menu(){ script_path=$(dirname "$script") script_name="heavy_script.sh" cd "$script_path" || exit - clear -x - title - echo "Choose Your Update Type" - echo "-----------------------" - echo "1) -U | Update all applications, ignores versions" - echo "2) -u | Update all applications, does not update Major releases" - echo - echo "0) Exit" - echo - read -rt 600 -p "Please type the number associated with the flag above: " current_selection - if [[ $current_selection == 1 ]]; then - echo -e "\nHow many applications do you want updating at the same time?" - read -rt 600 -p "Please type an integer greater than 0: " up_async - elif [[ $current_selection == 2 ]]; then - echo -e "\nHow many applications do you want updating at the same time?" - read -rt 600 -p "Please type an integer greater than 0: " up_async - elif [[ $current_selection == 0 ]]; then - echo "Exiting.." - exit - else - echo "$current_selection was not an option, try again" - exit - fi - if [[ $up_async == 0 ]]; then - echo "0 was not an option.. exiting" - exit - elif ! [[ $up_async =~ ^[0-9]+$ ]]; then - echo "Error: \"$up_async\" is invalid, it needs to be an integer" - exit - else - update_selection+=("-u" "$up_async") - update_list+=("-u") - fi + while true + do + clear -x + title + echo "Choose Your Update Type" + echo "-----------------------" + echo "1) -U | Update all applications, ignores versions" + echo "2) -u | Update all applications, does not update Major releases" + echo + echo "0) Exit" + echo + read -rt 600 -p "Please type the number associated with the flag above: " current_selection + if [[ $current_selection == 1 ]]; then + echo -e "\nHow many applications do you want updating at the same time?" + read -rt 600 -p "Please type an integer greater than 0: " up_async + if [[ $up_async == 0 ]]; then + echo "Error: \"$up_async\" is less than 1" + echo "NOT adding it to the list" + sleep 5 + continue + elif ! [[ $up_async =~ ^[0-9]+$ ]]; then + echo "Error: \"$up_async\" is invalid, it needs to be an integer" + echo "NOT adding it to the list" + sleep 5 + continue + else + update_selection+=("-U" "$up_async") + update_list+=("-U") + break + fi + elif [[ $current_selection == 2 ]]; then + echo -e "\nHow many applications do you want updating at the same time?" + read -rt 600 -p "Please type an integer greater than 0: " up_async + if [[ $up_async == 0 ]]; then + echo "Error: \"$up_async\" is less than 1" + echo "NOT adding it to the list" + sleep 5 + continue + elif ! [[ $up_async =~ ^[0-9]+$ ]]; then + echo "Error: \"$up_async\" is invalid, it needs to be an integer" + echo "NOT adding it to the list" + sleep 5 + continue + else + update_selection+=("-u" "$up_async") + update_list+=("-u") + break + fi + elif [[ $current_selection == 0 ]]; then + echo "Exiting.." + exit + else + echo "$current_selection was not an option, try again" + exit + fi + done while true do clear -x From 681c0eb7c9e7364eb9a31bf1f21769cf58af8d9a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 17:29:51 -0600 Subject: [PATCH 221/352] test --- functions/menu.sh | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index cef8c1d0..6616091a 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -77,7 +77,6 @@ menu(){ continue else update_selection+=("-U" "$up_async") - update_list+=("-U") break fi elif [[ $current_selection == 2 ]]; then @@ -95,7 +94,6 @@ menu(){ continue else update_selection+=("-u" "$up_async") - update_list+=("-u") break fi elif [[ $current_selection == 0 ]]; then @@ -125,7 +123,7 @@ menu(){ echo echo "Current Choices" echo "---------------" - echo "${update_list[*]}" + echo "${update_selection[*]}" echo read -rt 600 -p "Please type the number associated with the flag above: " current_selection @@ -137,32 +135,32 @@ menu(){ read -rt 600 -p "Please type an integer: " up_backups ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 5 && continue - update_list+=("-b $up_backups") + update_selection+=("-b" "$up_backups") elif [[ $current_selection == 2 ]]; then read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore - update_list+=("-i $up_ignore") + update_selection+=("-i" "$up_ignore") elif [[ $current_selection == 3 ]]; then - update_list+=("-r") + update_selection+=("-r") elif [[ $current_selection == 4 ]]; then - update_list+=("-S") + update_selection+=("-S") elif [[ $current_selection == 5 ]]; then - update_list+=("-v") + update_selection+=("-v") elif [[ $current_selection == 6 ]]; then echo "What do you want your timeout to be?" read -rt 600 -p "Please type an integer: " up_timeout ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue - update_list+=("-t $up_timeout") + update_selection+=("-t" "$up_timeout") elif [[ $current_selection == 7 ]]; then - update_list+=("-s") + update_selection+=("-s") elif [[ $current_selection == 8 ]]; then - update_list+=("-p") + update_selection+=("-p") else echo "$current_selection was not an option, try again" && sleep 5 && continue From bd5569457be112ab4a126c84d216aa32acbb1e2c Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 17:30:54 -0600 Subject: [PATCH 222/352] QOL --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index 6616091a..188bd13e 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -123,7 +123,7 @@ menu(){ echo echo "Current Choices" echo "---------------" - echo "${update_selection[*]}" + echo "bash heavy_script.sh ${update_selection[*]}" echo read -rt 600 -p "Please type the number associated with the flag above: " current_selection From 882f4033c995977399ff7d18b57b787cc1febc5b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 17:43:06 -0600 Subject: [PATCH 223/352] polish messages --- functions/backup.sh | 2 +- functions/menu.sh | 2 ++ functions/misc.sh | 2 +- heavy_script.sh | 5 ++++- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index 03c0003b..a4eff30b 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -8,7 +8,7 @@ date=$(date '+%Y_%m_%d_%H_%M_%S') [[ -z "$verbose" ]] && echo_backup+=("\nNew Backup Name:") && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' | tail -n 1 &> /dev/null && echo_backup+=(HeavyScript_"$date") mapfile -t list_backups < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r") if [[ ${#list_backups[@]} -gt "number_of_backups" ]]; then - echo_backup+=("\nDeleting the oldest backup(s) for exceeding limit:") + echo_backup+=("\nDeleted the oldest backup(s) for exceeding limit:") overflow=$(( ${#list_backups[@]} - "$number_of_backups" )) mapfile -t list_overflow < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -V -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r" | head -n "$overflow") for i in "${list_overflow[@]}" diff --git a/functions/menu.sh b/functions/menu.sh index 188bd13e..acb24d7c 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -128,6 +128,8 @@ menu(){ read -rt 600 -p "Please type the number associated with the flag above: " current_selection if [[ $current_selection == 0 ]]; then + clear -x + echo "Running \"bash heavy_script.sh ${update_selection[*]}\"" exec bash "$script_name" "${update_selection[@]}" exit elif [[ $current_selection == 1 ]]; then diff --git a/functions/misc.sh b/functions/misc.sh index 8fcdbbed..e6439e9f 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -2,7 +2,7 @@ sync(){ -echo_sync+=("\nSyncing all catalogs, please wait..") && cli -c 'app catalog sync_all' &> /dev/null && echo_sync+=("Catalog sync complete") +cli -c 'app catalog sync_all' &> /dev/null && echo_sync+=("Catalog sync complete") #Dump the echo_array, ensures all output is in a neat order. for i in "${echo_sync[@]}" diff --git a/heavy_script.sh b/heavy_script.sh index 7dff535c..ce8742ce 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -139,7 +139,10 @@ done [[ "$restore" == "true" ]] && restore && exit [[ "$mount" == "true" ]] && mount && exit if [[ "$number_of_backups" -ge 1 && "$sync" == "true" ]]; then # Run backup and sync at the same time - echo -e "Backing up and syncing catalogs at the same time, please wait for output..\n" + echo "Running the following two tasks at the same time" + echo "------------------------------------------------" + echo -e "Backing up ix-applications dataset\nSyncing catalog(s)" + echo -e "This can take a LONG time, please wait for the output..\n" backup & sync & wait From 85eb4a17a1771c10466941f79b412e9a24cb9ecc Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 17:53:08 -0600 Subject: [PATCH 224/352] Titles --- functions/backup.sh | 4 +++- functions/menu.sh | 1 + functions/misc.sh | 7 ++++++- functions/update_apps.sh | 2 ++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index a4eff30b..f2221932 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -2,7 +2,9 @@ backup(){ -echo_backup+=("\nNumber of backups was set to $number_of_backups") +echo_backup+=("\nBackup Output") +echo_backup+=("--------------") +echo_backup+=("Number of backups was set to $number_of_backups") date=$(date '+%Y_%m_%d_%H_%M_%S') [[ "$verbose" == "true" ]] && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' &> /dev/null && echo_backup+=(HeavyScript_"$date") [[ -z "$verbose" ]] && echo_backup+=("\nNew Backup Name:") && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' | tail -n 1 &> /dev/null && echo_backup+=(HeavyScript_"$date") diff --git a/functions/menu.sh b/functions/menu.sh index acb24d7c..440c3f29 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -130,6 +130,7 @@ menu(){ if [[ $current_selection == 0 ]]; then clear -x echo "Running \"bash heavy_script.sh ${update_selection[*]}\"" + echo exec bash "$script_name" "${update_selection[@]}" exit elif [[ $current_selection == 1 ]]; then diff --git a/functions/misc.sh b/functions/misc.sh index e6439e9f..96ca57e1 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -2,6 +2,8 @@ sync(){ +echo_sync+=("\nSync Output") +echo_sync+=("-----------") cli -c 'app catalog sync_all' &> /dev/null && echo_sync+=("Catalog sync complete") #Dump the echo_array, ensures all output is in a neat order. @@ -13,7 +15,10 @@ done export -f sync prune(){ -echo -e "\nPruning Docker Images" && docker image prune -af | grep "^Total" || echo "Failed to Prune Docker Images" +echo -e "\nDocker Prune Output" +echo "-------------------" +echo "Pruned Docker Images" +docker image prune -af | grep "^Total" || echo "Failed to Prune Docker Images" } export -f prune diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 4664de1b..f036f3f9 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -3,6 +3,8 @@ commander(){ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | tr -d " \t\r" | grep -E ",true($|,)" | sort) +echo "Aplication Update Output" +echo "------------------------" [[ -z $array ]] && echo -e "\nThere are no updates available" && return 0 || echo -e "\n${#array[@]} update(s) available" [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" From 9aa6e15f4e8b142aa41aa5238bd977ac3ee95614 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 17:58:02 -0600 Subject: [PATCH 225/352] formatting --- functions/menu.sh | 4 ++-- functions/update_apps.sh | 2 +- heavy_script.sh | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 440c3f29..bf7157c8 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -108,7 +108,7 @@ menu(){ do clear -x title - echo "Choose your update options" + echo "Choose Your Update Options" echo "--------------------------" echo "1) -b | Back-up your ix-applications dataset, specify a number after -b" echo "2) -i | Add application to ignore list, one by one, see example below." @@ -174,6 +174,6 @@ menu(){ echo "Unknown option" && exit 1 ;; esac - echo "" + echo } export -f menu \ No newline at end of file diff --git a/functions/update_apps.sh b/functions/update_apps.sh index f036f3f9..6ea07838 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -3,7 +3,7 @@ commander(){ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | tr -d " \t\r" | grep -E ",true($|,)" | sort) -echo "Aplication Update Output" +echo -e "\nAplication Update Output" echo "------------------------" [[ -z $array ]] && echo -e "\nThere are no updates available" && return 0 || echo -e "\n${#array[@]} update(s) available" [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" diff --git a/heavy_script.sh b/heavy_script.sh index ce8742ce..ac4e4e48 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -147,7 +147,7 @@ if [[ "$number_of_backups" -ge 1 && "$sync" == "true" ]]; then # Run backup and sync & wait fi -[[ "$number_of_backups" -ge 1 && -z "$sync" ]] && echo "Please wait for output, this could take a while.." && backup -[[ "$sync" == "true" && "$number_of_backups" -lt 1 ]] && echo "Please wait for output, this could take a while.." && sync +[[ "$number_of_backups" -ge 1 && -z "$sync" ]] && echo "Backing up \"ix-applications\" dataset, please wait.." && backup +[[ "$sync" == "true" && "$number_of_backups" -lt 1 ]] && echo "Syncing catalogs, this takes a LONG time, please wait.." && sync [[ "$update_all_apps" == "true" || "$update_apps" == "true" ]] && commander [[ "$prune" == "true" ]] && prune From ac95a304d7722f35d67a8db890f49f58c8cca85f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 18:00:03 -0600 Subject: [PATCH 226/352] more formatting --- functions/update_apps.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 6ea07838..ce642ff2 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -5,8 +5,8 @@ commander(){ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | tr -d " \t\r" | grep -E ",true($|,)" | sort) echo -e "\nAplication Update Output" echo "------------------------" -[[ -z $array ]] && echo -e "\nThere are no updates available" && return 0 || echo -e "\n${#array[@]} update(s) available" -[[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" +[[ -z $array ]] && echo "There are no updates available" && return 0 || echo "${#array[@]} update(s) available" +[[ -z $timeout ]] && echo "Default Timeout: 500" && timeout=500 || echo "Custom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" echo "Asynchronous Updates: $update_limit" From 61a591f0230c98fb337fc645deac999a38df4ee8 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 18:16:56 -0600 Subject: [PATCH 227/352] while loop for menu test --- functions/menu.sh | 335 ++++++++++++++++++++------------------- functions/update_apps.sh | 1 - 2 files changed, 172 insertions(+), 164 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index bf7157c8..2091e1d4 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -1,179 +1,188 @@ #!/bin/bash menu(){ - clear -x - title - echo "1) Help" - echo "2) List DNS Names" - echo "3) Mount and Unmount PVC storage" - echo "4) Create a Backup" - echo "5) Restore a Backup" - echo "6) Delete a Backup" - echo "7) Update HeavyScript" - echo "8) Update Applications" - echo - echo "0) Exit" - read -rt 600 -p "Please select an option by number: " selection - - case $selection in - 0) - exit - ;; - 1) - help="true" - ;; - 2) - dns="true" - ;; - 3) - mount="true" - ;; - 4) - read -rt 600 -p "Please type the max number of backups to keep: " number_of_backups - number_of_backups=$number_of_backups - ! [[ $number_of_backups =~ ^[0-9]+$ ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit - [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit - echo "Generating backup, please be patient for output.." - backup "$number_of_backups" - ;; - 5) - restore="true" - ;; - 6) - deleteBackup="true" - ;; - 7) - self_update="true" - ;; - 8) - script=$(readlink -f "$0") - script_path=$(dirname "$script") - script_name="heavy_script.sh" - cd "$script_path" || exit - while true - do - clear -x - title - echo "Choose Your Update Type" - echo "-----------------------" - echo "1) -U | Update all applications, ignores versions" - echo "2) -u | Update all applications, does not update Major releases" - echo - echo "0) Exit" - echo - read -rt 600 -p "Please type the number associated with the flag above: " current_selection - if [[ $current_selection == 1 ]]; then - echo -e "\nHow many applications do you want updating at the same time?" - read -rt 600 -p "Please type an integer greater than 0: " up_async - if [[ $up_async == 0 ]]; then - echo "Error: \"$up_async\" is less than 1" - echo "NOT adding it to the list" - sleep 5 - continue - elif ! [[ $up_async =~ ^[0-9]+$ ]]; then - echo "Error: \"$up_async\" is invalid, it needs to be an integer" - echo "NOT adding it to the list" - sleep 5 - continue - else - update_selection+=("-U" "$up_async") - break - fi - elif [[ $current_selection == 2 ]]; then - echo -e "\nHow many applications do you want updating at the same time?" - read -rt 600 -p "Please type an integer greater than 0: " up_async - if [[ $up_async == 0 ]]; then - echo "Error: \"$up_async\" is less than 1" - echo "NOT adding it to the list" - sleep 5 - continue - elif ! [[ $up_async =~ ^[0-9]+$ ]]; then - echo "Error: \"$up_async\" is invalid, it needs to be an integer" - echo "NOT adding it to the list" - sleep 5 - continue - else - update_selection+=("-u" "$up_async") - break - fi - elif [[ $current_selection == 0 ]]; then - echo "Exiting.." + clear -x + title + echo "1) Help" + echo "2) List DNS Names" + echo "3) Mount and Unmount PVC storage" + echo "4) Create a Backup" + echo "5) Restore a Backup" + echo "6) Delete a Backup" + echo "7) Update HeavyScript" + echo "8) Update Applications" + echo + echo "0) Exit" + read -rt 600 -p "Please select an option by number: " selection + while true + do + case $selection in + 0) exit - else - echo "$current_selection was not an option, try again" + ;; + 1) + help="true" exit - fi - done - while true - do - clear -x - title - echo "Choose Your Update Options" - echo "--------------------------" - echo "1) -b | Back-up your ix-applications dataset, specify a number after -b" - echo "2) -i | Add application to ignore list, one by one, see example below." - echo "3) -r | Roll-back applications if they fail to update" - echo "4) -S | Shutdown applications prior to updating" - echo "5) -v | verbose output" - echo "6) -t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" - echo "7) -s | sync catalog" - echo "8) -p | Prune unused/old docker images" - echo - echo "0) Done making selections, proceed with update" - echo - echo "Current Choices" - echo "---------------" - echo "bash heavy_script.sh ${update_selection[*]}" - echo - read -rt 600 -p "Please type the number associated with the flag above: " current_selection - - if [[ $current_selection == 0 ]]; then - clear -x - echo "Running \"bash heavy_script.sh ${update_selection[*]}\"" - echo - exec bash "$script_name" "${update_selection[@]}" + ;; + 2) + dns="true" exit - elif [[ $current_selection == 1 ]]; then - echo "Up to how many backups should we keep?" - read -rt 600 -p "Please type an integer: " up_backups - ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue - [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 5 && continue + ;; + 3) + mount="true" + exit + ;; + 4) + read -rt 600 -p "Please type the max number of backups to keep: " number_of_backups + number_of_backups=$number_of_backups + ! [[ $number_of_backups =~ ^[0-9]+$ ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit + [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit + echo "Generating backup, please be patient for output.." + backup "$number_of_backups" + ;; + 5) + restore="true" + exit + ;; + 6) + deleteBackup="true" + exit + ;; + 7) + self_update="true" + exit + ;; + 8) + script=$(readlink -f "$0") + script_path=$(dirname "$script") + script_name="heavy_script.sh" + cd "$script_path" || exit + while true + do + clear -x + title + echo "Choose Your Update Type" + echo "-----------------------" + echo "1) -U | Update all applications, ignores versions" + echo "2) -u | Update all applications, does not update Major releases" + echo + echo "0) Exit" + echo + read -rt 600 -p "Please type the number associated with the flag above: " current_selection + if [[ $current_selection == 1 ]]; then + echo -e "\nHow many applications do you want updating at the same time?" + read -rt 600 -p "Please type an integer greater than 0: " up_async + if [[ $up_async == 0 ]]; then + echo "Error: \"$up_async\" is less than 1" + echo "NOT adding it to the list" + sleep 5 + continue + elif ! [[ $up_async =~ ^[0-9]+$ ]]; then + echo "Error: \"$up_async\" is invalid, it needs to be an integer" + echo "NOT adding it to the list" + sleep 5 + continue + else + update_selection+=("-U" "$up_async") + break + fi + elif [[ $current_selection == 2 ]]; then + echo -e "\nHow many applications do you want updating at the same time?" + read -rt 600 -p "Please type an integer greater than 0: " up_async + if [[ $up_async == 0 ]]; then + echo "Error: \"$up_async\" is less than 1" + echo "NOT adding it to the list" + sleep 5 + continue + elif ! [[ $up_async =~ ^[0-9]+$ ]]; then + echo "Error: \"$up_async\" is invalid, it needs to be an integer" + echo "NOT adding it to the list" + sleep 5 + continue + else + update_selection+=("-u" "$up_async") + break + fi + elif [[ $current_selection == 0 ]]; then + echo "Exiting.." + exit + else + echo "$current_selection was not an option, try again" + exit + fi + done + while true + do + clear -x + title + echo "Choose Your Update Options" + echo "--------------------------" + echo "1) -b | Back-up your ix-applications dataset, specify a number after -b" + echo "2) -i | Add application to ignore list, one by one, see example below." + echo "3) -r | Roll-back applications if they fail to update" + echo "4) -S | Shutdown applications prior to updating" + echo "5) -v | verbose output" + echo "6) -t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" + echo "7) -s | sync catalog" + echo "8) -p | Prune unused/old docker images" + echo + echo "0) Done making selections, proceed with update" + echo + echo "Current Choices" + echo "---------------" + echo "bash heavy_script.sh ${update_selection[*]}" + echo + read -rt 600 -p "Please type the number associated with the flag above: " current_selection - update_selection+=("-b" "$up_backups") - elif [[ $current_selection == 2 ]]; then - read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore + if [[ $current_selection == 0 ]]; then + clear -x + echo "Running \"bash heavy_script.sh ${update_selection[*]}\"" + echo + exec bash "$script_name" "${update_selection[@]}" + exit + elif [[ $current_selection == 1 ]]; then + echo "Up to how many backups should we keep?" + read -rt 600 -p "Please type an integer: " up_backups + ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue + [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 5 && continue - update_selection+=("-i" "$up_ignore") - elif [[ $current_selection == 3 ]]; then + update_selection+=("-b" "$up_backups") + elif [[ $current_selection == 2 ]]; then + read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore - update_selection+=("-r") - elif [[ $current_selection == 4 ]]; then + update_selection+=("-i" "$up_ignore") + elif [[ $current_selection == 3 ]]; then - update_selection+=("-S") - elif [[ $current_selection == 5 ]]; then + update_selection+=("-r") + elif [[ $current_selection == 4 ]]; then - update_selection+=("-v") - elif [[ $current_selection == 6 ]]; then - echo "What do you want your timeout to be?" - read -rt 600 -p "Please type an integer: " up_timeout - ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue + update_selection+=("-S") + elif [[ $current_selection == 5 ]]; then - update_selection+=("-t" "$up_timeout") - elif [[ $current_selection == 7 ]]; then + update_selection+=("-v") + elif [[ $current_selection == 6 ]]; then + echo "What do you want your timeout to be?" + read -rt 600 -p "Please type an integer: " up_timeout + ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue - update_selection+=("-s") - elif [[ $current_selection == 8 ]]; then + update_selection+=("-t" "$up_timeout") + elif [[ $current_selection == 7 ]]; then - update_selection+=("-p") - else - echo "$current_selection was not an option, try again" && sleep 5 && continue - fi - done - ;; - *) - echo "Unknown option" && exit 1 - ;; - esac - echo + update_selection+=("-s") + elif [[ $current_selection == 8 ]]; then + + update_selection+=("-p") + else + echo "$current_selection was not an option, try again" && sleep 5 && continue + fi + done + exit + ;; + *) + echo "That was not an option, please try again" && sleep 5 + ;; + esac + echo + done } export -f menu \ No newline at end of file diff --git a/functions/update_apps.sh b/functions/update_apps.sh index ce642ff2..320a0351 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -19,7 +19,6 @@ do do kill -0 "$proc" &> /dev/null || { unset "processes[$count]"; ((proc_count--)); } done - #jobs=$(jobs -p | wc -l) if [[ "$proc_count" -ge "$update_limit" ]]; then sleep 1 else From 5a325d210ac8a279f7875c738de747b07f0f31e3 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 18:18:20 -0600 Subject: [PATCH 228/352] test --- functions/menu.sh | 2 +- functions/update_apps.sh | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 2091e1d4..6aec0511 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -179,7 +179,7 @@ menu(){ exit ;; *) - echo "That was not an option, please try again" && sleep 5 + echo "That was not an option, please try again" && sleep 5 && menu ;; esac echo diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 320a0351..d1abed7e 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -32,8 +32,6 @@ for proc in "${processes[@]}" do wait "$proc" done - - } export -f commander From 987bc9812cea18ab87626e45ec378db580cb0f91 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 18:19:01 -0600 Subject: [PATCH 229/352] test --- functions/menu.sh | 6 ------ 1 file changed, 6 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 6aec0511..be39eb69 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -22,15 +22,12 @@ menu(){ ;; 1) help="true" - exit ;; 2) dns="true" - exit ;; 3) mount="true" - exit ;; 4) read -rt 600 -p "Please type the max number of backups to keep: " number_of_backups @@ -42,15 +39,12 @@ menu(){ ;; 5) restore="true" - exit ;; 6) deleteBackup="true" - exit ;; 7) self_update="true" - exit ;; 8) script=$(readlink -f "$0") From 8b0b8393a1b75bef3c62ee90d23fe70f25a81d55 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 18:21:45 -0600 Subject: [PATCH 230/352] test --- functions/menu.sh | 347 +++++++++++++++++++++++----------------------- 1 file changed, 172 insertions(+), 175 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index be39eb69..4028433e 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -1,182 +1,179 @@ #!/bin/bash menu(){ - clear -x - title - echo "1) Help" - echo "2) List DNS Names" - echo "3) Mount and Unmount PVC storage" - echo "4) Create a Backup" - echo "5) Restore a Backup" - echo "6) Delete a Backup" - echo "7) Update HeavyScript" - echo "8) Update Applications" - echo - echo "0) Exit" - read -rt 600 -p "Please select an option by number: " selection - while true - do - case $selection in - 0) + clear -x + title + echo "1) Help" + echo "2) List DNS Names" + echo "3) Mount and Unmount PVC storage" + echo "4) Create a Backup" + echo "5) Restore a Backup" + echo "6) Delete a Backup" + echo "7) Update HeavyScript" + echo "8) Update Applications" + echo + echo "0) Exit" + read -rt 600 -p "Please select an option by number: " selection + + case $selection in + 0) + exit + ;; + 1) + help="true" + ;; + 2) + dns="true" + ;; + 3) + mount="true" + ;; + 4) + read -rt 600 -p "Please type the max number of backups to keep: " number_of_backups + number_of_backups=$number_of_backups + ! [[ $number_of_backups =~ ^[0-9]+$ ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit + [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit + echo "Generating backup, please be patient for output.." + backup "$number_of_backups" + ;; + 5) + restore="true" + ;; + 6) + deleteBackup="true" + ;; + 7) + self_update="true" + ;; + 8) + script=$(readlink -f "$0") + script_path=$(dirname "$script") + script_name="heavy_script.sh" + cd "$script_path" || exit + while true + do + clear -x + title + echo "Choose Your Update Type" + echo "-----------------------" + echo "1) -U | Update all applications, ignores versions" + echo "2) -u | Update all applications, does not update Major releases" + echo + echo "0) Exit" + echo + read -rt 600 -p "Please type the number associated with the flag above: " current_selection + if [[ $current_selection == 1 ]]; then + echo -e "\nHow many applications do you want updating at the same time?" + read -rt 600 -p "Please type an integer greater than 0: " up_async + if [[ $up_async == 0 ]]; then + echo "Error: \"$up_async\" is less than 1" + echo "NOT adding it to the list" + sleep 5 + continue + elif ! [[ $up_async =~ ^[0-9]+$ ]]; then + echo "Error: \"$up_async\" is invalid, it needs to be an integer" + echo "NOT adding it to the list" + sleep 5 + continue + else + update_selection+=("-U" "$up_async") + break + fi + elif [[ $current_selection == 2 ]]; then + echo -e "\nHow many applications do you want updating at the same time?" + read -rt 600 -p "Please type an integer greater than 0: " up_async + if [[ $up_async == 0 ]]; then + echo "Error: \"$up_async\" is less than 1" + echo "NOT adding it to the list" + sleep 5 + continue + elif ! [[ $up_async =~ ^[0-9]+$ ]]; then + echo "Error: \"$up_async\" is invalid, it needs to be an integer" + echo "NOT adding it to the list" + sleep 5 + continue + else + update_selection+=("-u" "$up_async") + break + fi + elif [[ $current_selection == 0 ]]; then + echo "Exiting.." exit - ;; - 1) - help="true" - ;; - 2) - dns="true" - ;; - 3) - mount="true" - ;; - 4) - read -rt 600 -p "Please type the max number of backups to keep: " number_of_backups - number_of_backups=$number_of_backups - ! [[ $number_of_backups =~ ^[0-9]+$ ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit - [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit - echo "Generating backup, please be patient for output.." - backup "$number_of_backups" - ;; - 5) - restore="true" - ;; - 6) - deleteBackup="true" - ;; - 7) - self_update="true" - ;; - 8) - script=$(readlink -f "$0") - script_path=$(dirname "$script") - script_name="heavy_script.sh" - cd "$script_path" || exit - while true - do - clear -x - title - echo "Choose Your Update Type" - echo "-----------------------" - echo "1) -U | Update all applications, ignores versions" - echo "2) -u | Update all applications, does not update Major releases" - echo - echo "0) Exit" - echo - read -rt 600 -p "Please type the number associated with the flag above: " current_selection - if [[ $current_selection == 1 ]]; then - echo -e "\nHow many applications do you want updating at the same time?" - read -rt 600 -p "Please type an integer greater than 0: " up_async - if [[ $up_async == 0 ]]; then - echo "Error: \"$up_async\" is less than 1" - echo "NOT adding it to the list" - sleep 5 - continue - elif ! [[ $up_async =~ ^[0-9]+$ ]]; then - echo "Error: \"$up_async\" is invalid, it needs to be an integer" - echo "NOT adding it to the list" - sleep 5 - continue - else - update_selection+=("-U" "$up_async") - break - fi - elif [[ $current_selection == 2 ]]; then - echo -e "\nHow many applications do you want updating at the same time?" - read -rt 600 -p "Please type an integer greater than 0: " up_async - if [[ $up_async == 0 ]]; then - echo "Error: \"$up_async\" is less than 1" - echo "NOT adding it to the list" - sleep 5 - continue - elif ! [[ $up_async =~ ^[0-9]+$ ]]; then - echo "Error: \"$up_async\" is invalid, it needs to be an integer" - echo "NOT adding it to the list" - sleep 5 - continue - else - update_selection+=("-u" "$up_async") - break - fi - elif [[ $current_selection == 0 ]]; then - echo "Exiting.." - exit - else - echo "$current_selection was not an option, try again" - exit - fi - done - while true - do - clear -x - title - echo "Choose Your Update Options" - echo "--------------------------" - echo "1) -b | Back-up your ix-applications dataset, specify a number after -b" - echo "2) -i | Add application to ignore list, one by one, see example below." - echo "3) -r | Roll-back applications if they fail to update" - echo "4) -S | Shutdown applications prior to updating" - echo "5) -v | verbose output" - echo "6) -t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" - echo "7) -s | sync catalog" - echo "8) -p | Prune unused/old docker images" - echo - echo "0) Done making selections, proceed with update" - echo - echo "Current Choices" - echo "---------------" - echo "bash heavy_script.sh ${update_selection[*]}" - echo - read -rt 600 -p "Please type the number associated with the flag above: " current_selection - - if [[ $current_selection == 0 ]]; then - clear -x - echo "Running \"bash heavy_script.sh ${update_selection[*]}\"" - echo - exec bash "$script_name" "${update_selection[@]}" - exit - elif [[ $current_selection == 1 ]]; then - echo "Up to how many backups should we keep?" - read -rt 600 -p "Please type an integer: " up_backups - ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue - [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 5 && continue - - update_selection+=("-b" "$up_backups") - elif [[ $current_selection == 2 ]]; then - read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore - - update_selection+=("-i" "$up_ignore") - elif [[ $current_selection == 3 ]]; then - - update_selection+=("-r") - elif [[ $current_selection == 4 ]]; then - - update_selection+=("-S") - elif [[ $current_selection == 5 ]]; then - - update_selection+=("-v") - elif [[ $current_selection == 6 ]]; then - echo "What do you want your timeout to be?" - read -rt 600 -p "Please type an integer: " up_timeout - ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue - - update_selection+=("-t" "$up_timeout") - elif [[ $current_selection == 7 ]]; then - - update_selection+=("-s") - elif [[ $current_selection == 8 ]]; then - - update_selection+=("-p") - else - echo "$current_selection was not an option, try again" && sleep 5 && continue - fi - done + else + echo "$current_selection was not an option, try again" exit - ;; - *) - echo "That was not an option, please try again" && sleep 5 && menu - ;; - esac - echo - done + fi + done + while true + do + clear -x + title + echo "Choose Your Update Options" + echo "--------------------------" + echo "1) -b | Back-up your ix-applications dataset, specify a number after -b" + echo "2) -i | Add application to ignore list, one by one, see example below." + echo "3) -r | Roll-back applications if they fail to update" + echo "4) -S | Shutdown applications prior to updating" + echo "5) -v | verbose output" + echo "6) -t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" + echo "7) -s | sync catalog" + echo "8) -p | Prune unused/old docker images" + echo + echo "0) Done making selections, proceed with update" + echo + echo "Current Choices" + echo "---------------" + echo "bash heavy_script.sh ${update_selection[*]}" + echo + read -rt 600 -p "Please type the number associated with the flag above: " current_selection + + if [[ $current_selection == 0 ]]; then + clear -x + echo "Running \"bash heavy_script.sh ${update_selection[*]}\"" + echo + exec bash "$script_name" "${update_selection[@]}" + exit + elif [[ $current_selection == 1 ]]; then + echo "Up to how many backups should we keep?" + read -rt 600 -p "Please type an integer: " up_backups + ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue + [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 5 && continue + + update_selection+=("-b" "$up_backups") + elif [[ $current_selection == 2 ]]; then + read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore + + update_selection+=("-i" "$up_ignore") + elif [[ $current_selection == 3 ]]; then + + update_selection+=("-r") + elif [[ $current_selection == 4 ]]; then + + update_selection+=("-S") + elif [[ $current_selection == 5 ]]; then + + update_selection+=("-v") + elif [[ $current_selection == 6 ]]; then + echo "What do you want your timeout to be?" + read -rt 600 -p "Please type an integer: " up_timeout + ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue + + update_selection+=("-t" "$up_timeout") + elif [[ $current_selection == 7 ]]; then + + update_selection+=("-s") + elif [[ $current_selection == 8 ]]; then + + update_selection+=("-p") + else + echo "$current_selection was not an option, try again" && sleep 5 && continue + fi + done + ;; + *) + echo "That was not an option, please try agian" && menu + ;; + esac + echo } export -f menu \ No newline at end of file From 939ce2f7312b8e44f7c2fa1c2e40fd894f6980fd Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 18:22:19 -0600 Subject: [PATCH 231/352] test --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index 4028433e..6c36be3d 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -171,7 +171,7 @@ menu(){ done ;; *) - echo "That was not an option, please try agian" && menu + echo "That was not an option, please try agian" && sleep 5 && menu ;; esac echo From 46184a772201512086221baf303a94e41de491a3 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 18:28:23 -0600 Subject: [PATCH 232/352] fix backups --- functions/menu.sh | 1 + heavy_script.sh | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 6c36be3d..595c0444 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -34,6 +34,7 @@ menu(){ ! [[ $number_of_backups =~ ^[0-9]+$ ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit echo "Generating backup, please be patient for output.." + menu_backup="true" backup "$number_of_backups" ;; 5) diff --git a/heavy_script.sh b/heavy_script.sh index ac4e4e48..db3cb062 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -56,6 +56,7 @@ do exit ;; b) + backup="true" number_of_backups=$OPTARG ! [[ $OPTARG =~ ^[0-9]+$ ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit @@ -138,7 +139,7 @@ done [[ "$dns" == "true" ]] && dns && exit [[ "$restore" == "true" ]] && restore && exit [[ "$mount" == "true" ]] && mount && exit -if [[ "$number_of_backups" -ge 1 && "$sync" == "true" ]]; then # Run backup and sync at the same time +if [[ "$backup" == "true" && "$sync" == "true" ]]; then # Run backup and sync at the same time echo "Running the following two tasks at the same time" echo "------------------------------------------------" echo -e "Backing up ix-applications dataset\nSyncing catalog(s)" @@ -147,7 +148,7 @@ if [[ "$number_of_backups" -ge 1 && "$sync" == "true" ]]; then # Run backup and sync & wait fi -[[ "$number_of_backups" -ge 1 && -z "$sync" ]] && echo "Backing up \"ix-applications\" dataset, please wait.." && backup -[[ "$sync" == "true" && "$number_of_backups" -lt 1 ]] && echo "Syncing catalogs, this takes a LONG time, please wait.." && sync +[[ "$backup" == "true" && -z "$sync" ]] && echo "Backing up \"ix-applications\" dataset, please wait.." && backup +[[ "$sync" == "true" && -z "$backup" ]] && echo "Syncing catalogs, this takes a LONG time, please wait.." && sync [[ "$update_all_apps" == "true" || "$update_apps" == "true" ]] && commander [[ "$prune" == "true" ]] && prune From 13a2a2f8b2a3b77469ad90c097d889afc25d8aa6 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 18:32:35 -0600 Subject: [PATCH 233/352] fix delete backup --- functions/menu.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 595c0444..6d405efb 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -1,6 +1,10 @@ #!/bin/bash menu(){ + script=$(readlink -f "$0") + script_path=$(dirname "$script") + script_name="heavy_script.sh" + cd "$script_path" || exit clear -x title echo "1) Help" @@ -42,15 +46,13 @@ menu(){ ;; 6) deleteBackup="true" + exec bash "$script_name" --restore + exit ;; 7) self_update="true" ;; 8) - script=$(readlink -f "$0") - script_path=$(dirname "$script") - script_name="heavy_script.sh" - cd "$script_path" || exit while true do clear -x From 065a809da3467273decf2205766dcdc7bf4ba119 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 18:33:58 -0600 Subject: [PATCH 234/352] woops lol --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index 6d405efb..3466b84d 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -46,7 +46,7 @@ menu(){ ;; 6) deleteBackup="true" - exec bash "$script_name" --restore + exec bash "$script_name" --delete-backup exit ;; 7) From 27bf546869f2bba69b4ea327e46b73e934cac4ad Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 18:36:08 -0600 Subject: [PATCH 235/352] uhh --- functions/menu.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 3466b84d..75618d27 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -46,8 +46,6 @@ menu(){ ;; 6) deleteBackup="true" - exec bash "$script_name" --delete-backup - exit ;; 7) self_update="true" From c2002979a8613f8699c67ddf9c79a2edd9c7db99 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 18:37:34 -0600 Subject: [PATCH 236/352] test --- functions/menu.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index 75618d27..f4fe1dc7 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -45,7 +45,8 @@ menu(){ restore="true" ;; 6) - deleteBackup="true" + exec bash "$script_name" --delete-backup + exit ;; 7) self_update="true" From 88ba5b18af49d2a6a06ea7f7163f270dd678efd4 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 18:40:07 -0600 Subject: [PATCH 237/352] no idea --- functions/menu.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index f4fe1dc7..75618d27 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -45,8 +45,7 @@ menu(){ restore="true" ;; 6) - exec bash "$script_name" --delete-backup - exit + deleteBackup="true" ;; 7) self_update="true" From 3f73c98fbec492285e4aa1a37be587aac2e4cb4e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 18:40:57 -0600 Subject: [PATCH 238/352] test --- functions/backup.sh | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index f2221932..fc81dce3 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -34,22 +34,12 @@ deleteBackup(){ clear -x && echo "pulling all restore points.." list_backups=$(cli -c 'app kubernetes list_backups' | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t) clear -x -[[ -z "$list_backups" ]] && echo "No restore points available" && exit -title -echo -e "Choose a restore point to delete\nThese may be out of order if they are not all HeavyScript backups" -echo "$list_backups" -read -pr -t 600 "Please type a number: " selection -restore_point=$(echo "$list_backups" | grep ^"$selection " | awk '{print $2}') -if [[ -z "$selection" ]]; then #Check for valid selection. If none, kill script - echo "Your selection cannot be empty" - exit -elif [[ -z "$restore_point" ]]; then #Check for valid selection. If none, kill script - echo "Invalid Selection: $selection, was not an option" - exit -fi -echo -e "\nWARNING:\nYou CANNOT go back after deleting your restore point" -echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" && echo -e "1 Yes\n2 No" -read -rp -t 120 "Please type a number: " yesno || { echo "Failed to make a valid selection"; exit; } +[[ -z "$list_backups" ]] && echo "No restore points available" && exit || { title; echo -e "Choose a restore point to delete\nThese may be out of order if they are not HeavyScript backups" ; } +echo "$list_backups" && read -t 600 -p "Please type a number: " selection && restore_point=$(echo "$list_backups" | grep ^"$selection " | awk '{print $2}') +[[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script +[[ -z "$restore_point" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script +echo -e "\nWARNING:\nYou CANNOT go back after deleting your restore point" || { echo "FAILED"; exit; } +echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" && echo -e "1 Yes\n2 No" && read -t 120 -p "Please type a number: " yesno || { echo "FAILED"; exit; } if [[ $yesno == "1" ]]; then echo -e "\nDeleting $restore_point" && cli -c 'app kubernetes delete_backup backup_name=''"'"$restore_point"'"' &>/dev/null && echo "Sucessfully deleted" || echo "Deletion Failed" elif [[ $yesno == "2" ]]; then From e459cce2413da0fcf92c4127cf874fb0579d0594 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 18:44:55 -0600 Subject: [PATCH 239/352] update readme --- README.md | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index f7717f6e..bcfb7e7a 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ | Flag | Example | Parameter | Description | |----------------- |------------------------ |----------- |--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| --self-update | --self-update | None | Updates HeavyScript prior to running it
_You no longer need to git pull_ | | --delete-backup | --delete-backup | None | Opens a menu to delete backups
_Useful if you need to delete old system backups or backups from other scripts_ | | --restore | --restore | None | Restore HeavyScript specific `ix-applications dataset` snapshot | | --mount | --mount | None | Initiates mounting feature
Choose between unmounting and mounting PVC data | @@ -36,7 +37,7 @@ ### Examples #### Typical Cron Job ``` -bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -rsup +bash heavy_script.sh --self-update -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -rsup ``` > `-b` is set to 14. Up to 14 snapshots of your ix-applications dataset will be saved @@ -53,6 +54,8 @@ bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -rsup > `-p` Prune docker images. +> `--self-update` Will update the script prior to running anything else. + #### Mounting PVC Data ``` @@ -79,7 +82,7 @@ bash /mnt/tank/scripts/heavy_script/heavy_script.sh --dns #### My personal Cron Job ``` -git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_script/heavy_script.sh -b 14 -rsup +bash /mnt/speed/scripts/heavy_script/heavy_script.sh --self-update -b 14 -rsup ```
@@ -111,7 +114,7 @@ cd heavy_script From here, you can just run Heavy_Script with `bash heavy_script.sh -ARGUMENTS` -> Note: `chmod +x` is NOT required. Doing this will break the `git pull` function. Just run the script with `bash heavy_script.sh` +> Note: `chmod +x` is NOT required. Doing this will break the `git pull` (or self update) function. Just run the script with `bash heavy_script.sh`
@@ -132,20 +135,13 @@ git pull ```
-### Update with your Cron Job +### Update with the scripts built-in option -Here, we will update the script prior to running it, incase there is a bugfix, or any new additions to the script - -**Cron Job Command** ``` -git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_script/heavy_script.sh -b 14 -rsup +bash heavyscript.sh --self-update -b 14 -supr ``` -> The important command here is the `git -C /PATH/TO/HEAVY_SCRIPT_DIRECTORY pull` +> The important argument here is the `--self-update`, you can still use all of your same arguments with this option. -> This command will allow you to preform a `git pull` on a remote directory, which will ensure your script is udated prior to running it - -> `&&` Is used to run a command AFTER the previous command completed successfully ->> So once the `git -C /PATH/TO/HEAVY_SCRIPT_DIRECTORY pull` command completes, THEN it will run the `bash /PATH/TO/HEAVY_SCRIPT_DIRECTORY/heavy_script.sh -b 14 -rsup` command

@@ -161,7 +157,7 @@ git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_scr | Name | Value | Reason | |------------------------ |------------------------------------------------------------------------------------------------------------------- |------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `Description` | HeavyScript git pull and Update apps | This is up to you, put whatever you think is a good description in here | -| `Command` | `git -C /PATH/TO/HEAVY_SCRIPT_DIRECTORY pull && bash /PATH/TO/HEAVY_SCRIPT_DIRECTORY/heavy_script.sh -b 14 -rsup` | This is the command you will be running on your schedule I personally use: `git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_script/heavy_script.sh -b 14 -rsup` | +| `Command` | `bash /PATH/TO/HEAVY_SCRIPT_DIRECTORY/heavy_script.sh --self-update -b 14 -rsup` | This is the command you will be running on your schedule I personally use: `bash /mnt/speed/scripts/heavy_script/heavy_script.sh --self-update -b 14 -rsup` | | `Run As User` | `root` | Running the script as `root` is REQUIRED. You cannot access all of the kubernetes functions without this user. | | `Schedule` | Up to you, I run mine everyday at `0400` | Again up to you | | `Hide Standard Output` | `False` or Unticked | I like to receive an email report of how the script ran, what apps updated etc. | @@ -184,4 +180,3 @@ git -C /mnt/speed/scripts/heavy_script pull && bash /mnt/speed/scripts/heavy_scr | ![image](https://user-images.githubusercontent.com/20793231/167971188-07f71d02-8da3-4e0c-b9a0-cd26e7f63613.png) | ![image](https://user-images.githubusercontent.com/20793231/167972033-dc8d4ab4-4fb2-4c8a-b7dc-b9311ae55cf8.png) | - From feb42b49e677581d1b3d68bcf47d637ea853cf22 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 18:57:22 -0600 Subject: [PATCH 240/352] update readme --- README.md | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index bcfb7e7a..627502b9 100644 --- a/README.md +++ b/README.md @@ -12,24 +12,24 @@ ## Arguments -| Flag | Example | Parameter | Description | -|----------------- |------------------------ |----------- |--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| --self-update | --self-update | None | Updates HeavyScript prior to running it
_You no longer need to git pull_ | -| --delete-backup | --delete-backup | None | Opens a menu to delete backups
_Useful if you need to delete old system backups or backups from other scripts_ | -| --restore | --restore | None | Restore HeavyScript specific `ix-applications dataset` snapshot | -| --mount | --mount | None | Initiates mounting feature
Choose between unmounting and mounting PVC data | -| --dns | --dns | None | list all of your applications DNS names and their web ports | -| -U | -U | None | Update applications, ignoring major version changes | -| -u | -u | None | Update applications, do NOT update if there was a major version change | -| -b | -b 14 | Integer | Backup `ix-appliactions` dataset
_Creates backups up to the number you've chosen_ | -| -i | -i nextcloud -i sonarr | String | Applications listed will be ignored during updating
_List one application after another as shown in the example_ | -| (-R\|-r) | -r | None | Monitors applications after they update
If the app does not become "ACTIVE" after either:
The custom Timeout, or Default Timeout,
rollback the application.
__Warning: deprecating `-R` please begin using `-r` instead__ | -| -v | -v | None | Verbose Output
_Look at the bottom of this page for an example_ | -| -S | -S | None | Shutdown the application prior to updating it | -| -t | -t 150 | Integer | Set a custom timeout to be used with either:
`-m`
_Time the script will wait for application to be "STOPPED"_
or
`-(u\|U)`
_Time the script will wait for application to be either "STOPPED" or "ACTIVE"_ | -| -s | -s | None | Sync Catalogs prior to updating | -| -p | -p | None | Prune old/unused docker images | - +| Flag | Example | Parameter | Description | +|----------------- |------------------------ |----------------- |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| NULL | NULL | NULL | If you choose not to supply an option, it will open the menu for easier access to the utilities | +| --self-update | --self-update | None | Updates HeavyScript prior to running it
_You no longer need to git pull_ | +| --delete-backup | --delete-backup | None | Opens a menu to delete backups
_Useful if you need to delete old system backups or backups from other scripts_ | +| --restore | --restore | None | Restore HeavyScript specific `ix-applications dataset` snapshot | +| --mount | --mount | None | Initiates mounting feature
Choose between unmounting and mounting PVC data | +| --dns | --dns | None | list all of your applications DNS names and their web ports | +| -U | -U
-U 5 | None or Integer | Update applications, ignoring major version changes
_Optionally, you can supply a number after the argument to update multiple applications at once_ | +| -u | -u
-u 5 | None or Integer | Update applications, do NOT update if there was a major version change
_Optionally, you can supply a number after the argument to update multiple applications at once_ | +| -b | -b 14 | Integer | Backup `ix-appliactions` dataset
_Creates backups up to the number you've chosen_ | +| -i | -i nextcloud -i sonarr | String | Applications listed will be ignored during updating
_List one application after another as shown in the example_ | +| -r | -r | None | Monitors applications after they update
If the app does not become "ACTIVE" after either:
The custom Timeout, or Default Timeout,
rollback the application. | +| -v | -v | None | Verbose Output
_Look at the bottom of this page for an example_ | +| -S | -S | None | Shutdown the application prior to updating it | +| -t | -t 150 | Integer | Set a custom timeout to be used with either:
`-m`
_Time the script will wait for application to be "STOPPED"_
or
`-(u\|U)`
_Time the script will wait for application to be either "STOPPED" or "ACTIVE"_ | +| -s | -s | None | Sync Catalogs prior to updating | +| -p | -p | None | Prune old/unused docker images |

@@ -37,7 +37,7 @@ ### Examples #### Typical Cron Job ``` -bash heavy_script.sh --self-update -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -rsup +bash heavy_script.sh --self-update -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -rsp -u 5 ``` > `-b` is set to 14. Up to 14 snapshots of your ix-applications dataset will be saved @@ -50,10 +50,11 @@ bash heavy_script.sh --self-update -b 14 -i portainer -i arch -i sonarr -i radar > `-s` will just sync the repositories, ensuring you are downloading the latest updates. -> `-u` update applications as long as the major version has absolutely no change, if it does have a change it will ask the user to update manually. - > `-p` Prune docker images. +> `-u` update applications as long as the major version has absolutely no change, if it does have a change it will ask the user to update manually. +> The `5` after the `-u` means up to 5 applications will be updating and monitored at one time + > `--self-update` Will update the script prior to running anything else. #### Mounting PVC Data @@ -82,7 +83,7 @@ bash /mnt/tank/scripts/heavy_script/heavy_script.sh --dns #### My personal Cron Job ``` -bash /mnt/speed/scripts/heavy_script/heavy_script.sh --self-update -b 14 -rsup +bash /mnt/speed/scripts/heavy_script/heavy_script.sh --self-update -b 14 -rsp -u 10 ```
From e0ba0935b837622dc316b8e5be617460959dafaa Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 18:58:17 -0600 Subject: [PATCH 241/352] readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 627502b9..8ab10a50 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ bash heavy_script.sh --self-update -b 14 -i portainer -i arch -i sonarr -i radar > `-p` Prune docker images. > `-u` update applications as long as the major version has absolutely no change, if it does have a change it will ask the user to update manually. -> The `5` after the `-u` means up to 5 applications will be updating and monitored at one time +>> The `5` after the `-u` means up to 5 applications will be updating and monitored at one time > `--self-update` Will update the script prior to running anything else. From 05051adf233764dcd6f28cf0a7240ee8ecefc626 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 19:04:27 -0600 Subject: [PATCH 242/352] cleanup --- functions/menu.sh | 40 ++++++++++++++++++++-------------------- functions/update_apps.sh | 3 +-- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 75618d27..e965ed7b 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -1,25 +1,25 @@ #!/bin/bash menu(){ - script=$(readlink -f "$0") - script_path=$(dirname "$script") - script_name="heavy_script.sh" - cd "$script_path" || exit - clear -x - title - echo "1) Help" - echo "2) List DNS Names" - echo "3) Mount and Unmount PVC storage" - echo "4) Create a Backup" - echo "5) Restore a Backup" - echo "6) Delete a Backup" - echo "7) Update HeavyScript" - echo "8) Update Applications" - echo - echo "0) Exit" - read -rt 600 -p "Please select an option by number: " selection +script=$(readlink -f "$0") +script_path=$(dirname "$script") +script_name="heavy_script.sh" +cd "$script_path" || exit +clear -x +title +echo "1) Help" +echo "2) List DNS Names" +echo "3) Mount and Unmount PVC storage" +echo "4) Create a Backup" +echo "5) Restore a Backup" +echo "6) Delete a Backup" +echo "7) Update HeavyScript" +echo "8) Update Applications" +echo +echo "0) Exit" +read -rt 600 -p "Please select an option by number: " selection - case $selection in +case $selection in 0) exit ;; @@ -174,7 +174,7 @@ menu(){ *) echo "That was not an option, please try agian" && sleep 5 && menu ;; - esac - echo +esac +echo } export -f menu \ No newline at end of file diff --git a/functions/update_apps.sh b/functions/update_apps.sh index d1abed7e..92aeab24 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -35,6 +35,7 @@ done } export -f commander + update_apps(){ app_name=$(echo "${array[$it]}" | awk -F ',' '{print $1}') #print out first catagory, name. printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && return 0 #If application is on ignore list, skip @@ -86,8 +87,6 @@ rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' ' echo_array+=("\n$app_name\nMajor Release, update manually") return 0 fi - - } export -f update_apps From 0884c75ec257e04dfb3663bcf2e4bed3c2039ca0 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 19:06:57 -0600 Subject: [PATCH 243/352] todo --- functions/self_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 93543752..20461d04 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -8,7 +8,7 @@ script_path=$(dirname "$script") script_name="heavy_script.sh" cd "$script_path" || exit git fetch &> /dev/null - +# TODO: change beta to main once testing is complete if git diff --name-only origin/beta | grep -qs ".sh" ; then echo "Found a new version of HeavyScript, updating myself..." git reset --hard -q From f2d30a74e501f46ffdb36a380d5369febd625739 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 20:20:16 -0600 Subject: [PATCH 244/352] remove uneeded --- functions/backup.sh | 2 +- functions/menu.sh | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index fc81dce3..f7626653 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -9,7 +9,7 @@ date=$(date '+%Y_%m_%d_%H_%M_%S') [[ "$verbose" == "true" ]] && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' &> /dev/null && echo_backup+=(HeavyScript_"$date") [[ -z "$verbose" ]] && echo_backup+=("\nNew Backup Name:") && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' | tail -n 1 &> /dev/null && echo_backup+=(HeavyScript_"$date") mapfile -t list_backups < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r") -if [[ ${#list_backups[@]} -gt "number_of_backups" ]]; then +if [[ ${#list_backups[@]} -gt "$number_of_backups" ]]; then echo_backup+=("\nDeleted the oldest backup(s) for exceeding limit:") overflow=$(( ${#list_backups[@]} - "$number_of_backups" )) mapfile -t list_overflow < <(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -V -k2,7 | awk -F '|' '{print $2}'| tr -d " \t\r" | head -n "$overflow") diff --git a/functions/menu.sh b/functions/menu.sh index e965ed7b..06c138b8 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -34,12 +34,9 @@ case $selection in ;; 4) read -rt 600 -p "Please type the max number of backups to keep: " number_of_backups - number_of_backups=$number_of_backups ! [[ $number_of_backups =~ ^[0-9]+$ ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit echo "Generating backup, please be patient for output.." - menu_backup="true" - backup "$number_of_backups" ;; 5) restore="true" From d262ad52f93628b8cb92bb50f3071cab6304dc29 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 20:21:48 -0600 Subject: [PATCH 245/352] test --- functions/menu.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 06c138b8..e4bff97a 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -33,10 +33,7 @@ case $selection in mount="true" ;; 4) - read -rt 600 -p "Please type the max number of backups to keep: " number_of_backups - ! [[ $number_of_backups =~ ^[0-9]+$ ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit - [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit - echo "Generating backup, please be patient for output.." + backup="true" ;; 5) restore="true" From 890677c72f920fa75e72a8db017cda5466d51f64 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 20:23:52 -0600 Subject: [PATCH 246/352] test --- functions/menu.sh | 1 + heavy_script.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index e4bff97a..f78bbb6b 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -33,6 +33,7 @@ case $selection in mount="true" ;; 4) + read -rt 600 -p "What is the maximun number of backups you would like?: " number_of_backups backup="true" ;; 5) diff --git a/heavy_script.sh b/heavy_script.sh index db3cb062..27abd6f7 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -56,10 +56,10 @@ do exit ;; b) - backup="true" number_of_backups=$OPTARG ! [[ $OPTARG =~ ^[0-9]+$ ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit [[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit + backup="true" ;; r) rollback="true" From 6f1fbd8bcf0957faa6345d216285b36c7478c012 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 20:31:44 -0600 Subject: [PATCH 247/352] update help --- functions/misc.sh | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/functions/misc.sh b/functions/misc.sh index 96ca57e1..35601d93 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -44,19 +44,24 @@ echo "--delete-backup | Opens a menu to delete backups on your system" echo "--dns | list all of your applications DNS names and their web ports" echo echo "Update Options" -echo "-U | Update all applications, ignores versions" -echo "-u | Update all applications, does not update Major releases" -echo "-b | Back-up your ix-applications dataset, specify a number after -b" -echo "-i | Add application to ignore list, one by one, see example below." -echo "-r | Roll-back applications if they fail to update" -echo "-S | Shutdown applications prior to updating" -echo "-v | verbose output" -echo "-t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" -echo "-s | sync catalog" -echo "-p | Prune unused/old docker images" +echo "-U | Update all applications, ignores versions" +echo "-U 5 | Same as above, but updates 5 applications at one time" +echo "-u | Update all applications, does not update Major releases" +echo "-u 5 | Same as above, but updates 5 applications at one time" +echo +echo "Additional Options" +echo "-b | Back-up your ix-applications dataset, specify a number after -b" +echo "-i | Add application to ignore list, one by one, see example below." +echo "-r | Roll-back applications if they fail to update" +echo "-S | Shutdown applications prior to updating" +echo "-v | verbose output" +echo "-t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" +echo "-s | sync catalog" +echo "-p | Prune unused/old docker images" echo echo "Examples" echo "bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vrsUp" +echo "bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vrsp -U 10" echo "bash /mnt/tank/scripts/heavy_script.sh -t 150 --mount" echo "bash /mnt/tank/scripts/heavy_script.sh --dns" echo "bash heavy_script.sh --restore" From 73feac7b95e8850c7b75fd93dabaf26089ccc77e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 20:34:18 -0600 Subject: [PATCH 248/352] help fix --- functions/misc.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/functions/misc.sh b/functions/misc.sh index 35601d93..9b61a053 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -37,19 +37,28 @@ export -f title help(){ [[ $help == "true" ]] && clear -x + +echo "Access the HeavyScript Menu" +echo "---------------------------" +echo "(Just dont send any other argument)" +echo "bash heavy_script.sh" +echo echo "Basic Utilities" +echo "---------------" echo "--mount | Initiates mounting feature, choose between unmounting and mounting PVC data" echo "--restore | Opens a menu to restore a \"heavy_script\" backup that was taken on your \"ix-applications\" dataset" echo "--delete-backup | Opens a menu to delete backups on your system" echo "--dns | list all of your applications DNS names and their web ports" echo echo "Update Options" +echo "--------------" echo "-U | Update all applications, ignores versions" echo "-U 5 | Same as above, but updates 5 applications at one time" echo "-u | Update all applications, does not update Major releases" echo "-u 5 | Same as above, but updates 5 applications at one time" echo echo "Additional Options" +echo "------------------" echo "-b | Back-up your ix-applications dataset, specify a number after -b" echo "-i | Add application to ignore list, one by one, see example below." echo "-r | Roll-back applications if they fail to update" @@ -60,12 +69,14 @@ echo "-s | sync catalog" echo "-p | Prune unused/old docker images" echo echo "Examples" +echo "--------" echo "bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vrsUp" echo "bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vrsp -U 10" echo "bash /mnt/tank/scripts/heavy_script.sh -t 150 --mount" echo "bash /mnt/tank/scripts/heavy_script.sh --dns" echo "bash heavy_script.sh --restore" echo "bash /mnt/tank/scripts/heavy_script.sh --delete-backup" +echo "bash heavy_script.sh" echo exit } From c836ff5ce246564d249fe82452f75605b5ad5332 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 20:36:18 -0600 Subject: [PATCH 249/352] cleanup help --- functions/misc.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/misc.sh b/functions/misc.sh index 9b61a053..ce13f395 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -57,8 +57,8 @@ echo "-U 5 | Same as above, but updates 5 applications at one time" echo "-u | Update all applications, does not update Major releases" echo "-u 5 | Same as above, but updates 5 applications at one time" echo -echo "Additional Options" -echo "------------------" +echo "Additional Update Options" +echo "-------------------------" echo "-b | Back-up your ix-applications dataset, specify a number after -b" echo "-i | Add application to ignore list, one by one, see example below." echo "-r | Roll-back applications if they fail to update" From 587fefee3be6c5f63b9770dc9d7bcb5cc32f0cd3 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 20:38:18 -0600 Subject: [PATCH 250/352] final readme --- functions/misc.sh | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/functions/misc.sh b/functions/misc.sh index ce13f395..7956fe53 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -52,31 +52,31 @@ echo "--dns | list all of your applications DNS names and their web po echo echo "Update Options" echo "--------------" -echo "-U | Update all applications, ignores versions" -echo "-U 5 | Same as above, but updates 5 applications at one time" -echo "-u | Update all applications, does not update Major releases" -echo "-u 5 | Same as above, but updates 5 applications at one time" +echo "-U | Update all applications, ignores versions" +echo "-U 5 | Same as above, but updates 5 applications at one time" +echo "-u | Update all applications, does not update Major releases" +echo "-u 5 | Same as above, but updates 5 applications at one time" echo echo "Additional Update Options" echo "-------------------------" -echo "-b | Back-up your ix-applications dataset, specify a number after -b" -echo "-i | Add application to ignore list, one by one, see example below." -echo "-r | Roll-back applications if they fail to update" -echo "-S | Shutdown applications prior to updating" -echo "-v | verbose output" -echo "-t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" -echo "-s | sync catalog" -echo "-p | Prune unused/old docker images" +echo "-b 14 | Back-up your ix-applications dataset, specify a number after -b" +echo "-i | Add application to ignore list, one by one, see example below." +echo "-r | Roll-back applications if they fail to update" +echo "-S | Shutdown applications prior to updating" +echo "-v | verbose output" +echo "-t 500| Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" +echo "-s | sync catalog" +echo "-p | Prune unused/old docker images" echo echo "Examples" echo "--------" -echo "bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vrsUp" -echo "bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -i radarr -t 600 -vrsp -U 10" +echo "bash heavy_script.sh" +echo "bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -t 600 -vrsUp" +echo "bash heavy_script.sh -b 14 -i portainer -i arch -i sonarr -t 600 -vrsp -U 10" echo "bash /mnt/tank/scripts/heavy_script.sh -t 150 --mount" echo "bash /mnt/tank/scripts/heavy_script.sh --dns" echo "bash heavy_script.sh --restore" echo "bash /mnt/tank/scripts/heavy_script.sh --delete-backup" -echo "bash heavy_script.sh" echo exit } From 84f272abde456e8137ca62e15e9bcf95de3190a6 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 22:45:12 -0600 Subject: [PATCH 251/352] attempt case --- functions/menu.sh | 103 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 73 insertions(+), 30 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index f78bbb6b..c13c7247 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -35,7 +35,7 @@ case $selection in 4) read -rt 600 -p "What is the maximun number of backups you would like?: " number_of_backups backup="true" - ;; + ;; 5) restore="true" ;; @@ -123,47 +123,90 @@ case $selection in echo read -rt 600 -p "Please type the number associated with the flag above: " current_selection - if [[ $current_selection == 0 ]]; then - clear -x - echo "Running \"bash heavy_script.sh ${update_selection[*]}\"" - echo - exec bash "$script_name" "${update_selection[@]}" - exit - elif [[ $current_selection == 1 ]]; then + case $current_selection in + 0) + clear -x + echo "Running \"bash heavy_script.sh ${update_selection[*]}\"" + echo + exec bash "$script_name" "${update_selection[@]}" + exit + ;; + 1) echo "Up to how many backups should we keep?" read -rt 600 -p "Please type an integer: " up_backups ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 5 && continue - update_selection+=("-b" "$up_backups") - elif [[ $current_selection == 2 ]]; then - read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore + ;; + 2) + read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore + update_selection+=("-i" "$up_ignore") + ;; + 3) + update_selection+=("-r") + ;; + 4) + update_selection+=("-S") + ;; + 5) + update_selection+=("-v") + ;; + 6) + echo "What do you want your timeout to be?" + read -rt 600 -p "Please type an integer: " up_timeout + ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue + ;; + 7) + update_selection+=("-s") + ;; + 8) + update_selection+=("-p") + ;; + *) + echo "$current_selection was not an option, try again" && sleep 5 && continue + ;; + esac + # if [[ $current_selection == 0 ]]; then + # clear -x + # echo "Running \"bash heavy_script.sh ${update_selection[*]}\"" + # echo + # exec bash "$script_name" "${update_selection[@]}" + # exit + # elif [[ $current_selection == 1 ]]; then + # echo "Up to how many backups should we keep?" + # read -rt 600 -p "Please type an integer: " up_backups + # ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue + # [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 5 && continue - update_selection+=("-i" "$up_ignore") - elif [[ $current_selection == 3 ]]; then + # update_selection+=("-b" "$up_backups") + # elif [[ $current_selection == 2 ]]; then + # read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore - update_selection+=("-r") - elif [[ $current_selection == 4 ]]; then + # update_selection+=("-i" "$up_ignore") + # elif [[ $current_selection == 3 ]]; then - update_selection+=("-S") - elif [[ $current_selection == 5 ]]; then + # update_selection+=("-r") + # elif [[ $current_selection == 4 ]]; then - update_selection+=("-v") - elif [[ $current_selection == 6 ]]; then - echo "What do you want your timeout to be?" - read -rt 600 -p "Please type an integer: " up_timeout - ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue + # update_selection+=("-S") + # elif [[ $current_selection == 5 ]]; then - update_selection+=("-t" "$up_timeout") - elif [[ $current_selection == 7 ]]; then + # update_selection+=("-v") + # elif [[ $current_selection == 6 ]]; then + # echo "What do you want your timeout to be?" + # read -rt 600 -p "Please type an integer: " up_timeout + # ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue - update_selection+=("-s") - elif [[ $current_selection == 8 ]]; then + # update_selection+=("-t" "$up_timeout") + # elif [[ $current_selection == 7 ]]; then - update_selection+=("-p") - else - echo "$current_selection was not an option, try again" && sleep 5 && continue - fi + # update_selection+=("-s") + # elif [[ $current_selection == 8 ]]; then + + # update_selection+=("-p") + # else + # echo "$current_selection was not an option, try again" && sleep 5 && continue + # fi done ;; *) From 42282b5017fd052ef63d4c302c06bbdca1d105d3 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 22:46:58 -0600 Subject: [PATCH 252/352] success --- functions/menu.sh | 51 +++++------------------------------------------ 1 file changed, 5 insertions(+), 46 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index c13c7247..d011a072 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -132,11 +132,11 @@ case $selection in exit ;; 1) - echo "Up to how many backups should we keep?" - read -rt 600 -p "Please type an integer: " up_backups - ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue - [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 5 && continue - update_selection+=("-b" "$up_backups") + echo "Up to how many backups should we keep?" + read -rt 600 -p "Please type an integer: " up_backups + ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue + [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 5 && continue + update_selection+=("-b" "$up_backups") ;; 2) read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore @@ -166,47 +166,6 @@ case $selection in echo "$current_selection was not an option, try again" && sleep 5 && continue ;; esac - # if [[ $current_selection == 0 ]]; then - # clear -x - # echo "Running \"bash heavy_script.sh ${update_selection[*]}\"" - # echo - # exec bash "$script_name" "${update_selection[@]}" - # exit - # elif [[ $current_selection == 1 ]]; then - # echo "Up to how many backups should we keep?" - # read -rt 600 -p "Please type an integer: " up_backups - # ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue - # [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 5 && continue - - # update_selection+=("-b" "$up_backups") - # elif [[ $current_selection == 2 ]]; then - # read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore - - # update_selection+=("-i" "$up_ignore") - # elif [[ $current_selection == 3 ]]; then - - # update_selection+=("-r") - # elif [[ $current_selection == 4 ]]; then - - # update_selection+=("-S") - # elif [[ $current_selection == 5 ]]; then - - # update_selection+=("-v") - # elif [[ $current_selection == 6 ]]; then - # echo "What do you want your timeout to be?" - # read -rt 600 -p "Please type an integer: " up_timeout - # ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue - - # update_selection+=("-t" "$up_timeout") - # elif [[ $current_selection == 7 ]]; then - - # update_selection+=("-s") - # elif [[ $current_selection == 8 ]]; then - - # update_selection+=("-p") - # else - # echo "$current_selection was not an option, try again" && sleep 5 && continue - # fi done ;; *) From 39b7928f68e9faef723d0ad1c640f35851858f14 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 22:48:46 -0600 Subject: [PATCH 253/352] cleaning --- functions/menu.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index d011a072..e15fbe31 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -163,13 +163,13 @@ case $selection in update_selection+=("-p") ;; *) - echo "$current_selection was not an option, try again" && sleep 5 && continue + echo "\"$OPTARG\" was not an option, try again" && sleep 5 && continue ;; esac done ;; *) - echo "That was not an option, please try agian" && sleep 5 && menu + echo "\"$OPTARG\" was not an option, please try agian" && sleep 5 && menu ;; esac echo From e83e7c8a80e0c1557276002e70cae84db79bbaf8 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 22:50:00 -0600 Subject: [PATCH 254/352] test --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index e15fbe31..fbd46c27 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -97,7 +97,7 @@ case $selection in exit else echo "$current_selection was not an option, try again" - exit + continue fi done while true From e794d71be9318e95619230842363909ee2aebb2c Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 22:50:32 -0600 Subject: [PATCH 255/352] fix --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index fbd46c27..a5fa27f8 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -96,7 +96,7 @@ case $selection in echo "Exiting.." exit else - echo "$current_selection was not an option, try again" + echo "$current_selection was not an option, try again" && sleep 5 continue fi done From 7f210da6b8d3564e1a6dcb3d4bc12473edc9b953 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 22:53:05 -0600 Subject: [PATCH 256/352] fix --- functions/menu.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/menu.sh b/functions/menu.sh index a5fa27f8..f9bb003b 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -155,6 +155,7 @@ case $selection in echo "What do you want your timeout to be?" read -rt 600 -p "Please type an integer: " up_timeout ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue + update_selection+=("-i" "$up_timeout") ;; 7) update_selection+=("-s") From 63f1d6c477b5303b23c81b421e274932d45f7258 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 22:54:14 -0600 Subject: [PATCH 257/352] test --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index f9bb003b..83978694 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -155,7 +155,7 @@ case $selection in echo "What do you want your timeout to be?" read -rt 600 -p "Please type an integer: " up_timeout ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue - update_selection+=("-i" "$up_timeout") + update_selection+=("-t" "$up_timeout") ;; 7) update_selection+=("-s") From a44b250390d6e8d965bfafb38507e99477a548ff Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 23:00:12 -0600 Subject: [PATCH 258/352] test skip --- functions/menu.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/functions/menu.sh b/functions/menu.sh index 83978694..8f564350 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -137,6 +137,7 @@ case $selection in ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 5 && continue update_selection+=("-b" "$up_backups") + printf '%s\0' "${update_selection[@]}" | grep -iFxqz "$OPTARG" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it ;; 2) read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore @@ -144,24 +145,30 @@ case $selection in ;; 3) update_selection+=("-r") + printf '%s\0' "${update_selection[@]}" | grep -iFxqz "$OPTARG" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it ;; 4) update_selection+=("-S") + printf '%s\0' "${update_selection[@]}" | grep -iFxqz "$OPTARG" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it ;; 5) update_selection+=("-v") + printf '%s\0' "${update_selection[@]}" | grep -iFxqz "$OPTARG" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it ;; 6) echo "What do you want your timeout to be?" read -rt 600 -p "Please type an integer: " up_timeout ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue + printf '%s\0' "${update_selection[@]}" | grep -iFxqz "$OPTARG" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-t" "$up_timeout") ;; 7) update_selection+=("-s") + printf '%s\0' "${update_selection[@]}" | grep -iFxqz "$OPTARG" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it ;; 8) update_selection+=("-p") + printf '%s\0' "${update_selection[@]}" | grep -iFxqz "$OPTARG" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it ;; *) echo "\"$OPTARG\" was not an option, try again" && sleep 5 && continue From 0c7479801ed9881dc43607178fe0ebcdf3747fbf Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 23:02:45 -0600 Subject: [PATCH 259/352] fix --- functions/menu.sh | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 8f564350..04a6a66b 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -132,43 +132,44 @@ case $selection in exit ;; 1) + printf '%s\0' "${update_selection[@]}" | grep -iFxqz "-b" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it echo "Up to how many backups should we keep?" read -rt 600 -p "Please type an integer: " up_backups ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 5 && continue update_selection+=("-b" "$up_backups") - printf '%s\0' "${update_selection[@]}" | grep -iFxqz "$OPTARG" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it ;; 2) read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore update_selection+=("-i" "$up_ignore") ;; 3) + printf '%s\0' "${update_selection[@]}" | grep -iFxqz "-r" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-r") - printf '%s\0' "${update_selection[@]}" | grep -iFxqz "$OPTARG" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + ;; 4) + printf '%s\0' "${update_selection[@]}" | grep -iFxqz "-S" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-S") - printf '%s\0' "${update_selection[@]}" | grep -iFxqz "$OPTARG" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it ;; 5) + printf '%s\0' "${update_selection[@]}" | grep -iFxqz "-v" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-v") - printf '%s\0' "${update_selection[@]}" | grep -iFxqz "$OPTARG" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it ;; 6) + printf '%s\0' "${update_selection[@]}" | grep -iFxqz "-t" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it echo "What do you want your timeout to be?" read -rt 600 -p "Please type an integer: " up_timeout ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue - printf '%s\0' "${update_selection[@]}" | grep -iFxqz "$OPTARG" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-t" "$up_timeout") ;; 7) + printf '%s\0' "${update_selection[@]}" | grep -iFxqz "-s" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-s") - printf '%s\0' "${update_selection[@]}" | grep -iFxqz "$OPTARG" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it ;; 8) + printf '%s\0' "${update_selection[@]}" | grep -iFxqz "-p" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-p") - printf '%s\0' "${update_selection[@]}" | grep -iFxqz "$OPTARG" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it ;; *) echo "\"$OPTARG\" was not an option, try again" && sleep 5 && continue From 2f7169ee11deb0c5221d022adb6819cf69dcf630 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 23:05:41 -0600 Subject: [PATCH 260/352] uhh --- functions/menu.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 04a6a66b..a6a5eee0 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -132,7 +132,7 @@ case $selection in exit ;; 1) - printf '%s\0' "${update_selection[@]}" | grep -iFxqz "-b" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxqz '-b' && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it echo "Up to how many backups should we keep?" read -rt 600 -p "Please type an integer: " up_backups ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue @@ -144,31 +144,31 @@ case $selection in update_selection+=("-i" "$up_ignore") ;; 3) - printf '%s\0' "${update_selection[@]}" | grep -iFxqz "-r" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxqz "-r" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-r") ;; 4) - printf '%s\0' "${update_selection[@]}" | grep -iFxqz "-S" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxqz "-S" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-S") ;; 5) - printf '%s\0' "${update_selection[@]}" | grep -iFxqz "-v" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxqz "-v" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-v") ;; 6) - printf '%s\0' "${update_selection[@]}" | grep -iFxqz "-t" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxqz "-t" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it echo "What do you want your timeout to be?" read -rt 600 -p "Please type an integer: " up_timeout ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue update_selection+=("-t" "$up_timeout") ;; 7) - printf '%s\0' "${update_selection[@]}" | grep -iFxqz "-s" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxqz "-s" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-s") ;; 8) - printf '%s\0' "${update_selection[@]}" | grep -iFxqz "-p" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxqz "-p" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-p") ;; *) From 4e15a6ba3eede92cc2de7eca879b6bbe6ee20e93 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 23:07:06 -0600 Subject: [PATCH 261/352] asd --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index a6a5eee0..7d065b58 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -132,7 +132,7 @@ case $selection in exit ;; 1) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz '-b' && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxq '-b' && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it echo "Up to how many backups should we keep?" read -rt 600 -p "Please type an integer: " up_backups ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue From 20551b4df9b11513e806fbd370df92cf1125dda4 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 23:08:55 -0600 Subject: [PATCH 262/352] escape? --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index 7d065b58..60cb7dce 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -132,7 +132,7 @@ case $selection in exit ;; 1) - printf '%s\0' "${update_selection[@]}" | grep -Fxq '-b' && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxqz "\-b" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it echo "Up to how many backups should we keep?" read -rt 600 -p "Please type an integer: " up_backups ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue From b0b9bce10e49a2f7587ca6f5fac2fddc037e8e4b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 23:10:16 -0600 Subject: [PATCH 263/352] test --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index 60cb7dce..fc74d51b 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -132,7 +132,7 @@ case $selection in exit ;; 1) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz "\-b" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-b" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it echo "Up to how many backups should we keep?" read -rt 600 -p "Please type an integer: " up_backups ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue From edfe7542f213b87684fa6dab4f6f66e9aaf98583 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 23:12:02 -0600 Subject: [PATCH 264/352] woo --- functions/menu.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index fc74d51b..b01f93b9 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -132,7 +132,7 @@ case $selection in exit ;; 1) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-b" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-b" && echo -e "\"-b\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it echo "Up to how many backups should we keep?" read -rt 600 -p "Please type an integer: " up_backups ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue @@ -144,31 +144,31 @@ case $selection in update_selection+=("-i" "$up_ignore") ;; 3) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz "-r" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-r" && echo -e "\"-r\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-r") ;; 4) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz "-S" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-S" && echo -e "\"-S\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-S") ;; 5) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz "-v" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-v" && echo -e "\"-v\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-v") ;; 6) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz "-t" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-t" && echo -e "\"-t\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it echo "What do you want your timeout to be?" read -rt 600 -p "Please type an integer: " up_timeout ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue update_selection+=("-t" "$up_timeout") ;; 7) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz "-s" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-s" && echo -e "\"-s\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-s") ;; 8) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz "-p" && echo -e "$OPTARG is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-p" && echo -e "\"-p\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-p") ;; *) From 10d6336671956813b7d8541a07fdeaa2b53777c3 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 23:21:10 -0600 Subject: [PATCH 265/352] test --- functions/menu.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/functions/menu.sh b/functions/menu.sh index b01f93b9..0e5310b9 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -171,6 +171,16 @@ case $selection in printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-p" && echo -e "\"-p\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-p") ;; + 99) + count=1 + echo "restarting" + for i in "${update_selection[@]:1}" + do + unset "update_selection[$count]" + echo "$i removed" + done + continue + ;; *) echo "\"$OPTARG\" was not an option, try again" && sleep 5 && continue ;; From 9f20f36d299f2eaef9578f7362a27defa8ef88a3 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 23:22:55 -0600 Subject: [PATCH 266/352] test --- functions/menu.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 0e5310b9..de2182d4 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -172,12 +172,13 @@ case $selection in update_selection+=("-p") ;; 99) - count=1 + count=2 echo "restarting" - for i in "${update_selection[@]:1}" + for i in "${update_selection[@]:2}" do unset "update_selection[$count]" echo "$i removed" + ((count++)) done continue ;; From 20ed6d7babae07399c9274a3be7c2c9e406af4ae Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 23:25:08 -0600 Subject: [PATCH 267/352] test --- functions/menu.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index de2182d4..b4145a9d 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -115,7 +115,8 @@ case $selection in echo "7) -s | sync catalog" echo "8) -p | Prune unused/old docker images" echo - echo "0) Done making selections, proceed with update" + echo "99) Remove Update Options, Restart" + echo "00) Done making selections, proceed with update" echo echo "Current Choices" echo "---------------" @@ -124,7 +125,7 @@ case $selection in read -rt 600 -p "Please type the number associated with the flag above: " current_selection case $current_selection in - 0) + 00) clear -x echo "Running \"bash heavy_script.sh ${update_selection[*]}\"" echo @@ -180,6 +181,7 @@ case $selection in echo "$i removed" ((count++)) done + sleep 5 continue ;; *) From f97d4be4815e3b8135a6dbdb03ebe11c0be6d950 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 23:34:50 -0600 Subject: [PATCH 268/352] correct var --- functions/menu.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index b4145a9d..057a700f 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -185,13 +185,13 @@ case $selection in continue ;; *) - echo "\"$OPTARG\" was not an option, try again" && sleep 5 && continue + echo "\"$current_selection\" was not an option, try again" && sleep 5 && continue ;; esac done ;; *) - echo "\"$OPTARG\" was not an option, please try agian" && sleep 5 && menu + echo "\"$selection\" was not an option, please try agian" && sleep 5 && menu ;; esac echo From 767c18a62a42206e71ecb6e0f6c617425e55c33f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 23:40:48 -0600 Subject: [PATCH 269/352] optional flag --- functions/menu.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 057a700f..ff127da7 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -132,7 +132,7 @@ case $selection in exec bash "$script_name" "${update_selection[@]}" exit ;; - 1) + 1 | -b) printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-b" && echo -e "\"-b\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it echo "Up to how many backups should we keep?" read -rt 600 -p "Please type an integer: " up_backups @@ -140,35 +140,35 @@ case $selection in [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 5 && continue update_selection+=("-b" "$up_backups") ;; - 2) + 2 | -i) read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore update_selection+=("-i" "$up_ignore") ;; - 3) + 3 | -r) printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-r" && echo -e "\"-r\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-r") ;; - 4) + 4 | -S) printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-S" && echo -e "\"-S\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-S") ;; - 5) + 5 | -v) printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-v" && echo -e "\"-v\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-v") ;; - 6) + 6 | -t) printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-t" && echo -e "\"-t\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it echo "What do you want your timeout to be?" read -rt 600 -p "Please type an integer: " up_timeout ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue update_selection+=("-t" "$up_timeout") ;; - 7) + 7 | -s) printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-s" && echo -e "\"-s\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-s") ;; - 8) + 8 | -p) printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-p" && echo -e "\"-p\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-p") ;; From e38c9c65d4f2007151736f655fa2d4bbc4f82603 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 26 Jul 2022 23:42:30 -0600 Subject: [PATCH 270/352] done for the night --- functions/menu.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index ff127da7..1ac5659e 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -123,7 +123,6 @@ case $selection in echo "bash heavy_script.sh ${update_selection[*]}" echo read -rt 600 -p "Please type the number associated with the flag above: " current_selection - case $current_selection in 00) clear -x From 97b65f746d776f821c767ab27d9a4cf8eb401472 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 09:47:19 -0600 Subject: [PATCH 271/352] cd to script --- heavy_script.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/heavy_script.sh b/heavy_script.sh index 27abd6f7..a4552ac3 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -1,5 +1,9 @@ #!/bin/bash +# cd to script +script=$(readlink -f "$0") +script_path=$(dirname "$script") +cd "$script_path" || exit # shellcheck source=functions/backup.sh source functions/backup.sh From 27eb8b0e61199c5ec6837c34265c3f5827e1f04c Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 10:03:34 -0600 Subject: [PATCH 272/352] polish format --- functions/misc.sh | 4 ++-- functions/update_apps.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/misc.sh b/functions/misc.sh index 7956fe53..663e93cc 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -2,7 +2,7 @@ sync(){ -echo_sync+=("\nSync Output") +echo_sync+=("\n\nSync Output") echo_sync+=("-----------") cli -c 'app catalog sync_all' &> /dev/null && echo_sync+=("Catalog sync complete") @@ -15,7 +15,7 @@ done export -f sync prune(){ -echo -e "\nDocker Prune Output" +echo -e "\n\nDocker Prune Output" echo "-------------------" echo "Pruned Docker Images" docker image prune -af | grep "^Total" || echo "Failed to Prune Docker Images" diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 92aeab24..6fe1e875 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -3,7 +3,7 @@ commander(){ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | tr -d " \t\r" | grep -E ",true($|,)" | sort) -echo -e "\nAplication Update Output" +echo -e "\n\nAplication Update Output" echo "------------------------" [[ -z $array ]] && echo "There are no updates available" && return 0 || echo "${#array[@]} update(s) available" [[ -z $timeout ]] && echo "Default Timeout: 500" && timeout=500 || echo "Custom Timeout: $timeout" From 425564e75217f6e87a93597ea014aa33df76ee92 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 10:27:12 -0600 Subject: [PATCH 273/352] description --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index a4552ac3..18a08b36 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -1,6 +1,6 @@ #!/bin/bash -# cd to script +# cd to script, this ensures the script can find the source scripts below, even when ran from a seperate directory script=$(readlink -f "$0") script_path=$(dirname "$script") cd "$script_path" || exit From dfe359e34aadd34f25c570b9ff9e835c65930a18 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 10:31:43 -0600 Subject: [PATCH 274/352] silencing shellcheck --- functions/mount.sh | 2 +- functions/update_apps.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/mount.sh b/functions/mount.sh index 88d9af21..b7576ca9 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -39,7 +39,7 @@ if [[ $selection == "1" ]]; then exit elif [[ $selection == "2" ]]; then mapfile -t unmount_array < <(basename -a /mnt/heavyscript/* | sed "s/*//") - [[ -z $unmount_array ]] && echo "Theres nothing to unmount" && exit + [[ -z ${unmount_array[*]} ]] && echo "Theres nothing to unmount" && exit for i in "${unmount_array[@]}" do main=$(k3s kubectl get pvc -A | grep -E "\s$i\s" | awk '{print $1, $2, $4}') diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 6fe1e875..64104df1 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -5,7 +5,7 @@ commander(){ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | tr -d " \t\r" | grep -E ",true($|,)" | sort) echo -e "\n\nAplication Update Output" echo "------------------------" -[[ -z $array ]] && echo "There are no updates available" && return 0 || echo "${#array[@]} update(s) available" +[[ -z ${array[*]} ]] && echo "There are no updates available" && return 0 || echo "${#array[@]} update(s) available" [[ -z $timeout ]] && echo "Default Timeout: 500" && timeout=500 || echo "Custom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" echo "Asynchronous Updates: $update_limit" From d340f3164d50af24d2099e4c2c6c1d9c682795c4 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 13:00:22 -0600 Subject: [PATCH 275/352] parent shell updates status --- functions/update_apps.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 92aeab24..06dabee1 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -13,6 +13,7 @@ echo "Asynchronous Updates: $update_limit" it=0 while [[ $it -lt ${#array[@]} ]] do + status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status') proc_count=${#processes[@]} count=0 for proc in "${processes[@]}" @@ -20,7 +21,7 @@ do kill -0 "$proc" &> /dev/null || { unset "processes[$count]"; ((proc_count--)); } done if [[ "$proc_count" -ge "$update_limit" ]]; then - sleep 1 + sleep 3 else update_apps "${array[$it]}" & processes+=($!) @@ -43,8 +44,7 @@ old_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{prin new_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version old_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version new_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # New Chart MAJOR version -status=$(echo "${array[$it]}" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE -startstatus=$status +startstatus=$(echo "${array[$it]}" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE diff_app=$(diff <(echo "$old_app_ver") <(echo "$new_app_ver")) #caluclating difference in major app versions diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclating difference in Chart versions old_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}') #Upgraded From @@ -52,7 +52,7 @@ new_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}') #Upraded To rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not - if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop + if [[ "$startstatus" == "STOPPED" ]]; then # if status is already stopped, skip while loop echo_array+=("\n$app_name") [[ "$verbose" == "true" ]] && echo_array+=("Updating..") cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=("Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo_array+=("FAILED") @@ -61,9 +61,9 @@ rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' ' echo_array+=("\n$app_name") [[ "$verbose" == "true" ]] && echo_array+=("Stopping prior to update..") midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && SECONDS=0 || echo_array+=("FAILED") - while [[ "$status" != "STOPPED" ]] + while [[ "$startstatus" != "STOPPED" ]] do - status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') + #status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') if [[ "$status" == "STOPPED" ]]; then echo_array+=("Stopped") [[ "$verbose" == "true" ]] && echo_array+=("Updating..") @@ -98,7 +98,7 @@ if [[ $rollback == "true" ]]; then while true do (( count++ )) - status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') + status=$(echo "$status" | grep "^$app_name," | awk -F ',' '{print $2}') if [[ "$status" == "ACTIVE" && "$startstatus" == "STOPPED" ]]; then [[ "$verbose" == "true" ]] && echo_array+=("Returing to STOPPED state..") midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && echo_array+=("Stopped")|| echo_array+=("FAILED") @@ -130,7 +130,7 @@ else while true #using a constant while loop, then breaking out of the loop with break commands below. do (( count++ )) - status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') + status=$(echo "$status" | grep "^$app_name," | awk -F ',' '{print $2}') if [[ "$status" == "STOPPED" ]]; then [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 15 && continue #if reports stopped on FIRST time through loop, double check [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check From 6dc96419f464ac594bf9e48d04beb2c6ac77ccfd Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 13:09:10 -0600 Subject: [PATCH 276/352] pos fix --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 90952be1..f8efb24d 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -63,7 +63,7 @@ rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' ' midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && SECONDS=0 || echo_array+=("FAILED") while [[ "$startstatus" != "STOPPED" ]] do - #status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') + status=$(echo "$status" | grep "^$app_name," | awk -F ',' '{print $2}') if [[ "$status" == "STOPPED" ]]; then echo_array+=("Stopped") [[ "$verbose" == "true" ]] && echo_array+=("Updating..") From 8ff5886a9990e4779a4ae89001463349c7c68221 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 13:16:11 -0600 Subject: [PATCH 277/352] test --- functions/update_apps.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index f8efb24d..2522c2c1 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -11,7 +11,7 @@ echo "------------------------" echo "Asynchronous Updates: $update_limit" it=0 -while [[ $it -lt ${#array[@]} ]] +while true do status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status') proc_count=${#processes[@]} @@ -20,7 +20,9 @@ do do kill -0 "$proc" &> /dev/null || { unset "processes[$count]"; ((proc_count--)); } done - if [[ "$proc_count" -ge "$update_limit" ]]; then + if [[ $it -eq ${#array[@]} && ${#processes[@]} == 0 ]]; then + break + elif [[ "$proc_count" -ge "$update_limit" ]]; then sleep 3 else update_apps "${array[$it]}" & From 8a61eb1f8aef9ef4e71a34f69d9d5b2c6fff69bb Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 13:27:04 -0600 Subject: [PATCH 278/352] export --- functions/update_apps.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 2522c2c1..548a599b 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -14,6 +14,7 @@ it=0 while true do status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status') + export status proc_count=${#processes[@]} count=0 for proc in "${processes[@]}" From e12b72a97b58cae456d7b93853f856f46206c9b9 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 13:47:44 -0600 Subject: [PATCH 279/352] revert changes --- functions/update_apps.sh | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 548a599b..64104df1 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -11,20 +11,16 @@ echo "------------------------" echo "Asynchronous Updates: $update_limit" it=0 -while true +while [[ $it -lt ${#array[@]} ]] do - status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status') - export status proc_count=${#processes[@]} count=0 for proc in "${processes[@]}" do kill -0 "$proc" &> /dev/null || { unset "processes[$count]"; ((proc_count--)); } done - if [[ $it -eq ${#array[@]} && ${#processes[@]} == 0 ]]; then - break - elif [[ "$proc_count" -ge "$update_limit" ]]; then - sleep 3 + if [[ "$proc_count" -ge "$update_limit" ]]; then + sleep 1 else update_apps "${array[$it]}" & processes+=($!) @@ -47,7 +43,8 @@ old_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{prin new_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version old_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version new_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # New Chart MAJOR version -startstatus=$(echo "${array[$it]}" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE +status=$(echo "${array[$it]}" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE +startstatus=$status diff_app=$(diff <(echo "$old_app_ver") <(echo "$new_app_ver")) #caluclating difference in major app versions diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclating difference in Chart versions old_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}') #Upgraded From @@ -55,7 +52,7 @@ new_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}') #Upraded To rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not - if [[ "$startstatus" == "STOPPED" ]]; then # if status is already stopped, skip while loop + if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop echo_array+=("\n$app_name") [[ "$verbose" == "true" ]] && echo_array+=("Updating..") cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=("Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo_array+=("FAILED") @@ -64,9 +61,9 @@ rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' ' echo_array+=("\n$app_name") [[ "$verbose" == "true" ]] && echo_array+=("Stopping prior to update..") midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && SECONDS=0 || echo_array+=("FAILED") - while [[ "$startstatus" != "STOPPED" ]] + while [[ "$status" != "STOPPED" ]] do - status=$(echo "$status" | grep "^$app_name," | awk -F ',' '{print $2}') + status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') if [[ "$status" == "STOPPED" ]]; then echo_array+=("Stopped") [[ "$verbose" == "true" ]] && echo_array+=("Updating..") @@ -101,7 +98,7 @@ if [[ $rollback == "true" ]]; then while true do (( count++ )) - status=$(echo "$status" | grep "^$app_name," | awk -F ',' '{print $2}') + status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') if [[ "$status" == "ACTIVE" && "$startstatus" == "STOPPED" ]]; then [[ "$verbose" == "true" ]] && echo_array+=("Returing to STOPPED state..") midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && echo_array+=("Stopped")|| echo_array+=("FAILED") @@ -133,7 +130,7 @@ else while true #using a constant while loop, then breaking out of the loop with break commands below. do (( count++ )) - status=$(echo "$status" | grep "^$app_name," | awk -F ',' '{print $2}') + status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') if [[ "$status" == "STOPPED" ]]; then [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 15 && continue #if reports stopped on FIRST time through loop, double check [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check From cb25487dffe11eb93e6acd71e90d6e684f7e7e80 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 13:56:22 -0600 Subject: [PATCH 280/352] test file method --- functions/update_apps.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 64104df1..f609ef01 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -10,9 +10,11 @@ echo "------------------------" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" echo "Asynchronous Updates: $update_limit" +touch temp.txt it=0 while [[ $it -lt ${#array[@]} ]] do + cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' > temp.txt proc_count=${#processes[@]} count=0 for proc in "${processes[@]}" @@ -20,13 +22,14 @@ do kill -0 "$proc" &> /dev/null || { unset "processes[$count]"; ((proc_count--)); } done if [[ "$proc_count" -ge "$update_limit" ]]; then - sleep 1 + sleep 3 else update_apps "${array[$it]}" & processes+=($!) ((it++)) fi done +rm temp.txt for proc in "${processes[@]}" do @@ -63,7 +66,7 @@ rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' ' midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && SECONDS=0 || echo_array+=("FAILED") while [[ "$status" != "STOPPED" ]] do - status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') + status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') if [[ "$status" == "STOPPED" ]]; then echo_array+=("Stopped") [[ "$verbose" == "true" ]] && echo_array+=("Updating..") @@ -98,7 +101,7 @@ if [[ $rollback == "true" ]]; then while true do (( count++ )) - status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') + status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') if [[ "$status" == "ACTIVE" && "$startstatus" == "STOPPED" ]]; then [[ "$verbose" == "true" ]] && echo_array+=("Returing to STOPPED state..") midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && echo_array+=("Stopped")|| echo_array+=("FAILED") @@ -130,7 +133,7 @@ else while true #using a constant while loop, then breaking out of the loop with break commands below. do (( count++ )) - status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') + status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') if [[ "$status" == "STOPPED" ]]; then [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 15 && continue #if reports stopped on FIRST time through loop, double check [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check From 2fd4d0a92698f18cb9c4b93f6ee4fdca150c960e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 14:13:40 -0600 Subject: [PATCH 281/352] test --- functions/update_apps.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index f609ef01..efb9d9a3 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -12,7 +12,7 @@ echo "Asynchronous Updates: $update_limit" touch temp.txt it=0 -while [[ $it -lt ${#array[@]} ]] +while true do cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' > temp.txt proc_count=${#processes[@]} @@ -23,18 +23,20 @@ do done if [[ "$proc_count" -ge "$update_limit" ]]; then sleep 3 - else + elif [[ $it -lt ${#array[@]} ]]; then update_apps "${array[$it]}" & processes+=($!) ((it++)) + else + for proc in "${processes[@]}" + do + wait "$proc" + done + break fi done rm temp.txt -for proc in "${processes[@]}" -do - wait "$proc" -done } export -f commander From eb50e56e6bf79d031666fe4cb9a5b863f5ebc0d0 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 14:36:23 -0600 Subject: [PATCH 282/352] test --- functions/update_apps.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index efb9d9a3..94f525ec 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -27,12 +27,10 @@ do update_apps "${array[$it]}" & processes+=($!) ((it++)) - else - for proc in "${processes[@]}" - do - wait "$proc" - done + elif [[ ${#processes[@]} == 0 ]]; then break + else + sleep 3 fi done rm temp.txt From 3da75f299d1a5e9b770a2066fbdbfb38a669aa23 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 14:40:46 -0600 Subject: [PATCH 283/352] test --- functions/update_apps.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 94f525ec..36f5719b 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -14,7 +14,8 @@ touch temp.txt it=0 while true do - cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' > temp.txt + while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status') + echo "$while_status" > temp.txt proc_count=${#processes[@]} count=0 for proc in "${processes[@]}" From ef43d3c214153e5dac21d596a57001a2f4e640c4 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 14:50:52 -0600 Subject: [PATCH 284/352] test --- functions/update_apps.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 36f5719b..472ded56 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -28,10 +28,10 @@ do update_apps "${array[$it]}" & processes+=($!) ((it++)) - elif [[ ${#processes[@]} == 0 ]]; then - break - else + elif [[ ${#processes[@]} != 0 ]]; then # Wait for all processes to finish sleep 3 + else + break fi done rm temp.txt From fd21a80db09334840e54d7319cdcc68691461fea Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 15:07:53 -0600 Subject: [PATCH 285/352] test --- functions/update_apps.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 472ded56..a856a945 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -21,6 +21,7 @@ do for proc in "${processes[@]}" do kill -0 "$proc" &> /dev/null || { unset "processes[$count]"; ((proc_count--)); } + ((count++)) done if [[ "$proc_count" -ge "$update_limit" ]]; then sleep 3 @@ -28,9 +29,10 @@ do update_apps "${array[$it]}" & processes+=($!) ((it++)) - elif [[ ${#processes[@]} != 0 ]]; then # Wait for all processes to finish + elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 3 - else + else # All processes must be completed, break out of loop + wait "${processes[*]}" break fi done From cf2f5000ee4f19ce8d912c3f82e3232776f159ab Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 15:23:56 -0600 Subject: [PATCH 286/352] test --- functions/update_apps.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index a856a945..05e62519 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -32,7 +32,9 @@ do elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 3 else # All processes must be completed, break out of loop - wait "${processes[*]}" + for proc in "${processes[@]}"; do + wait "$proc" + done break fi done From 2f180d1a4b33ceed6d8aa411c75f2da7f778a699 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 15:34:00 -0600 Subject: [PATCH 287/352] remove for loop --- functions/update_apps.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 05e62519..88018f7d 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -32,9 +32,10 @@ do elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 3 else # All processes must be completed, break out of loop - for proc in "${processes[@]}"; do - wait "$proc" - done + # Unessesary for loop. since processes have to be completed before getting to this point, it is unlikely we would ever have to wait on processes.. Will test more. + # for proc in "${processes[@]}"; do + # wait "$proc" + # done break fi done From 3bffd42f8cc7e63b7adafe39123e06ab06f33543 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 15:47:11 -0600 Subject: [PATCH 288/352] remove var --- functions/update_apps.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 88018f7d..a4dbdb72 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -52,8 +52,7 @@ old_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{prin new_app_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version old_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # Old Chart MAJOR version new_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{print $2}' | awk -F '.' '{print $1}') # New Chart MAJOR version -status=$(echo "${array[$it]}" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE -startstatus=$status +startstatus=$(echo "${array[$it]}" | awk -F ',' '{print $2}') #status of the app: STOPPED / DEPLOYING / ACTIVE diff_app=$(diff <(echo "$old_app_ver") <(echo "$new_app_ver")) #caluclating difference in major app versions diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclating difference in Chart versions old_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}') #Upgraded From @@ -61,7 +60,7 @@ new_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}') #Upraded To rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not - if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop + if [[ "$startstatus" == "STOPPED" ]]; then # if status is already stopped, skip while loop echo_array+=("\n$app_name") [[ "$verbose" == "true" ]] && echo_array+=("Updating..") cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=("Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo_array+=("FAILED") From 12218c4976925c0bf246fffdd518f96fd3fff18e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 16:35:16 -0600 Subject: [PATCH 289/352] remove touch --- functions/update_apps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index a4dbdb72..d2f00837 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -10,7 +10,7 @@ echo "------------------------" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" echo "Asynchronous Updates: $update_limit" -touch temp.txt + it=0 while true do From f52ef399d47782167ca5c909310ec7d3d96c5748 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 16:40:44 -0600 Subject: [PATCH 290/352] better format --- functions/update_apps.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index d2f00837..30c197ea 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -5,10 +5,10 @@ commander(){ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | tr -d " \t\r" | grep -E ",true($|,)" | sort) echo -e "\n\nAplication Update Output" echo "------------------------" -[[ -z ${array[*]} ]] && echo "There are no updates available" && return 0 || echo "${#array[@]} update(s) available" +[[ -z ${array[*]} ]] && echo "There are no updates available" && return 0 || echo "Update(s) Available: ${#array[@]}" +echo "Asynchronous Updates: $update_limit" [[ -z $timeout ]] && echo "Default Timeout: 500" && timeout=500 || echo "Custom Timeout: $timeout" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" -echo "Asynchronous Updates: $update_limit" it=0 From e365429ee48e8e47672e822f8fa55b22ed40a020 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 16:51:23 -0600 Subject: [PATCH 291/352] better mount message --- functions/mount.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/mount.sh b/functions/mount.sh index b7576ca9..880ffce4 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -29,7 +29,7 @@ if [[ $selection == "1" ]]; then volume_name=$(echo "$pvc" | awk '{print $4}') mapfile -t full_path < <(zfs list | grep "$volume_name" | awk '{print $1}') if [[ "${#full_path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. - echo "$app is a name used on more than one pool.. attempting to use your current kubernetes apps pool" + echo "$app is using the same volume identifier on more than one pool.. attempting to use your current kubernetes apps pool" pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") full_path=$(zfs list | grep "$volume_name" | grep "$pool" | awk '{print $1}') fi From 6c9bd67e42f1e8578b6fd29a86bcccf82cb4132d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 16:56:29 -0600 Subject: [PATCH 292/352] rm cd from selfupdate --- functions/self_update.sh | 4 ---- heavy_script.sh | 2 ++ 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 20461d04..cd56e705 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -3,10 +3,6 @@ args=("$@") self_update() { -script=$(readlink -f "$0") -script_path=$(dirname "$script") -script_name="heavy_script.sh" -cd "$script_path" || exit git fetch &> /dev/null # TODO: change beta to main once testing is complete if git diff --name-only origin/beta | grep -qs ".sh" ; then diff --git a/heavy_script.sh b/heavy_script.sh index 18a08b36..4b99e646 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -3,8 +3,10 @@ # cd to script, this ensures the script can find the source scripts below, even when ran from a seperate directory script=$(readlink -f "$0") script_path=$(dirname "$script") +script_name="heavy_script.sh" cd "$script_path" || exit + # shellcheck source=functions/backup.sh source functions/backup.sh # shellcheck source=functions/dns.sh From 5ac2b76c32769abd77a2023172742087b365f92e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 16:57:24 -0600 Subject: [PATCH 293/352] test change --- functions/self_update.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index cd56e705..fac45a1e 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -1,7 +1,6 @@ #!/bin/bash args=("$@") - self_update() { git fetch &> /dev/null # TODO: change beta to main once testing is complete From 6902e15c9cfa599839ff0f014b6b20d39de6c62f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 17:03:03 -0600 Subject: [PATCH 294/352] better message --- heavy_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/heavy_script.sh b/heavy_script.sh index 4b99e646..024aec0c 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -4,7 +4,7 @@ script=$(readlink -f "$0") script_path=$(dirname "$script") script_name="heavy_script.sh" -cd "$script_path" || exit +cd "$script_path" || { echo "Error: Failed to change to script directory" ; exit ; } # shellcheck source=functions/backup.sh From d88762ea57019e8f2cb46f9871072310b80efc4a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 20:05:28 -0600 Subject: [PATCH 295/352] cleanup --- functions/update_apps.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 30c197ea..eb517a92 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -32,10 +32,6 @@ do elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 3 else # All processes must be completed, break out of loop - # Unessesary for loop. since processes have to be completed before getting to this point, it is unlikely we would ever have to wait on processes.. Will test more. - # for proc in "${processes[@]}"; do - # wait "$proc" - # done break fi done From ca8d3f5b4e66de2cf1114a49e591896823bdb4fc Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 13:31:48 -0600 Subject: [PATCH 296/352] fancy titles --- functions/backup.sh | 3 +-- functions/misc.sh | 6 ++---- functions/update_apps.sh | 3 +-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index f7626653..56656b9d 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -2,8 +2,7 @@ backup(){ -echo_backup+=("\nBackup Output") -echo_backup+=("--------------") +echo_backup+=("\n🄱 🄰 🄲 🄺 🅄 🄿 🅂") echo_backup+=("Number of backups was set to $number_of_backups") date=$(date '+%Y_%m_%d_%H_%M_%S') [[ "$verbose" == "true" ]] && cli -c 'app kubernetes backup_chart_releases backup_name=''"'HeavyScript_"$date"'"' &> /dev/null && echo_backup+=(HeavyScript_"$date") diff --git a/functions/misc.sh b/functions/misc.sh index 663e93cc..baa1583b 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -2,8 +2,7 @@ sync(){ -echo_sync+=("\n\nSync Output") -echo_sync+=("-----------") +echo_sync+=("\n\n🅂 🅈 🄽 🄲") cli -c 'app catalog sync_all' &> /dev/null && echo_sync+=("Catalog sync complete") #Dump the echo_array, ensures all output is in a neat order. @@ -15,8 +14,7 @@ done export -f sync prune(){ -echo -e "\n\nDocker Prune Output" -echo "-------------------" +echo -e "\n\n🄳 🄾 🄲 🄺 🄴 🅁 🄿 🅁 🅄 🄽 🄴" echo "Pruned Docker Images" docker image prune -af | grep "^Total" || echo "Failed to Prune Docker Images" } diff --git a/functions/update_apps.sh b/functions/update_apps.sh index eb517a92..460877eb 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -3,8 +3,7 @@ commander(){ mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | tr -d " \t\r" | grep -E ",true($|,)" | sort) -echo -e "\n\nAplication Update Output" -echo "------------------------" +echo -e "\n\n🅄 🄿 🄳 🄰 🅃 🄴 🅂" [[ -z ${array[*]} ]] && echo "There are no updates available" && return 0 || echo "Update(s) Available: ${#array[@]}" echo "Asynchronous Updates: $update_limit" [[ -z $timeout ]] && echo "Default Timeout: 500" && timeout=500 || echo "Custom Timeout: $timeout" From 88e047e56acd8b693c44477060e5ef4aef02b248 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 13:50:34 -0600 Subject: [PATCH 297/352] format --- functions/misc.sh | 2 +- heavy_script.sh | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/functions/misc.sh b/functions/misc.sh index baa1583b..880de232 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -14,7 +14,7 @@ done export -f sync prune(){ -echo -e "\n\n🄳 🄾 🄲 🄺 🄴 🅁 🄿 🅁 🅄 🄽 🄴" +echo -e "\n\n🄿 🅁 🅄 🄽 🄴" echo "Pruned Docker Images" docker image prune -af | grep "^Total" || echo "Failed to Prune Docker Images" } diff --git a/heavy_script.sh b/heavy_script.sh index 024aec0c..758296be 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -146,8 +146,7 @@ done [[ "$restore" == "true" ]] && restore && exit [[ "$mount" == "true" ]] && mount && exit if [[ "$backup" == "true" && "$sync" == "true" ]]; then # Run backup and sync at the same time - echo "Running the following two tasks at the same time" - echo "------------------------------------------------" + echo "🅁 🅄 🄽 🄽 🄸 🄽 🄶 🅃 🄰 🅂 🄺 🅂 :" echo -e "Backing up ix-applications dataset\nSyncing catalog(s)" echo -e "This can take a LONG time, please wait for the output..\n" backup & From b0c7cb88509229318b632b9b0fd8fda27d5f74ca Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 13:55:35 -0600 Subject: [PATCH 298/352] More Titles --- functions/self_update.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/self_update.sh b/functions/self_update.sh index fac45a1e..690d2516 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -3,6 +3,7 @@ args=("$@") self_update() { git fetch &> /dev/null +echo "🅂 🄴 🄻 🄵 🅄 🄿 🄳 🄰 🅃 🄴 :" # TODO: change beta to main once testing is complete if git diff --name-only origin/beta | grep -qs ".sh" ; then echo "Found a new version of HeavyScript, updating myself..." From 69258f9af5c159ba85a307216e1bf6f7ead7b233 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 13:59:50 -0600 Subject: [PATCH 299/352] format --- heavy_script.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index 758296be..5d539c1d 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -146,9 +146,9 @@ done [[ "$restore" == "true" ]] && restore && exit [[ "$mount" == "true" ]] && mount && exit if [[ "$backup" == "true" && "$sync" == "true" ]]; then # Run backup and sync at the same time - echo "🅁 🅄 🄽 🄽 🄸 🄽 🄶 🅃 🄰 🅂 🄺 🅂 :" - echo -e "Backing up ix-applications dataset\nSyncing catalog(s)" - echo -e "This can take a LONG time, please wait for the output..\n" + echo "🅃 🄰 🅂 🄺 🅂 :" + echo -e "-Backing up ix-applications dataset\n-Syncing catalog(s)" + echo -e "This can take a LONG time, please wait for both output..\n" backup & sync & wait From 0f9469cc3a317a82c177ab42a20442ffcbe85d4e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 14:02:57 -0600 Subject: [PATCH 300/352] self update fix --- functions/self_update.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 690d2516..5b404492 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -9,16 +9,16 @@ if git diff --name-only origin/beta | grep -qs ".sh" ; then echo "Found a new version of HeavyScript, updating myself..." git reset --hard -q git pull --force -q - echo -e "Running the new version...\n" count=0 for i in "${args[@]}" do [[ "$i" == "--self-update" ]] && unset "args[$count]" && break ((count++)) done + [[ -z ${args[*]} ]] && exit + echo -e "Running the new version...\n" sleep 5 exec bash "$script_name" "${args[@]}" - # Now exit this old instance exit else From c9c77c1d6cb4d4ae41bca9ac2c4cb26b1404e6b9 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 14:05:21 -0600 Subject: [PATCH 301/352] change just for test --- functions/self_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 5b404492..82342d33 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -4,7 +4,7 @@ args=("$@") self_update() { git fetch &> /dev/null echo "🅂 🄴 🄻 🄵 🅄 🄿 🄳 🄰 🅃 🄴 :" -# TODO: change beta to main once testing is complete +# TODO: change beta to main once testing is complete if git diff --name-only origin/beta | grep -qs ".sh" ; then echo "Found a new version of HeavyScript, updating myself..." git reset --hard -q From 2adbf8d1f71701b0c9491e265fb8a6c29e1db09e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 14:06:10 -0600 Subject: [PATCH 302/352] explanation --- functions/self_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 82342d33..871276b7 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -15,7 +15,7 @@ if git diff --name-only origin/beta | grep -qs ".sh" ; then [[ "$i" == "--self-update" ]] && unset "args[$count]" && break ((count++)) done - [[ -z ${args[*]} ]] && exit + [[ -z ${args[*]} ]] && echo "No more arguments, exiting.." && exit echo -e "Running the new version...\n" sleep 5 exec bash "$script_name" "${args[@]}" From 21baeaf4d8d773dd032274bb717c1ea3c963f549 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 14:06:40 -0600 Subject: [PATCH 303/352] testing self update again --- functions/self_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 871276b7..c5851484 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -4,7 +4,7 @@ args=("$@") self_update() { git fetch &> /dev/null echo "🅂 🄴 🄻 🄵 🅄 🄿 🄳 🄰 🅃 🄴 :" -# TODO: change beta to main once testing is complete +# TODO: change beta to main once testing is complete if git diff --name-only origin/beta | grep -qs ".sh" ; then echo "Found a new version of HeavyScript, updating myself..." git reset --hard -q From 3bd0543fc587540f6fb6bf75d85c66968abd92ca Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 14:07:38 -0600 Subject: [PATCH 304/352] again --- functions/self_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index c5851484..871276b7 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -4,7 +4,7 @@ args=("$@") self_update() { git fetch &> /dev/null echo "🅂 🄴 🄻 🄵 🅄 🄿 🄳 🄰 🅃 🄴 :" -# TODO: change beta to main once testing is complete +# TODO: change beta to main once testing is complete if git diff --name-only origin/beta | grep -qs ".sh" ; then echo "Found a new version of HeavyScript, updating myself..." git reset --hard -q From e5a28282a0469950cba728b030e9b7839c6b167a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 14:10:16 -0600 Subject: [PATCH 305/352] formatting --- functions/self_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 871276b7..96d017d9 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -15,7 +15,7 @@ if git diff --name-only origin/beta | grep -qs ".sh" ; then [[ "$i" == "--self-update" ]] && unset "args[$count]" && break ((count++)) done - [[ -z ${args[*]} ]] && echo "No more arguments, exiting.." && exit + [[ -z ${args[*]} ]] && echo -e "No more arguments, exiting..\n" && exit echo -e "Running the new version...\n" sleep 5 exec bash "$script_name" "${args[@]}" From 9e2bd269a6c0d75e9bd3f2f7b9b55dbd25188d2d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 14:13:57 -0600 Subject: [PATCH 306/352] final --- functions/self_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 96d017d9..3f2445c3 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -3,7 +3,7 @@ args=("$@") self_update() { git fetch &> /dev/null -echo "🅂 🄴 🄻 🄵 🅄 🄿 🄳 🄰 🅃 🄴 :" +echo "🅂 🄴 🄻 🄵 - 🅄 🄿 🄳 🄰 🅃 🄴 :" # TODO: change beta to main once testing is complete if git diff --name-only origin/beta | grep -qs ".sh" ; then echo "Found a new version of HeavyScript, updating myself..." From b8e649badf3979b076b00173302ed8ab348d0ae9 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 14:21:21 -0600 Subject: [PATCH 307/352] remove colon --- functions/self_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 3f2445c3..b4b88664 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -3,7 +3,7 @@ args=("$@") self_update() { git fetch &> /dev/null -echo "🅂 🄴 🄻 🄵 - 🅄 🄿 🄳 🄰 🅃 🄴 :" +echo "🅂 🄴 🄻 🄵 - 🅄 🄿 🄳 🄰 🅃 🄴" # TODO: change beta to main once testing is complete if git diff --name-only origin/beta | grep -qs ".sh" ; then echo "Found a new version of HeavyScript, updating myself..." From 8da7373f33ced2fb61bc49c9622805d95eeff9e4 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 16:01:29 -0600 Subject: [PATCH 308/352] heavysetup readme --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 8ab10a50..af609280 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ # heavy_script +## Website + +[HeavySetup - Further In-Depth Explanation](https://heavysetup.info/scripts/heavyscript/about/) + ## Table of contents: * [Arguments](#arguments) * [Examples](#examples) From e2dfead10a046008a64daa6f39f13efa5f272ba8 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 16:04:41 -0600 Subject: [PATCH 309/352] selfupdate to menu update --- functions/menu.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/functions/menu.sh b/functions/menu.sh index 1ac5659e..9fcafab9 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -114,6 +114,7 @@ case $selection in echo "6) -t | Set a custom timeout in seconds when checking if either an App or Mountpoint correctly Started, Stopped or (un)Mounted. Defaults to 500 seconds" echo "7) -s | sync catalog" echo "8) -p | Prune unused/old docker images" + echo "9) --self-update | Updates HeavyScript prior to running any other commands" echo echo "99) Remove Update Options, Restart" echo "00) Done making selections, proceed with update" @@ -171,6 +172,10 @@ case $selection in printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-p" && echo -e "\"-p\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it update_selection+=("-p") ;; + 9 | --self-update ) + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "--self-update" && echo -e "\"--self-update\" is already on here, skipping" && sleep 5 && continue #If option is already on there, skip it + update_selection+=("--self-update") + ;; 99) count=2 echo "restarting" From 8e654d5942c629357e8d1829636d974958c44f23 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 16:10:33 -0600 Subject: [PATCH 310/352] test ignore regex validation --- functions/menu.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index 9fcafab9..2d4195a0 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -123,7 +123,7 @@ case $selection in echo "---------------" echo "bash heavy_script.sh ${update_selection[*]}" echo - read -rt 600 -p "Please type the number associated with the flag above: " current_selection + read -rt 600 -p "Type the Number OR Flag: " current_selection case $current_selection in 00) clear -x @@ -142,6 +142,7 @@ case $selection in ;; 2 | -i) read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore + ! [[ $up_ignore =~ ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ ]] && echo -e "Error: \"$up_ignore\" is invalid, that is not the name youre using for your application" && sleep 5 && continue update_selection+=("-i" "$up_ignore") ;; 3 | -r) From 1fa9e3f9084123497b3be9d9505c2d9cb6688762 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 16:48:27 -0600 Subject: [PATCH 311/352] regex changes for ignore --- functions/menu.sh | 2 +- heavy_script.sh | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 2d4195a0..95008b4a 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -142,7 +142,7 @@ case $selection in ;; 2 | -i) read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore - ! [[ $up_ignore =~ ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ ]] && echo -e "Error: \"$up_ignore\" is invalid, that is not the name youre using for your application" && sleep 5 && continue + ! [[ $up_ignore =~ ^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$ ]] && echo -e "Error: \"$up_ignore\" is invalid, that is not the name youre using for your application" && sleep 5 && continue update_selection+=("-i" "$up_ignore") ;; 3 | -r) diff --git a/heavy_script.sh b/heavy_script.sh index 5d539c1d..61caec9a 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -71,15 +71,11 @@ do rollback="true" ;; i) - # Check next positional parameter - eval nextopt=${!OPTIND} - # existing or starting with dash? - if [[ -n $nextopt && $nextopt != -* ]] ; then - OPTIND=$((OPTIND + 1)) - ignore+=("$nextopt") - else - echo "Option: \"-i\" requires an argument" + if ! [[ $OPTARG =~ ^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$ ]]; then # Using case insensitive version of the regex used by Truenas Scale + echo -e "Error: \"$OPTARG\" is invalid, that is not the name youre using for your application" exit + else + ignore+=("$OPTARG") fi ;; t) From 276f2126870e9c0cdc51986d7c933fad57bf9a74 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 17:00:45 -0600 Subject: [PATCH 312/352] remove hyphen in title --- functions/self_update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index b4b88664..586cadc9 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -3,7 +3,7 @@ args=("$@") self_update() { git fetch &> /dev/null -echo "🅂 🄴 🄻 🄵 - 🅄 🄿 🄳 🄰 🅃 🄴" +echo "🅂 🄴 🄻 🄵 🅄 🄿 🄳 🄰 🅃 🄴" # TODO: change beta to main once testing is complete if git diff --name-only origin/beta | grep -qs ".sh" ; then echo "Found a new version of HeavyScript, updating myself..." From 34c4e5f9cb50bb6b201cdba913237c4325f92c53 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 17:31:38 -0600 Subject: [PATCH 313/352] change ignore error message --- functions/menu.sh | 2 +- heavy_script.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 95008b4a..27e702a6 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -142,7 +142,7 @@ case $selection in ;; 2 | -i) read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore - ! [[ $up_ignore =~ ^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$ ]] && echo -e "Error: \"$up_ignore\" is invalid, that is not the name youre using for your application" && sleep 5 && continue + ! [[ $up_ignore =~ ^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$ ]] && echo -e "Error: \"$up_ignore\" is not a possible option for an application name" && sleep 5 && continue update_selection+=("-i" "$up_ignore") ;; 3 | -r) diff --git a/heavy_script.sh b/heavy_script.sh index 61caec9a..f0e3015c 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -72,7 +72,7 @@ do ;; i) if ! [[ $OPTARG =~ ^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$ ]]; then # Using case insensitive version of the regex used by Truenas Scale - echo -e "Error: \"$OPTARG\" is invalid, that is not the name youre using for your application" + echo -e "Error: \"$OPTARG\" is not a possible option for an application name" exit else ignore+=("$OPTARG") From 6e5a0480d9e80c82aad4537ada02cb90944d2168 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 22:23:10 -0600 Subject: [PATCH 314/352] test new mount --- functions/mount.sh | 245 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 191 insertions(+), 54 deletions(-) diff --git a/functions/mount.sh b/functions/mount.sh index 880ffce4..c0785e64 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -1,63 +1,200 @@ #!/bin/bash +# mount(){ +# clear -x +# title +# echo -e "1 Mount\n2 Unmount All" && read -t 600 -p "Please type a number: " selection +# [[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script +# if [[ $selection == "1" ]]; then +# list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") +# echo "$list" && read -t 120 -p "Please type a number: " selection +# [[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script +# app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) +# [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script +# pvc=$(echo -e "$list" | grep ^"$selection ") +# status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") +# if [[ "$status" != "STOPPED" ]]; then +# [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" +# SECONDS=0 && echo -e "\nScaling down $app" && midclt call chart.release.scale "$app" '{"replica_count": 0}' &> /dev/null +# else +# echo -e "\n$app is already stopped" +# fi +# while [[ "$SECONDS" -le "$timeout" && "$status" != "STOPPED" ]] +# do +# status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") +# echo -e "Waiting $((timeout-SECONDS)) more seconds for $app to be STOPPED" && sleep 5 +# done +# data_name=$(echo "$pvc" | awk '{print $3}') +# mount=$(echo "$pvc" | awk '{print $4}') +# volume_name=$(echo "$pvc" | awk '{print $4}') +# mapfile -t full_path < <(zfs list | grep "$volume_name" | awk '{print $1}') +# if [[ "${#full_path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. +# echo "$app is using the same volume identifier on more than one pool.. attempting to use your current kubernetes apps pool" +# pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") +# full_path=$(zfs list | grep "$volume_name" | grep "$pool" | awk '{print $1}') +# fi +# echo -e "\nMounting\n$full_path\nTo\n/mnt/heavyscript/$data_name" +# zfs set mountpoint=/heavyscript/"$data_name" "$full_path" || echo "Failed to mount $app" +# echo -e "Mounted\n\nUnmount with:\nzfs set mountpoint=legacy $full_path && rmdir /mnt/heavyscript/$data_name\n\nOr use the Unmount All option\n" +# exit +# elif [[ $selection == "2" ]]; then +# mapfile -t unmount_array < <(basename -a /mnt/heavyscript/* | sed "s/*//") +# [[ -z ${unmount_array[*]} ]] && echo "Theres nothing to unmount" && exit +# for i in "${unmount_array[@]}" +# do +# main=$(k3s kubectl get pvc -A | grep -E "\s$i\s" | awk '{print $1, $2, $4}') +# app=$(echo "$main" | awk '{print $1}' | cut -c 4-) +# pvc=$(echo "$main" | awk '{print $3}') +# mapfile -t path < <(find /mnt/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) +# if [[ "${#path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. +# echo "$i is a name used on more than one pool.. attempting to use your current kubernetes apps pool" +# pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") +# full_path=$(find /mnt/"$pool"/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) +# zfs set mountpoint=legacy "$full_path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" +# else +# zfs set mountpoint=legacy "$path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" +# fi +# done +# rmdir /mnt/heavyscript +# else +# echo "Invalid selection, \"$selection\" was not an option" +# fi +# } +# export -f mount + + + + mount(){ clear -x title -echo -e "1 Mount\n2 Unmount All" && read -t 600 -p "Please type a number: " selection -[[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script -if [[ $selection == "1" ]]; then - list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") - echo "$list" && read -t 120 -p "Please type a number: " selection - [[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script - app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) - [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script - pvc=$(echo -e "$list" | grep ^"$selection ") - status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") - if [[ "$status" != "STOPPED" ]]; then - [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" - SECONDS=0 && echo -e "\nScaling down $app" && midclt call chart.release.scale "$app" '{"replica_count": 0}' &> /dev/null - else - echo -e "\n$app is already stopped" - fi - while [[ "$SECONDS" -le "$timeout" && "$status" != "STOPPED" ]] - do +echo "1 Mount" +echo "2 Unmount All" +echo +echo "0 Exit" +read -rt 120 -p "Unmount All Please type a number: " selection + +case $selection in + 0) + echo "Exitting.." + exit + ;; + 1) + list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") + echo "$list" + read -rt 120 -p "Please type a number: " selection + app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) + [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script + pvc=$(echo -e "$list" | grep ^"$selection ") status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") - echo -e "Waiting $((timeout-SECONDS)) more seconds for $app to be STOPPED" && sleep 5 - done - data_name=$(echo "$pvc" | awk '{print $3}') - mount=$(echo "$pvc" | awk '{print $4}') - volume_name=$(echo "$pvc" | awk '{print $4}') - mapfile -t full_path < <(zfs list | grep "$volume_name" | awk '{print $1}') - if [[ "${#full_path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. - echo "$app is using the same volume identifier on more than one pool.. attempting to use your current kubernetes apps pool" - pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") - full_path=$(zfs list | grep "$volume_name" | grep "$pool" | awk '{print $1}') - fi - echo -e "\nMounting\n$full_path\nTo\n/mnt/heavyscript/$data_name" - zfs set mountpoint=/heavyscript/"$data_name" "$full_path" || echo "Failed to mount $app" - echo -e "Mounted\n\nUnmount with:\nzfs set mountpoint=legacy $full_path && rmdir /mnt/heavyscript/$data_name\n\nOr use the Unmount All option\n" - exit -elif [[ $selection == "2" ]]; then - mapfile -t unmount_array < <(basename -a /mnt/heavyscript/* | sed "s/*//") - [[ -z ${unmount_array[*]} ]] && echo "Theres nothing to unmount" && exit - for i in "${unmount_array[@]}" - do - main=$(k3s kubectl get pvc -A | grep -E "\s$i\s" | awk '{print $1, $2, $4}') - app=$(echo "$main" | awk '{print $1}' | cut -c 4-) - pvc=$(echo "$main" | awk '{print $3}') - mapfile -t path < <(find /mnt/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) - if [[ "${#path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. - echo "$i is a name used on more than one pool.. attempting to use your current kubernetes apps pool" - pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") - full_path=$(find /mnt/"$pool"/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) - zfs set mountpoint=legacy "$full_path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" + if [[ "$status" != "STOPPED" ]]; then + [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" + SECONDS=0 && echo -e "\nScaling down $app" && midclt call chart.release.scale "$app" '{"replica_count": 0}' &> /dev/null else - zfs set mountpoint=legacy "$path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" + echo -e "\n$app is already stopped" fi - done - rmdir /mnt/heavyscript -else - echo "Invalid selection, \"$selection\" was not an option" -fi + while [[ "$SECONDS" -le "$timeout" && "$status" != "STOPPED" ]] + do + status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") + echo -e "Waiting $((timeout-SECONDS)) more seconds for $app to be STOPPED" && sleep 5 + done + data_name=$(echo "$pvc" | awk '{print $3}') + mount=$(echo "$pvc" | awk '{print $4}') + volume_name=$(echo "$pvc" | awk '{print $4}') + mapfile -t full_path < <(zfs list | grep "$volume_name" | awk '{print $1}') + if [[ "${#full_path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. + echo "$app is using the same volume identifier on more than one pool.. attempting to use your current kubernetes apps pool" + pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") + full_path=$(zfs list | grep "$volume_name" | grep "$pool" | awk '{print $1}') + fi + echo -e "\nMounting\n$full_path\nTo\n/mnt/heavyscript/$data_name" + zfs set mountpoint=/heavyscript/"$data_name" "$full_path" || echo "Failed to mount $app" + echo -e "Mounted\n\nUnmount with:\nzfs set mountpoint=legacy $full_path && rmdir /mnt/heavyscript/$data_name\n\nOr use the Unmount All option\n" + exit + ;; + 2) + mapfile -t unmount_array < <(basename -a /mnt/heavyscript/* | sed "s/*//") + [[ -z ${unmount_array[*]} ]] && echo "Theres nothing to unmount" && exit + for i in "${unmount_array[@]}" + do + main=$(k3s kubectl get pvc -A | grep -E "\s$i\s" | awk '{print $1, $2, $4}') + app=$(echo "$main" | awk '{print $1}' | cut -c 4-) + pvc=$(echo "$main" | awk '{print $3}') + mapfile -t path < <(find /mnt/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) + if [[ "${#path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. + echo "$i is a name used on more than one pool.. attempting to use your current kubernetes apps pool" + pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") + full_path=$(find /mnt/"$pool"/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) + zfs set mountpoint=legacy "$full_path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" + else + zfs set mountpoint=legacy "$path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" + fi + done + rmdir /mnt/heavyscript + ;; + *) + echo "Invalid selection, \"$selection\" was not an option" + ;; +esac } -export -f mount \ No newline at end of file +export -f mount + + + +# [[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script +# if [[ $selection == "1" ]]; then + # list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") + # echo "$list" && read -t 120 -p "Please type a number: " selection + # [[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script + # app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) + # [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script + # pvc=$(echo -e "$list" | grep ^"$selection ") + # status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") + # if [[ "$status" != "STOPPED" ]]; then + # [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" + # SECONDS=0 && echo -e "\nScaling down $app" && midclt call chart.release.scale "$app" '{"replica_count": 0}' &> /dev/null + # else + # echo -e "\n$app is already stopped" + # fi + # while [[ "$SECONDS" -le "$timeout" && "$status" != "STOPPED" ]] + # do + # status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") + # echo -e "Waiting $((timeout-SECONDS)) more seconds for $app to be STOPPED" && sleep 5 + # done + # data_name=$(echo "$pvc" | awk '{print $3}') + # mount=$(echo "$pvc" | awk '{print $4}') + # volume_name=$(echo "$pvc" | awk '{print $4}') + # mapfile -t full_path < <(zfs list | grep "$volume_name" | awk '{print $1}') + # if [[ "${#full_path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. + # echo "$app is using the same volume identifier on more than one pool.. attempting to use your current kubernetes apps pool" + # pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") + # full_path=$(zfs list | grep "$volume_name" | grep "$pool" | awk '{print $1}') + # fi + # echo -e "\nMounting\n$full_path\nTo\n/mnt/heavyscript/$data_name" + # zfs set mountpoint=/heavyscript/"$data_name" "$full_path" || echo "Failed to mount $app" + # echo -e "Mounted\n\nUnmount with:\nzfs set mountpoint=legacy $full_path && rmdir /mnt/heavyscript/$data_name\n\nOr use the Unmount All option\n" + # exit +# elif [[ $selection == "2" ]]; then +# # mapfile -t unmount_array < <(basename -a /mnt/heavyscript/* | sed "s/*//") + # [[ -z ${unmount_array[*]} ]] && echo "Theres nothing to unmount" && exit + # for i in "${unmount_array[@]}" + # do + # main=$(k3s kubectl get pvc -A | grep -E "\s$i\s" | awk '{print $1, $2, $4}') + # app=$(echo "$main" | awk '{print $1}' | cut -c 4-) + # pvc=$(echo "$main" | awk '{print $3}') + # mapfile -t path < <(find /mnt/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) + # if [[ "${#path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. + # echo "$i is a name used on more than one pool.. attempting to use your current kubernetes apps pool" + # pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") + # full_path=$(find /mnt/"$pool"/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) + # zfs set mountpoint=legacy "$full_path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" + # else + # zfs set mountpoint=legacy "$path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" + # fi + # done + # rmdir /mnt/heavyscript +# else +# echo "Invalid selection, \"$selection\" was not an option" +# fi +# } +# export -f mount \ No newline at end of file From 436599e7a93784e8cf7a90a16d95f71d5a9b10e4 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 22:36:14 -0600 Subject: [PATCH 315/352] test new while loop for mount --- functions/mount.sh | 79 +++++++++++++++++++++++++++++----------------- 1 file changed, 50 insertions(+), 29 deletions(-) diff --git a/functions/mount.sh b/functions/mount.sh index c0785e64..ece5861d 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -76,41 +76,62 @@ read -rt 120 -p "Unmount All Please type a number: " selection case $selection in 0) - echo "Exitting.." + echo "Exiting.." exit ;; 1) - list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") - echo "$list" - read -rt 120 -p "Please type a number: " selection - app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) - [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script - pvc=$(echo -e "$list" | grep ^"$selection ") - status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") - if [[ "$status" != "STOPPED" ]]; then - [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" - SECONDS=0 && echo -e "\nScaling down $app" && midclt call chart.release.scale "$app" '{"replica_count": 0}' &> /dev/null - else - echo -e "\n$app is already stopped" - fi - while [[ "$SECONDS" -le "$timeout" && "$status" != "STOPPED" ]] + while true do + list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") + echo "$list" + read -rt 120 -p "Please type a number: " selection + app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) + [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script + pvc=$(echo -e "$list" | grep ^"$selection ") status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") - echo -e "Waiting $((timeout-SECONDS)) more seconds for $app to be STOPPED" && sleep 5 + if [[ "$status" != "STOPPED" ]]; then + [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" + SECONDS=0 && echo -e "\nScaling down $app" && midclt call chart.release.scale "$app" '{"replica_count": 0}' &> /dev/null + else + echo -e "\n$app is already stopped" + fi + while [[ "$SECONDS" -le "$timeout" && "$status" != "STOPPED" ]] + do + status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") + echo -e "Waiting $((timeout-SECONDS)) more seconds for $app to be STOPPED" && sleep 5 + done + data_name=$(echo "$pvc" | awk '{print $3}') + mount=$(echo "$pvc" | awk '{print $4}') + volume_name=$(echo "$pvc" | awk '{print $4}') + mapfile -t full_path < <(zfs list | grep "$volume_name" | awk '{print $1}') + if [[ "${#full_path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. + echo "$app is using the same volume identifier on more than one pool.. attempting to use your current kubernetes apps pool" + pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") + full_path=$(zfs list | grep "$volume_name" | grep "$pool" | awk '{print $1}') + fi + echo -e "\nMounting\n$full_path\nTo\n/mnt/heavyscript/$data_name" + zfs set mountpoint=/heavyscript/"$data_name" "$full_path" || echo "Failed to mount $app" + echo -e "Mounted\n\nUnmount with:\nzfs set mountpoint=legacy $full_path && rmdir /mnt/heavyscript/$data_name\n\nOr use the Unmount All option\n" + while [[ $yesno != 0 ]] + do + echo "Would you like to mount anything else?" + echo "1 Yes" + echo "2 No" + read -rt 120 -p "Unmount All Please type a number: " yesno + case $yesno in + 1) + continue + ;; + 2) + exit + ;; + *) + echo "Invalid selection \"$yesno\" was not an option" sleep 3 + continue + ;; + esac + done done - data_name=$(echo "$pvc" | awk '{print $3}') - mount=$(echo "$pvc" | awk '{print $4}') - volume_name=$(echo "$pvc" | awk '{print $4}') - mapfile -t full_path < <(zfs list | grep "$volume_name" | awk '{print $1}') - if [[ "${#full_path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. - echo "$app is using the same volume identifier on more than one pool.. attempting to use your current kubernetes apps pool" - pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") - full_path=$(zfs list | grep "$volume_name" | grep "$pool" | awk '{print $1}') - fi - echo -e "\nMounting\n$full_path\nTo\n/mnt/heavyscript/$data_name" - zfs set mountpoint=/heavyscript/"$data_name" "$full_path" || echo "Failed to mount $app" - echo -e "Mounted\n\nUnmount with:\nzfs set mountpoint=legacy $full_path && rmdir /mnt/heavyscript/$data_name\n\nOr use the Unmount All option\n" - exit ;; 2) mapfile -t unmount_array < <(basename -a /mnt/heavyscript/* | sed "s/*//") From 348fa7b3025c54df4eb01ef836fbfc2a7c724573 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 22:40:40 -0600 Subject: [PATCH 316/352] test --- functions/mount.sh | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/functions/mount.sh b/functions/mount.sh index ece5861d..8a8f60c0 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -112,24 +112,24 @@ case $selection in echo -e "\nMounting\n$full_path\nTo\n/mnt/heavyscript/$data_name" zfs set mountpoint=/heavyscript/"$data_name" "$full_path" || echo "Failed to mount $app" echo -e "Mounted\n\nUnmount with:\nzfs set mountpoint=legacy $full_path && rmdir /mnt/heavyscript/$data_name\n\nOr use the Unmount All option\n" - while [[ $yesno != 0 ]] + while true do - echo "Would you like to mount anything else?" - echo "1 Yes" - echo "2 No" - read -rt 120 -p "Unmount All Please type a number: " yesno - case $yesno in - 1) - continue - ;; - 2) - exit - ;; - *) - echo "Invalid selection \"$yesno\" was not an option" sleep 3 - continue - ;; - esac + echo "Would you like to mount anything else?" + echo "1 Yes" + echo "2 No" + read -rt 120 -p "Please type a number: " yesno + case $yesno in + 1) + break + ;; + 2) + exit + ;; + *) + echo "Invalid selection \"$yesno\" was not an option" sleep 3 + continue + ;; + esac done done ;; From 96cc369f32665f8822ae1b44a03bfd937bca6d3b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 22:44:28 -0600 Subject: [PATCH 317/352] test --- functions/mount.sh | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/functions/mount.sh b/functions/mount.sh index 8a8f60c0..6d757f56 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -68,10 +68,10 @@ mount(){ clear -x title -echo "1 Mount" -echo "2 Unmount All" +echo "1) Mount" +echo "2) Unmount All" echo -echo "0 Exit" +echo "0) Exit" read -rt 120 -p "Unmount All Please type a number: " selection case $selection in @@ -114,9 +114,9 @@ case $selection in echo -e "Mounted\n\nUnmount with:\nzfs set mountpoint=legacy $full_path && rmdir /mnt/heavyscript/$data_name\n\nOr use the Unmount All option\n" while true do - echo "Would you like to mount anything else?" - echo "1 Yes" - echo "2 No" + echo -e "\nWould you like to mount anything else?" + echo "1) Yes" + echo "2) No" read -rt 120 -p "Please type a number: " yesno case $yesno in 1) @@ -126,7 +126,8 @@ case $selection in exit ;; *) - echo "Invalid selection \"$yesno\" was not an option" sleep 3 + echo "Invalid selection \"$yesno\" was not an option" + sleep 2 continue ;; esac From a96092c37037076105a373ef1903273c8cee6c36 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 22:48:22 -0600 Subject: [PATCH 318/352] test --- functions/mount.sh | 181 +++++++++++++++++++++++---------------------- 1 file changed, 93 insertions(+), 88 deletions(-) diff --git a/functions/mount.sh b/functions/mount.sh index 6d757f56..d2c4a7f9 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -66,98 +66,103 @@ mount(){ -clear -x -title -echo "1) Mount" -echo "2) Unmount All" -echo -echo "0) Exit" -read -rt 120 -p "Unmount All Please type a number: " selection +while true +do + clear -x + title + echo "1) Mount" + echo "2) Unmount All" + echo + echo "0) Exit" + read -rt 120 -p "Unmount All Please type a number: " selection -case $selection in - 0) - echo "Exiting.." - exit - ;; - 1) - while true - do - list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") - echo "$list" - read -rt 120 -p "Please type a number: " selection - app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) - [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script - pvc=$(echo -e "$list" | grep ^"$selection ") - status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") - if [[ "$status" != "STOPPED" ]]; then - [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" - SECONDS=0 && echo -e "\nScaling down $app" && midclt call chart.release.scale "$app" '{"replica_count": 0}' &> /dev/null - else - echo -e "\n$app is already stopped" - fi - while [[ "$SECONDS" -le "$timeout" && "$status" != "STOPPED" ]] - do - status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") - echo -e "Waiting $((timeout-SECONDS)) more seconds for $app to be STOPPED" && sleep 5 - done - data_name=$(echo "$pvc" | awk '{print $3}') - mount=$(echo "$pvc" | awk '{print $4}') - volume_name=$(echo "$pvc" | awk '{print $4}') - mapfile -t full_path < <(zfs list | grep "$volume_name" | awk '{print $1}') - if [[ "${#full_path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. - echo "$app is using the same volume identifier on more than one pool.. attempting to use your current kubernetes apps pool" - pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") - full_path=$(zfs list | grep "$volume_name" | grep "$pool" | awk '{print $1}') - fi - echo -e "\nMounting\n$full_path\nTo\n/mnt/heavyscript/$data_name" - zfs set mountpoint=/heavyscript/"$data_name" "$full_path" || echo "Failed to mount $app" - echo -e "Mounted\n\nUnmount with:\nzfs set mountpoint=legacy $full_path && rmdir /mnt/heavyscript/$data_name\n\nOr use the Unmount All option\n" + case $selection in + 0) + echo "Exiting.." + exit + ;; + 1) while true do - echo -e "\nWould you like to mount anything else?" - echo "1) Yes" - echo "2) No" - read -rt 120 -p "Please type a number: " yesno - case $yesno in - 1) - break - ;; - 2) - exit - ;; - *) - echo "Invalid selection \"$yesno\" was not an option" - sleep 2 - continue - ;; - esac + list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") + echo "$list" + read -rt 120 -p "Please type a number: " selection + app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) + [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script + pvc=$(echo -e "$list" | grep ^"$selection ") + status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") + if [[ "$status" != "STOPPED" ]]; then + [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" + SECONDS=0 && echo -e "\nScaling down $app" && midclt call chart.release.scale "$app" '{"replica_count": 0}' &> /dev/null + else + echo -e "\n$app is already stopped" + fi + while [[ "$SECONDS" -le "$timeout" && "$status" != "STOPPED" ]] + do + status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") + echo -e "Waiting $((timeout-SECONDS)) more seconds for $app to be STOPPED" && sleep 5 + done + data_name=$(echo "$pvc" | awk '{print $3}') + mount=$(echo "$pvc" | awk '{print $4}') + volume_name=$(echo "$pvc" | awk '{print $4}') + mapfile -t full_path < <(zfs list | grep "$volume_name" | awk '{print $1}') + if [[ "${#full_path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. + echo "$app is using the same volume identifier on more than one pool.. attempting to use your current kubernetes apps pool" + pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") + full_path=$(zfs list | grep "$volume_name" | grep "$pool" | awk '{print $1}') + fi + echo -e "\nMounting\n$full_path\nTo\n/mnt/heavyscript/$data_name" + zfs set mountpoint=/heavyscript/"$data_name" "$full_path" || echo "Failed to mount $app" + echo -e "Mounted\n\nUnmount with:\nzfs set mountpoint=legacy $full_path && rmdir /mnt/heavyscript/$data_name\n\nOr use the Unmount All option\n" + while true + do + echo -e "\nWould you like to mount anything else?" + echo "1) Yes" + echo "2) No" + read -rt 120 -p "Please type a number: " yesno + case $yesno in + 1) + break + ;; + 2) + exit + ;; + *) + echo "Invalid selection \"$yesno\" was not an option" + sleep 2 + continue + ;; + esac + done done - done - ;; - 2) - mapfile -t unmount_array < <(basename -a /mnt/heavyscript/* | sed "s/*//") - [[ -z ${unmount_array[*]} ]] && echo "Theres nothing to unmount" && exit - for i in "${unmount_array[@]}" - do - main=$(k3s kubectl get pvc -A | grep -E "\s$i\s" | awk '{print $1, $2, $4}') - app=$(echo "$main" | awk '{print $1}' | cut -c 4-) - pvc=$(echo "$main" | awk '{print $3}') - mapfile -t path < <(find /mnt/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) - if [[ "${#path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. - echo "$i is a name used on more than one pool.. attempting to use your current kubernetes apps pool" - pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") - full_path=$(find /mnt/"$pool"/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) - zfs set mountpoint=legacy "$full_path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" - else - zfs set mountpoint=legacy "$path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" - fi - done - rmdir /mnt/heavyscript - ;; - *) - echo "Invalid selection, \"$selection\" was not an option" - ;; -esac + ;; + 2) + mapfile -t unmount_array < <(basename -a /mnt/heavyscript/* | sed "s/*//") + [[ -z ${unmount_array[*]} ]] && echo "Theres nothing to unmount" && exit + for i in "${unmount_array[@]}" + do + main=$(k3s kubectl get pvc -A | grep -E "\s$i\s" | awk '{print $1, $2, $4}') + app=$(echo "$main" | awk '{print $1}' | cut -c 4-) + pvc=$(echo "$main" | awk '{print $3}') + mapfile -t path < <(find /mnt/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) + if [[ "${#path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. + echo "$i is a name used on more than one pool.. attempting to use your current kubernetes apps pool" + pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") + full_path=$(find /mnt/"$pool"/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) + zfs set mountpoint=legacy "$full_path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" + else + zfs set mountpoint=legacy "$path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" + fi + done + rmdir /mnt/heavyscript + ;; + *) + echo "Invalid selection, \"$selection\" was not an option" + sleep 2 + continue + ;; + esac +done } export -f mount From 5b51ba45b600e32c12e2989731745e83319e7441 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 22:52:54 -0600 Subject: [PATCH 319/352] remove exits from mount --- functions/mount.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/mount.sh b/functions/mount.sh index d2c4a7f9..9214da3e 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -88,7 +88,7 @@ do echo "$list" read -rt 120 -p "Please type a number: " selection app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) - [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script + [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && sleep 5 && continue #Check for valid selection. If none, kill script pvc=$(echo -e "$list" | grep ^"$selection ") status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") if [[ "$status" != "STOPPED" ]]; then @@ -138,7 +138,7 @@ do ;; 2) mapfile -t unmount_array < <(basename -a /mnt/heavyscript/* | sed "s/*//") - [[ -z ${unmount_array[*]} ]] && echo "Theres nothing to unmount" && exit + [[ -z ${unmount_array[*]} ]] && echo "Theres nothing to unmount" && sleep 3 && continue for i in "${unmount_array[@]}" do main=$(k3s kubectl get pvc -A | grep -E "\s$i\s" | awk '{print $1, $2, $4}') From 5858610851a0e600c20ab8c8e10d0b0c6920a73f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 23:11:09 -0600 Subject: [PATCH 320/352] delete while loop --- functions/backup.sh | 57 ++++++++++++++++---- functions/mount.sh | 127 +------------------------------------------- 2 files changed, 47 insertions(+), 137 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index 56656b9d..c28a2e7b 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -33,19 +33,54 @@ deleteBackup(){ clear -x && echo "pulling all restore points.." list_backups=$(cli -c 'app kubernetes list_backups' | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t) clear -x -[[ -z "$list_backups" ]] && echo "No restore points available" && exit || { title; echo -e "Choose a restore point to delete\nThese may be out of order if they are not HeavyScript backups" ; } -echo "$list_backups" && read -t 600 -p "Please type a number: " selection && restore_point=$(echo "$list_backups" | grep ^"$selection " | awk '{print $2}') -[[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script -[[ -z "$restore_point" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script -echo -e "\nWARNING:\nYou CANNOT go back after deleting your restore point" || { echo "FAILED"; exit; } -echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" && echo -e "1 Yes\n2 No" && read -t 120 -p "Please type a number: " yesno || { echo "FAILED"; exit; } -if [[ $yesno == "1" ]]; then - echo -e "\nDeleting $restore_point" && cli -c 'app kubernetes delete_backup backup_name=''"'"$restore_point"'"' &>/dev/null && echo "Sucessfully deleted" || echo "Deletion Failed" -elif [[ $yesno == "2" ]]; then - echo "You've chosen NO, killing script." +if [[ -z "$list_backups" ]]; then + echo "No restore points available" + exit else - echo "Invalid Selection" + title + echo -e "Choose a restore point to delete\nThese may be out of order if they are not HeavyScript backups" fi +echo "$list_backups" +read -rt 120 -p "Please type a number: " selection +restore_point=$(echo "$list_backups" | grep ^"$selection " | awk '{print $2}') +#Check for valid selection. If none, kill script +if [[ -z "$selection" ]]; then + echo "Your selection cannot be empty" + exit +elif [[ -z "$restore_point" ]]; then + echo "Invalid Selection: $selection, was not an option" + exit +fi +while true +do + echo -e "\nWARNING:\nYou CANNOT go back after deleting your restore point" + echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" + echo -e "Yes\n0 exit" + read -rt 120 -p "Type \"yes\" to continue, or exit with \"0\": " yesno + case $yesno in + [Yy][Ee][Ss]) + echo -e "\nDeleting $restore_point" + cli -c 'app kubernetes delete_backup backup_name=''"'"$restore_point"'"' &>/dev/null || { echo "Failed to delete backup.."; exit; } + echo "Sucessfully deleted" + break + ;; + 0|[Ee][Xx][Ii][Tt]) + echo "Exiting" + exit + ;; + *) + echo "Invalid Selection" + ;; + esac +done +# while true +# do +# echo "Delete more?" +# echo + + +# done + } export -f deleteBackup diff --git a/functions/mount.sh b/functions/mount.sh index 9214da3e..aabc3989 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -1,70 +1,5 @@ #!/bin/bash -# mount(){ -# clear -x -# title -# echo -e "1 Mount\n2 Unmount All" && read -t 600 -p "Please type a number: " selection -# [[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script -# if [[ $selection == "1" ]]; then -# list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") -# echo "$list" && read -t 120 -p "Please type a number: " selection -# [[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script -# app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) -# [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script -# pvc=$(echo -e "$list" | grep ^"$selection ") -# status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") -# if [[ "$status" != "STOPPED" ]]; then -# [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" -# SECONDS=0 && echo -e "\nScaling down $app" && midclt call chart.release.scale "$app" '{"replica_count": 0}' &> /dev/null -# else -# echo -e "\n$app is already stopped" -# fi -# while [[ "$SECONDS" -le "$timeout" && "$status" != "STOPPED" ]] -# do -# status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") -# echo -e "Waiting $((timeout-SECONDS)) more seconds for $app to be STOPPED" && sleep 5 -# done -# data_name=$(echo "$pvc" | awk '{print $3}') -# mount=$(echo "$pvc" | awk '{print $4}') -# volume_name=$(echo "$pvc" | awk '{print $4}') -# mapfile -t full_path < <(zfs list | grep "$volume_name" | awk '{print $1}') -# if [[ "${#full_path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. -# echo "$app is using the same volume identifier on more than one pool.. attempting to use your current kubernetes apps pool" -# pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") -# full_path=$(zfs list | grep "$volume_name" | grep "$pool" | awk '{print $1}') -# fi -# echo -e "\nMounting\n$full_path\nTo\n/mnt/heavyscript/$data_name" -# zfs set mountpoint=/heavyscript/"$data_name" "$full_path" || echo "Failed to mount $app" -# echo -e "Mounted\n\nUnmount with:\nzfs set mountpoint=legacy $full_path && rmdir /mnt/heavyscript/$data_name\n\nOr use the Unmount All option\n" -# exit -# elif [[ $selection == "2" ]]; then -# mapfile -t unmount_array < <(basename -a /mnt/heavyscript/* | sed "s/*//") -# [[ -z ${unmount_array[*]} ]] && echo "Theres nothing to unmount" && exit -# for i in "${unmount_array[@]}" -# do -# main=$(k3s kubectl get pvc -A | grep -E "\s$i\s" | awk '{print $1, $2, $4}') -# app=$(echo "$main" | awk '{print $1}' | cut -c 4-) -# pvc=$(echo "$main" | awk '{print $3}') -# mapfile -t path < <(find /mnt/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) -# if [[ "${#path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. -# echo "$i is a name used on more than one pool.. attempting to use your current kubernetes apps pool" -# pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") -# full_path=$(find /mnt/"$pool"/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) -# zfs set mountpoint=legacy "$full_path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" -# else -# zfs set mountpoint=legacy "$path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" -# fi -# done -# rmdir /mnt/heavyscript -# else -# echo "Invalid selection, \"$selection\" was not an option" -# fi -# } -# export -f mount - - - - mount(){ while true do @@ -164,64 +99,4 @@ do esac done } -export -f mount - - - -# [[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script -# if [[ $selection == "1" ]]; then - # list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") - # echo "$list" && read -t 120 -p "Please type a number: " selection - # [[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script - # app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) - # [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script - # pvc=$(echo -e "$list" | grep ^"$selection ") - # status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") - # if [[ "$status" != "STOPPED" ]]; then - # [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" - # SECONDS=0 && echo -e "\nScaling down $app" && midclt call chart.release.scale "$app" '{"replica_count": 0}' &> /dev/null - # else - # echo -e "\n$app is already stopped" - # fi - # while [[ "$SECONDS" -le "$timeout" && "$status" != "STOPPED" ]] - # do - # status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") - # echo -e "Waiting $((timeout-SECONDS)) more seconds for $app to be STOPPED" && sleep 5 - # done - # data_name=$(echo "$pvc" | awk '{print $3}') - # mount=$(echo "$pvc" | awk '{print $4}') - # volume_name=$(echo "$pvc" | awk '{print $4}') - # mapfile -t full_path < <(zfs list | grep "$volume_name" | awk '{print $1}') - # if [[ "${#full_path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. - # echo "$app is using the same volume identifier on more than one pool.. attempting to use your current kubernetes apps pool" - # pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") - # full_path=$(zfs list | grep "$volume_name" | grep "$pool" | awk '{print $1}') - # fi - # echo -e "\nMounting\n$full_path\nTo\n/mnt/heavyscript/$data_name" - # zfs set mountpoint=/heavyscript/"$data_name" "$full_path" || echo "Failed to mount $app" - # echo -e "Mounted\n\nUnmount with:\nzfs set mountpoint=legacy $full_path && rmdir /mnt/heavyscript/$data_name\n\nOr use the Unmount All option\n" - # exit -# elif [[ $selection == "2" ]]; then -# # mapfile -t unmount_array < <(basename -a /mnt/heavyscript/* | sed "s/*//") - # [[ -z ${unmount_array[*]} ]] && echo "Theres nothing to unmount" && exit - # for i in "${unmount_array[@]}" - # do - # main=$(k3s kubectl get pvc -A | grep -E "\s$i\s" | awk '{print $1, $2, $4}') - # app=$(echo "$main" | awk '{print $1}' | cut -c 4-) - # pvc=$(echo "$main" | awk '{print $3}') - # mapfile -t path < <(find /mnt/*/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) - # if [[ "${#path[@]}" -gt 1 ]]; then #if there is another app with the same name on another pool, use the current pools application, since the other instance is probably old, or unused, or a backup. - # echo "$i is a name used on more than one pool.. attempting to use your current kubernetes apps pool" - # pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") - # full_path=$(find /mnt/"$pool"/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) - # zfs set mountpoint=legacy "$full_path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" - # else - # zfs set mountpoint=legacy "$path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" - # fi - # done - # rmdir /mnt/heavyscript -# else -# echo "Invalid selection, \"$selection\" was not an option" -# fi -# } -# export -f mount \ No newline at end of file +export -f mount \ No newline at end of file From 26815e9783dbc9e16257cc6ad24d13f27813c2af Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 23:22:06 -0600 Subject: [PATCH 321/352] test loop --- functions/backup.sh | 113 +++++++++++++++++++++++++------------------- 1 file changed, 65 insertions(+), 48 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index c28a2e7b..b8946e4a 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -30,57 +30,74 @@ export -f backup deleteBackup(){ -clear -x && echo "pulling all restore points.." -list_backups=$(cli -c 'app kubernetes list_backups' | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t) -clear -x -if [[ -z "$list_backups" ]]; then - echo "No restore points available" - exit -else - title - echo -e "Choose a restore point to delete\nThese may be out of order if they are not HeavyScript backups" -fi -echo "$list_backups" -read -rt 120 -p "Please type a number: " selection -restore_point=$(echo "$list_backups" | grep ^"$selection " | awk '{print $2}') -#Check for valid selection. If none, kill script -if [[ -z "$selection" ]]; then - echo "Your selection cannot be empty" - exit -elif [[ -z "$restore_point" ]]; then - echo "Invalid Selection: $selection, was not an option" - exit -fi while true do - echo -e "\nWARNING:\nYou CANNOT go back after deleting your restore point" - echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" - echo -e "Yes\n0 exit" - read -rt 120 -p "Type \"yes\" to continue, or exit with \"0\": " yesno - case $yesno in - [Yy][Ee][Ss]) - echo -e "\nDeleting $restore_point" - cli -c 'app kubernetes delete_backup backup_name=''"'"$restore_point"'"' &>/dev/null || { echo "Failed to delete backup.."; exit; } - echo "Sucessfully deleted" - break - ;; - 0|[Ee][Xx][Ii][Tt]) - echo "Exiting" - exit - ;; - *) - echo "Invalid Selection" - ;; - esac + clear -x && echo "pulling all restore points.." + list_backups=$(cli -c 'app kubernetes list_backups' | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t) + clear -x + if [[ -z "$list_backups" ]]; then + echo "No restore points available" + exit + else + title + echo -e "Choose a restore point to delete\nThese may be out of order if they are not HeavyScript backups" + fi + echo "$list_backups" + read -rt 120 -p "Please type a number: " selection + restore_point=$(echo "$list_backups" | grep ^"$selection " | awk '{print $2}') + #Check for valid selection. If none, kill script + if [[ -z "$selection" ]]; then + echo "Your selection cannot be empty" + continue + elif [[ -z "$restore_point" ]]; then + echo "Invalid Selection: $selection, was not an option" + continue + fi + while true + do + echo -e "\nWARNING:\nYou CANNOT go back after deleting your restore point" + echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" + echo -e "Yes\n0 exit\n" + read -rt 120 -p "Type \"yes\" to continue, or exit with \"0\": " yesno + case $yesno in + [Yy][Ee][Ss]) + echo -e "\nDeleting $restore_point" + cli -c 'app kubernetes delete_backup backup_name=''"'"$restore_point"'"' &>/dev/null || { echo "Failed to delete backup.."; exit; } + echo "Sucessfully deleted" + break + ;; + 0|[Ee][Xx][Ii][Tt]) + echo "Exiting" + exit + ;; + *) + echo "Invalid Selection" + ;; + esac + done + while true + do + echo "Delete more?" + echo "1 Yes" + echo "2 No" + read -rt 120 -p "Please type a number: " yesno + case $yesno in + 1) + break + ;; + 2) + exit + ;; + *) + echo "$yesno was not an option, try again" + sleep 2 + continue + ;; + + esac + + done done -# while true -# do -# echo "Delete more?" -# echo - - -# done - } export -f deleteBackup From 7c9cf2366448decc28d414086b43146db009a7c5 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 23:32:01 -0600 Subject: [PATCH 322/352] test nl --- functions/backup.sh | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index b8946e4a..f2e37b6f 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -33,7 +33,7 @@ deleteBackup(){ while true do clear -x && echo "pulling all restore points.." - list_backups=$(cli -c 'app kubernetes list_backups' | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t) + list_backups=$(cli -c 'app kubernetes list_backups' | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl -s \) | column -t) clear -x if [[ -z "$list_backups" ]]; then echo "No restore points available" @@ -48,38 +48,43 @@ do #Check for valid selection. If none, kill script if [[ -z "$selection" ]]; then echo "Your selection cannot be empty" + sleep 3 continue elif [[ -z "$restore_point" ]]; then echo "Invalid Selection: $selection, was not an option" + sleep 3 continue fi while true do + clear -x echo -e "\nWARNING:\nYou CANNOT go back after deleting your restore point" echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" - echo -e "Yes\n0 exit\n" - read -rt 120 -p "Type \"yes\" to continue, or exit with \"0\": " yesno + echo -e "1) Yes\n2) Exit\n" + read -rt 120 -p "Please type a number: " yesno case $yesno in - [Yy][Ee][Ss]) + 1) echo -e "\nDeleting $restore_point" cli -c 'app kubernetes delete_backup backup_name=''"'"$restore_point"'"' &>/dev/null || { echo "Failed to delete backup.."; exit; } echo "Sucessfully deleted" break ;; - 0|[Ee][Xx][Ii][Tt]) + 2) echo "Exiting" exit ;; *) - echo "Invalid Selection" + echo "That was not an option, try again" + sleep 3 + continue ;; esac done while true do echo "Delete more?" - echo "1 Yes" - echo "2 No" + echo "1) Yes" + echo "2) No" read -rt 120 -p "Please type a number: " yesno case $yesno in 1) From 7ad86534f0356758a55e9cdc7a9eded55d298dce Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 23:32:45 -0600 Subject: [PATCH 323/352] test --- functions/backup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/backup.sh b/functions/backup.sh index f2e37b6f..7fa5f08f 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -33,7 +33,7 @@ deleteBackup(){ while true do clear -x && echo "pulling all restore points.." - list_backups=$(cli -c 'app kubernetes list_backups' | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl -s \) | column -t) + list_backups=$(cli -c 'app kubernetes list_backups' | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl -s ") " | column -t) clear -x if [[ -z "$list_backups" ]]; then echo "No restore points available" From 048efbd4ba08b6a50d3aae680824606930a1e237 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 23:33:44 -0600 Subject: [PATCH 324/352] fix regex --- functions/backup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/backup.sh b/functions/backup.sh index 7fa5f08f..80ab8ec2 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -44,7 +44,7 @@ do fi echo "$list_backups" read -rt 120 -p "Please type a number: " selection - restore_point=$(echo "$list_backups" | grep ^"$selection " | awk '{print $2}') + restore_point=$(echo "$list_backups" | grep ^"$selection)" | awk '{print $2}') #Check for valid selection. If none, kill script if [[ -z "$selection" ]]; then echo "Your selection cannot be empty" From 4b3847c6fc391d46f54e536ef44d81c6cc72296a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 23:46:08 -0600 Subject: [PATCH 325/352] restore improvement --- functions/backup.sh | 66 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 50 insertions(+), 16 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index 80ab8ec2..ffc90786 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -108,21 +108,55 @@ export -f deleteBackup restore(){ -clear -x && echo "pulling restore points.." -list_backups=$(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl | column -t) -clear -x -[[ -z "$list_backups" ]] && echo "No HeavyScript restore points available" && exit || { title; echo "Choose a restore point" ; } -echo "$list_backups" && read -t 600 -p "Please type a number: " selection && restore_point=$(echo "$list_backups" | grep ^"$selection " | awk '{print $2}') -[[ -z "$selection" ]] && echo "Your selection cannot be empty" && exit #Check for valid selection. If none, kill script -[[ -z "$restore_point" ]] && echo "Invalid Selection: $selection, was not an option" && exit #Check for valid selection. If none, kill script -echo -e "\nWARNING:\nThis is NOT guranteed to work\nThis is ONLY supposed to be used as a LAST RESORT\nConsider rolling back your applications instead if possible" || { echo "FAILED"; exit; } -echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" && echo -e "1 Yes\n2 No" && read -t 120 -p "Please type a number: " yesno || { echo "FAILED"; exit; } -if [[ $yesno == "1" ]]; then - echo -e "\nStarting Backup, this will take a LONG time." && cli -c 'app kubernetes restore_backup backup_name=''"'"$restore_point"'"' || echo "Restore FAILED" -elif [[ $yesno == "2" ]]; then - echo "You've chosen NO, killing script. Good luck." -else - echo "Invalid Selection" -fi +while true +do + clear -x && echo "pulling restore points.." + list_backups=$(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl -s ") " | column -t) + clear -x + if [[ -z "$list_backups" ]]; then + echo "No HeavyScript restore points available" + exit + else + title + echo "Choose a restore point" + fi + echo "$list_backups" + read -rt 120 -p "Please type a number: " selection + restore_point=$(echo "$list_backups" | grep ^"$selection)" | awk '{print $2}') + #Check for valid selection. If none, kill script + if [[ -z "$selection" ]]; then + echo "Your selection cannot be empty" + sleep 3 + continue + elif [[ -z "$restore_point" ]]; then + echo "Invalid Selection: $selection, was not an option" + sleep 3 + continue + fi + while true + do + clear -x + echo -e "\nWARNING:\nThis is NOT guranteed to work\nThis is ONLY supposed to be used as a LAST RESORT\nConsider rolling back your applications instead if possible" + echo -e "\n\nYou have chosen:\n$restore_point\n\nWould you like to continue?" + echo -e "1) Yes\n2) Exit\n" + read -rt 120 -p "Please type a number: " yesno + case $yesno in + 1) + echo -e "\nStarting Backup, this will take a LONG time." + cli -c 'app kubernetes restore_backup backup_name=''"'"$restore_point"'"' || { echo "Failed to delete backup.."; exit; } + exit + ;; + 2) + echo "Exiting" + exit + ;; + *) + echo "That was not an option, try again" + sleep 3 + continue + ;; + esac + done +done } export -f restore \ No newline at end of file From 79f957f8ac26f296eb19ae69c6343f552736fc0a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 23:49:53 -0600 Subject: [PATCH 326/352] exit option --- functions/backup.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/functions/backup.sh b/functions/backup.sh index ffc90786..9199a560 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -121,7 +121,10 @@ do echo "Choose a restore point" fi echo "$list_backups" + echo + echo "0) Exit" read -rt 120 -p "Please type a number: " selection + [[ $selection == 0 ]] && echo "Exiting.." && exit restore_point=$(echo "$list_backups" | grep ^"$selection)" | awk '{print $2}') #Check for valid selection. If none, kill script if [[ -z "$selection" ]]; then From 719e1088af8a22a1596e6537809f417bea5ddebf Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 28 Jul 2022 23:51:33 -0600 Subject: [PATCH 327/352] exit option for deletebackup --- functions/backup.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/functions/backup.sh b/functions/backup.sh index 9199a560..adc3fece 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -43,7 +43,10 @@ do echo -e "Choose a restore point to delete\nThese may be out of order if they are not HeavyScript backups" fi echo "$list_backups" + echo + echo "0) Exit" read -rt 120 -p "Please type a number: " selection + [[ $selection == 0 ]] && echo "Exiting.." && exit restore_point=$(echo "$list_backups" | grep ^"$selection)" | awk '{print $2}') #Check for valid selection. If none, kill script if [[ -z "$selection" ]]; then From 4841c568fa0ad305c6c0bb398967291776f4dda0 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 00:08:30 -0600 Subject: [PATCH 328/352] better message --- functions/backup.sh | 4 ++-- functions/mount.sh | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index adc3fece..1345eae2 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -40,7 +40,7 @@ do exit else title - echo -e "Choose a restore point to delete\nThese may be out of order if they are not HeavyScript backups" + echo -e "Choose a Restore Point to Delete\nThese may be out of order if they are not HeavyScript backups" fi echo "$list_backups" echo @@ -121,7 +121,7 @@ do exit else title - echo "Choose a restore point" + echo "Choose a Restore Point" fi echo "$list_backups" echo diff --git a/functions/mount.sh b/functions/mount.sh index aabc3989..8a096579 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -90,6 +90,7 @@ do fi done rmdir /mnt/heavyscript + sleep 2 ;; *) echo "Invalid selection, \"$selection\" was not an option" From 571e00a2f4f76da51cff664d26c7969886ddd308 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 00:25:20 -0600 Subject: [PATCH 329/352] delete-backup avoid extra calls --- functions/backup.sh | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index 1345eae2..916291ff 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -42,22 +42,27 @@ do title echo -e "Choose a Restore Point to Delete\nThese may be out of order if they are not HeavyScript backups" fi - echo "$list_backups" - echo - echo "0) Exit" - read -rt 120 -p "Please type a number: " selection - [[ $selection == 0 ]] && echo "Exiting.." && exit - restore_point=$(echo "$list_backups" | grep ^"$selection)" | awk '{print $2}') - #Check for valid selection. If none, kill script - if [[ -z "$selection" ]]; then - echo "Your selection cannot be empty" - sleep 3 - continue - elif [[ -z "$restore_point" ]]; then - echo "Invalid Selection: $selection, was not an option" - sleep 3 - continue - fi + while true + do + echo "$list_backups" + echo + echo "0) Exit" + read -rt 120 -p "Please type a number: " selection + restore_point=$(echo "$list_backups" | grep ^"$selection)" | awk '{print $2}') + if [[ $selection == 0 ]]; then + echo "Exiting.." + exit + elif [[ -z "$selection" ]]; then + echo "Your selection cannot be empty" + sleep 3 + continue + elif [[ -z "$restore_point" ]]; then + echo "Invalid Selection: $selection, was not an option" + sleep 3 + continue + fi + break + done while true do clear -x From 291ad68542dc1db84e16a8773eff9332307e6770 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 00:26:47 -0600 Subject: [PATCH 330/352] fix --- functions/backup.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index 916291ff..2dd2c960 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -34,16 +34,15 @@ while true do clear -x && echo "pulling all restore points.." list_backups=$(cli -c 'app kubernetes list_backups' | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl -s ") " | column -t) - clear -x if [[ -z "$list_backups" ]]; then echo "No restore points available" exit - else - title - echo -e "Choose a Restore Point to Delete\nThese may be out of order if they are not HeavyScript backups" fi while true do + clear -x + title + echo -e "Choose a Restore Point to Delete\nThese may be out of order if they are not HeavyScript backups" echo "$list_backups" echo echo "0) Exit" From 73f060cea334d8325c7c744a5a909dbc9ff62024 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 00:34:55 -0600 Subject: [PATCH 331/352] restore update --- functions/backup.sh | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/functions/backup.sh b/functions/backup.sh index 2dd2c960..b875e08c 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -119,30 +119,33 @@ while true do clear -x && echo "pulling restore points.." list_backups=$(cli -c 'app kubernetes list_backups' | grep "HeavyScript_" | sort -t '_' -Vr -k2,7 | tr -d " \t\r" | awk -F '|' '{print $2}' | nl -s ") " | column -t) - clear -x if [[ -z "$list_backups" ]]; then echo "No HeavyScript restore points available" exit - else + fi + while true + do + clear -x title echo "Choose a Restore Point" - fi - echo "$list_backups" - echo - echo "0) Exit" - read -rt 120 -p "Please type a number: " selection - [[ $selection == 0 ]] && echo "Exiting.." && exit - restore_point=$(echo "$list_backups" | grep ^"$selection)" | awk '{print $2}') - #Check for valid selection. If none, kill script - if [[ -z "$selection" ]]; then - echo "Your selection cannot be empty" - sleep 3 - continue - elif [[ -z "$restore_point" ]]; then - echo "Invalid Selection: $selection, was not an option" - sleep 3 - continue - fi + echo "$list_backups" + echo + echo "0) Exit" + read -rt 120 -p "Please type a number: " selection + restore_point=$(echo "$list_backups" | grep ^"$selection)" | awk '{print $2}') + if [[ $selection == 0 ]]; then + echo "Exiting.." + exit + elif [[ -z "$selection" ]]; then + echo "Your selection cannot be empty" + sleep 3 + continue + elif [[ -z "$restore_point" ]]; then + echo "Invalid Selection: $selection, was not an option" + sleep 3 + continue + fi + done while true do clear -x From 06c80dd5ebc1dc5619b4fa720adf33b06664b16a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 00:35:54 -0600 Subject: [PATCH 332/352] break --- functions/backup.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/backup.sh b/functions/backup.sh index b875e08c..9561b5d6 100644 --- a/functions/backup.sh +++ b/functions/backup.sh @@ -145,6 +145,7 @@ do sleep 3 continue fi + break done while true do From 21c46258f62b523e35f3ea5e925961ed0678c156 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 00:45:22 -0600 Subject: [PATCH 333/352] break on bottom line --- functions/update_apps.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 460877eb..be33626f 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -117,11 +117,13 @@ if [[ $rollback == "true" ]]; then elif [[ "$status" == "STOPPED" ]]; then [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 15 && continue #if reports stopped on FIRST time through loop, double check [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check - echo_array+=("Stopped") && break #if reports stopped any time after the first loop, assume its extermal services. + echo_array+=("Stopped") + break #if reports stopped any time after the first loop, assume its extermal services. elif [[ "$status" == "ACTIVE" ]]; then [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 15 && continue #if reports active on FIRST time through loop, double check [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check - echo_array+=("Active") && break #if reports active any time after the first loop, assume actually active. + echo_array+=("Active") + break #if reports active any time after the first loop, assume actually active. else [[ "$verbose" == "true" ]] && echo_array+=("Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE") sleep 15 @@ -137,7 +139,7 @@ else if [[ "$status" == "STOPPED" ]]; then [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 15 && continue #if reports stopped on FIRST time through loop, double check [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports stopped on FIRST time through loop, double check - echo_array+=("Stopped") && break #assume actually stopped anytime AFTER the first loop + echo_array+=("Stopped") #assume actually stopped anytime AFTER the first loop break elif [[ "$status" == "ACTIVE" ]]; then [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 15 && continue #if reports active on FIRST time through loop, double check From 542ac5ee0b6582f7d89aad286c5d73ffe5e46a9e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 00:47:38 -0600 Subject: [PATCH 334/352] remove unused help --- heavy_script.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/heavy_script.sh b/heavy_script.sh index f0e3015c..adb5022c 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -52,14 +52,14 @@ do deleteBackup="true" ;; *) - echo -e "Invalid Option \"--$OPTARG\"\n" && help - exit + echo -e "Invalid Option \"--$OPTARG\"\n" + help ;; esac ;; :) - echo -e "Option: \"-$OPTARG\" requires an argument\n" && help - exit + echo -e "Option: \"-$OPTARG\" requires an argument\n" + help ;; b) number_of_backups=$OPTARG @@ -119,12 +119,12 @@ do verbose="true" ;; \?) - echo -e "Invalid Option \"-$OPTARG\"\n" && help - exit + echo -e "Invalid Option \"-$OPTARG\"\n" + help ;; *) - echo -e "Invalid Option \"-$OPTARG\"\n" && help - exit + echo -e "Invalid Option \"-$OPTARG\"\n" + help ;; esac done From 3107bc97cd351ba5aa3f58b93c04dde5d5d85fd7 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 00:50:33 -0600 Subject: [PATCH 335/352] change lines --- functions/mount.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/functions/mount.sh b/functions/mount.sh index 8a096579..ec2d7938 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -84,9 +84,11 @@ do echo "$i is a name used on more than one pool.. attempting to use your current kubernetes apps pool" pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") full_path=$(find /mnt/"$pool"/ix-applications/releases/"$app"/volumes/ -maxdepth 0 | cut -c 6-) - zfs set mountpoint=legacy "$full_path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" + zfs set mountpoint=legacy "$full_path""$pvc" + echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" else - zfs set mountpoint=legacy "$path""$pvc" && echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" + zfs set mountpoint=legacy "$path""$pvc" + echo "$i unmounted" && rmdir /mnt/heavyscript/"$i" || echo "failed to unmount $i" fi done rmdir /mnt/heavyscript From b1c62e68922664fe64f66a14752427816c246374 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 00:52:26 -0600 Subject: [PATCH 336/352] mount clear after continue --- functions/mount.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/mount.sh b/functions/mount.sh index ec2d7938..210f9699 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -57,6 +57,7 @@ do read -rt 120 -p "Please type a number: " yesno case $yesno in 1) + clear -x break ;; 2) From 42558612463d4c463f470e205492a050d6cbd3c3 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 00:53:11 -0600 Subject: [PATCH 337/352] add title again --- functions/mount.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/mount.sh b/functions/mount.sh index 210f9699..da01352d 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -58,6 +58,7 @@ do case $yesno in 1) clear -x + title break ;; 2) From f1f495544ba59218b7802b890e81dcc214e4bb5c Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 00:56:12 -0600 Subject: [PATCH 338/352] better output after invalid --- functions/mount.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/mount.sh b/functions/mount.sh index da01352d..993e4d51 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -23,7 +23,7 @@ do echo "$list" read -rt 120 -p "Please type a number: " selection app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) - [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && sleep 5 && continue #Check for valid selection. If none, kill script + [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && sleep 3 && clear -x && title && echo "$list" continue #Check for valid selection. If none, contiue pvc=$(echo -e "$list" | grep ^"$selection ") status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") if [[ "$status" != "STOPPED" ]]; then From fd26ef349a38e7c6b9b597789bdd36197d5b35b5 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 00:56:55 -0600 Subject: [PATCH 339/352] whoops --- functions/mount.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/mount.sh b/functions/mount.sh index 993e4d51..c52ee704 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -23,7 +23,7 @@ do echo "$list" read -rt 120 -p "Please type a number: " selection app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) - [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && sleep 3 && clear -x && title && echo "$list" continue #Check for valid selection. If none, contiue + [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && sleep 3 && clear -x && title && echo "$list" && continue #Check for valid selection. If none, contiue pvc=$(echo -e "$list" | grep ^"$selection ") status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") if [[ "$status" != "STOPPED" ]]; then From a211dc9a8ae7d72e68c66f0e334e60afed15913f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 00:58:49 -0600 Subject: [PATCH 340/352] tired --- functions/mount.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/functions/mount.sh b/functions/mount.sh index c52ee704..d88253cd 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -20,10 +20,12 @@ do while true do list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") + clear -x + title echo "$list" read -rt 120 -p "Please type a number: " selection app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) - [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && sleep 3 && clear -x && title && echo "$list" && continue #Check for valid selection. If none, contiue + [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && sleep 3 && continue #Check for valid selection. If none, contiue pvc=$(echo -e "$list" | grep ^"$selection ") status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") if [[ "$status" != "STOPPED" ]]; then From 22589499ada538ad9272c9826fb335a47cae072d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 01:02:13 -0600 Subject: [PATCH 341/352] avoid calling more than once --- functions/mount.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/functions/mount.sh b/functions/mount.sh index d88253cd..8082d0f8 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -10,7 +10,7 @@ do echo echo "0) Exit" read -rt 120 -p "Unmount All Please type a number: " selection - + list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") case $selection in 0) echo "Exiting.." @@ -19,7 +19,6 @@ do 1) while true do - list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") clear -x title echo "$list" From 717306e01f39d075d1fc925c54d723aac8bbe452 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 01:03:01 -0600 Subject: [PATCH 342/352] only list with option 1 --- functions/mount.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/mount.sh b/functions/mount.sh index 8082d0f8..422a10e3 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -10,13 +10,13 @@ do echo echo "0) Exit" read -rt 120 -p "Unmount All Please type a number: " selection - list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") case $selection in 0) echo "Exiting.." exit ;; 1) + list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") while true do clear -x From 4f303e3489a40dbdcf1315cd367366e1c0af2302 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 01:22:59 -0600 Subject: [PATCH 343/352] while loop for async check --- functions/menu.sh | 72 ++++++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 32 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 27e702a6..710a144a 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -59,39 +59,47 @@ case $selection in echo read -rt 600 -p "Please type the number associated with the flag above: " current_selection if [[ $current_selection == 1 ]]; then - echo -e "\nHow many applications do you want updating at the same time?" - read -rt 600 -p "Please type an integer greater than 0: " up_async - if [[ $up_async == 0 ]]; then - echo "Error: \"$up_async\" is less than 1" - echo "NOT adding it to the list" - sleep 5 - continue - elif ! [[ $up_async =~ ^[0-9]+$ ]]; then - echo "Error: \"$up_async\" is invalid, it needs to be an integer" - echo "NOT adding it to the list" - sleep 5 - continue - else - update_selection+=("-U" "$up_async") - break - fi + while true + do + echo -e "\nHow many applications do you want updating at the same time?" + read -rt 600 -p "Please type an integer greater than 0: " up_async + if [[ $up_async == 0 ]]; then + echo "Error: \"$up_async\" is less than 1" + echo "NOT adding it to the list" + sleep 5 + continue + elif ! [[ $up_async =~ ^[0-9]+$ ]]; then + echo "Error: \"$up_async\" is invalid, it needs to be an integer" + echo "NOT adding it to the list" + sleep 5 + continue + else + update_selection+=("-U" "$up_async") + break + fi + done + break elif [[ $current_selection == 2 ]]; then - echo -e "\nHow many applications do you want updating at the same time?" - read -rt 600 -p "Please type an integer greater than 0: " up_async - if [[ $up_async == 0 ]]; then - echo "Error: \"$up_async\" is less than 1" - echo "NOT adding it to the list" - sleep 5 - continue - elif ! [[ $up_async =~ ^[0-9]+$ ]]; then - echo "Error: \"$up_async\" is invalid, it needs to be an integer" - echo "NOT adding it to the list" - sleep 5 - continue - else - update_selection+=("-u" "$up_async") - break - fi + while true + do + echo -e "\nHow many applications do you want updating at the same time?" + read -rt 600 -p "Please type an integer greater than 0: " up_async + if [[ $up_async == 0 ]]; then + echo "Error: \"$up_async\" is less than 1" + echo "NOT adding it to the list" + sleep 5 + continue + elif ! [[ $up_async =~ ^[0-9]+$ ]]; then + echo "Error: \"$up_async\" is invalid, it needs to be an integer" + echo "NOT adding it to the list" + sleep 5 + continue + else + update_selection+=("-u" "$up_async") + break + fi + done + break elif [[ $current_selection == 0 ]]; then echo "Exiting.." exit From c7c3be0d95a7a5ad3368d0d6ed0105add3e44313 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 01:26:47 -0600 Subject: [PATCH 344/352] exit for updates menu --- functions/menu.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/functions/menu.sh b/functions/menu.sh index 710a144a..8330cc33 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -127,12 +127,18 @@ case $selection in echo "99) Remove Update Options, Restart" echo "00) Done making selections, proceed with update" echo + echo "0) Exit" + echo echo "Current Choices" echo "---------------" echo "bash heavy_script.sh ${update_selection[*]}" echo read -rt 600 -p "Type the Number OR Flag: " current_selection case $current_selection in + 0) + echo "Exiting.." + exit + ;; 00) clear -x echo "Running \"bash heavy_script.sh ${update_selection[*]}\"" From 3baffef323f522cc511d994a2f5a42372050ce5b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 01:30:27 -0600 Subject: [PATCH 345/352] exit menu mount --- functions/mount.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/functions/mount.sh b/functions/mount.sh index 422a10e3..c15158b3 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -22,7 +22,10 @@ do clear -x title echo "$list" + echo + echo "0 Exit" read -rt 120 -p "Please type a number: " selection + [[ $selection == 0 ]] && echo "Exiting.." && exit app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && sleep 3 && continue #Check for valid selection. If none, contiue pvc=$(echo -e "$list" | grep ^"$selection ") From d70bb33dd3dadbba040402ab4cad42e23892e526 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 01:51:37 -0600 Subject: [PATCH 346/352] test --- functions/mount.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/functions/mount.sh b/functions/mount.sh index c15158b3..cd700a67 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -16,7 +16,11 @@ do exit ;; 1) - list=$(k3s kubectl get pvc -A | sort -u | awk '{print NR-1, "\t" $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") + call=$(k3s kubectl get pvc -A | sort -u | awk '{print $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") + mount_list=$(echo "$call" | sed 1d | nl -s ") ") + mount_title=$(echo "$call" | head -n 1) + list=$(echo -e "$mount_title \n $mount_title") + while true do clear -x From e39912f0b1bee19658a0d484224cf11de7bb5935 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 01:52:27 -0600 Subject: [PATCH 347/352] test --- functions/mount.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/mount.sh b/functions/mount.sh index cd700a67..d0c28ce1 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -19,7 +19,7 @@ do call=$(k3s kubectl get pvc -A | sort -u | awk '{print $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") mount_list=$(echo "$call" | sed 1d | nl -s ") ") mount_title=$(echo "$call" | head -n 1) - list=$(echo -e "$mount_title \n $mount_title") + list=$(echo -e "$mount_title\n$mount_list") while true do From dba0e738e6ec96d7f6f44299c71104b322f13ec4 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 01:53:05 -0600 Subject: [PATCH 348/352] test --- functions/mount.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/mount.sh b/functions/mount.sh index d0c28ce1..0778a522 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -16,10 +16,10 @@ do exit ;; 1) - call=$(k3s kubectl get pvc -A | sort -u | awk '{print $1 "\t" $2 "\t" $4}' | column -t | sed "s/^0/ /") + call=$(k3s kubectl get pvc -A | sort -u | awk '{print $1 "\t" $2 "\t" $4}' | sed "s/^0/ /") mount_list=$(echo "$call" | sed 1d | nl -s ") ") mount_title=$(echo "$call" | head -n 1) - list=$(echo -e "$mount_title\n$mount_list") + list=$(echo -e "$mount_title\n$mount_list" | column -t) while true do From 978fdd7866b32f78d305fad2c8365c892818e1df Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 01:53:49 -0600 Subject: [PATCH 349/352] test --- functions/mount.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/mount.sh b/functions/mount.sh index 0778a522..b155071e 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -19,7 +19,7 @@ do call=$(k3s kubectl get pvc -A | sort -u | awk '{print $1 "\t" $2 "\t" $4}' | sed "s/^0/ /") mount_list=$(echo "$call" | sed 1d | nl -s ") ") mount_title=$(echo "$call" | head -n 1) - list=$(echo -e "$mount_title\n$mount_list" | column -t) + list=$(echo -e "# $mount_title\n$mount_list" | column -t) while true do From 4e24d1577e5256ad9e84bedbe5ef3e246bdb78a8 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 01:55:09 -0600 Subject: [PATCH 350/352] test --- functions/mount.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/mount.sh b/functions/mount.sh index b155071e..82909364 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -19,7 +19,7 @@ do call=$(k3s kubectl get pvc -A | sort -u | awk '{print $1 "\t" $2 "\t" $4}' | sed "s/^0/ /") mount_list=$(echo "$call" | sed 1d | nl -s ") ") mount_title=$(echo "$call" | head -n 1) - list=$(echo -e "# $mount_title\n$mount_list" | column -t) + list=$(echo -e "# $mount_title\n$mount_list\n\n0) Exit" | column -t) while true do From 67a6436944e4f0eb6362c6728cd2f673fabf1819 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 01:56:58 -0600 Subject: [PATCH 351/352] mount number brackets --- functions/mount.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/functions/mount.sh b/functions/mount.sh index 82909364..52a32359 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -19,7 +19,7 @@ do call=$(k3s kubectl get pvc -A | sort -u | awk '{print $1 "\t" $2 "\t" $4}' | sed "s/^0/ /") mount_list=$(echo "$call" | sed 1d | nl -s ") ") mount_title=$(echo "$call" | head -n 1) - list=$(echo -e "# $mount_title\n$mount_list\n\n0) Exit" | column -t) + list=$(echo -e "# $mount_title\n$mount_list" | column -t) while true do @@ -27,12 +27,12 @@ do title echo "$list" echo - echo "0 Exit" + echo "0) Exit" read -rt 120 -p "Please type a number: " selection [[ $selection == 0 ]] && echo "Exiting.." && exit - app=$(echo -e "$list" | grep ^"$selection " | awk '{print $2}' | cut -c 4- ) + app=$(echo -e "$list" | grep ^"$selection)" | awk '{print $2}' | cut -c 4- ) [[ -z "$app" ]] && echo "Invalid Selection: $selection, was not an option" && sleep 3 && continue #Check for valid selection. If none, contiue - pvc=$(echo -e "$list" | grep ^"$selection ") + pvc=$(echo -e "$list" | grep ^"$selection)") status=$(cli -m csv -c 'app chart_release query name,status' | grep -E "^$app\b" | awk -F ',' '{print $2}'| tr -d " \t\n\r") if [[ "$status" != "STOPPED" ]]; then [[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout" From df19c4f553971e6fd7e1540598d354994bdcfedd Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 29 Jul 2022 01:58:44 -0600 Subject: [PATCH 352/352] mounting complete --- functions/mount.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/functions/mount.sh b/functions/mount.sh index 52a32359..e574fcac 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -20,7 +20,6 @@ do mount_list=$(echo "$call" | sed 1d | nl -s ") ") mount_title=$(echo "$call" | head -n 1) list=$(echo -e "# $mount_title\n$mount_list" | column -t) - while true do clear -x