From 97b65f746d776f821c767ab27d9a4cf8eb401472 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 27 Jul 2022 09:47:19 -0600 Subject: [PATCH 1/4] 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 2/4] 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 3/4] 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 4/4] 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"