From c0f6ed10a83133a8f3dd520fe5089cf4c1ae44f1 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 30 Aug 2022 21:36:34 -0600 Subject: [PATCH] Documentation, remove redundant code, spacing --- functions/menu.sh | 1 - functions/mount.sh | 4 ++-- functions/update_apps.sh | 3 +++ heavy_script.sh | 5 ++--- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index a8677314..921b64f6 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -32,7 +32,6 @@ case $selection in ;; 4) read -rt 120 -p "What is the maximun number of backups you would like?: " number_of_backups || { echo -e "\nFailed to make a selection in time" ; exit; } - backup="true" ;; 5) restore diff --git a/functions/mount.sh b/functions/mount.sh index c915407e..c58f8571 100644 --- a/functions/mount.sh +++ b/functions/mount.sh @@ -51,7 +51,7 @@ do 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") + pool=$(cli -c 'app kubernetes config' | grep -E "pool\s\|" | awk -F '|' '{print $3}' | 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" @@ -90,7 +90,7 @@ do 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") + pool=$(cli -c 'app kubernetes config' | grep -E "pool\s\|" | awk -F '|' '{print $3}' | 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" diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 50629e2e..ce6a4476 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -136,6 +136,8 @@ count=0 if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then while true do + + # If app reports ACTIVE right away, assume its a false positive and wait for it to change, or trust it after 5 updates to all_app_status status=$(grep "^$app_name," all_app_status | awk -F ',' '{print $2}') if [[ $count -lt 1 && $status == "ACTIVE" && "$(grep "^$app_name," deploying 2>/dev/null | awk -F ',' '{print $2}')" != "DEPLOYING" ]]; then # If status shows up as Active or Stopped on the first check, verify that. Otherwise it may be a false report.. [[ "$verbose" == "true" ]] && echo_array+=("Verifying $status..") @@ -152,6 +154,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then done fi (( count++ )) + if [[ "$status" == "ACTIVE" ]]; then if [[ "$startstatus" == "STOPPED" ]]; then [[ "$verbose" == "true" ]] && echo_array+=("Returing to STOPPED state..") diff --git a/heavy_script.sh b/heavy_script.sh index 6858ed4d..76d03a9a 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -66,7 +66,6 @@ do 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" @@ -138,14 +137,14 @@ done [[ "$dns" == "true" ]] && dns && exit [[ "$restore" == "true" ]] && restore && exit [[ "$mount" == "true" ]] && mount && exit -if [[ "$backup" == "true" && "$sync" == "true" ]]; then # Run backup and sync at the same time +if [[ "$backup" -gt 1 && "$sync" == "true" ]]; then # Run backup and sync at the same time 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\n" backup & sync & wait -elif [[ "$backup" == "true" && -z "$sync" ]]; then # If only backup is true, run it +elif [[ "$backup" -gt 1 && -z "$sync" ]]; then # If only backup is true, run it echo "🅃 🄰 🅂 🄺 :" echo -e "-Backing up \"ix-applications\" Dataset\nPlease Wait..\n\n" backup