From 1d4be7191c617163c6e2481b4657ee4c10abb077 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 14:14:32 -0600 Subject: [PATCH 001/218] test ignore file for failed rollbacks --- functions/update_apps.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 9989a64e..05b44752 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -54,6 +54,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}') +if grep -qs "^$app_name," failed.txt ; then + if diff <(grep "^$app_name," | awk -F ',' '{print $2}') <(echo "$new_full_ver") ; then + sed -i /"$app_name","$new_full_ver"/d failed.txt + else + echo "Skipping already failed version $new_full_ver" + return 0 + fi +fi 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 @@ -111,6 +119,7 @@ if [[ $rollback == "true" ]]; then 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 + echo "$app_name,$new_full_ver" >> failed.txt break elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" && "$failed" == "true" ]]; then 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") From 738a773975df5dc06d9b699391fd38c8e7624c73 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 14:19:48 -0600 Subject: [PATCH 002/218] diff supress and appname --- 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 05b44752..8784cba1 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -55,9 +55,10 @@ 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}') if grep -qs "^$app_name," failed.txt ; then - if diff <(grep "^$app_name," | awk -F ',' '{print $2}') <(echo "$new_full_ver") ; then + if diff <(grep "^$app_name," | awk -F ',' '{print $2}') <(echo "$new_full_ver") &> /dev/null ; then sed -i /"$app_name","$new_full_ver"/d failed.txt else + echo "$app_name" echo "Skipping already failed version $new_full_ver" return 0 fi From 286c215281529e4295d15a0025fb2b81cbcce215 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 14:20:40 -0600 Subject: [PATCH 003/218] newline for appname --- 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 8784cba1..6100d688 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -58,7 +58,7 @@ if grep -qs "^$app_name," failed.txt ; then if diff <(grep "^$app_name," | awk -F ',' '{print $2}') <(echo "$new_full_ver") &> /dev/null ; then sed -i /"$app_name","$new_full_ver"/d failed.txt else - echo "$app_name" + echo -e "\n$app_name" echo "Skipping already failed version $new_full_ver" return 0 fi From 9ad8673e8bfb3703c4af6491fde1e8f3b97a59bb Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 14:36:39 -0600 Subject: [PATCH 004/218] test string --- 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 6100d688..95a57cc8 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -55,8 +55,9 @@ 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}') if grep -qs "^$app_name," failed.txt ; then - if diff <(grep "^$app_name," | awk -F ',' '{print $2}') <(echo "$new_full_ver") &> /dev/null ; then - sed -i /"$app_name","$new_full_ver"/d failed.txt + failed_ver=$(grep "^$app_name," | awk -F ',' '{print $2}') + if diff <(echo "$failed_ver") <(echo "$new_full_ver") &> /dev/null ; then + sed -inE /"$app_name",.*/d failed.txt else echo -e "\n$app_name" echo "Skipping already failed version $new_full_ver" From 0a2f3147a967900353f102b5abe666f1f2b247eb Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 14:38:43 -0600 Subject: [PATCH 005/218] forgot filename --- functions/update_apps.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 95a57cc8..9369e095 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -55,8 +55,7 @@ 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}') if grep -qs "^$app_name," failed.txt ; then - failed_ver=$(grep "^$app_name," | awk -F ',' '{print $2}') - if diff <(echo "$failed_ver") <(echo "$new_full_ver") &> /dev/null ; then + if diff <(grep "^$app_name," failed.txt | awk -F ',' '{print $2}') <(echo "$new_full_ver") &> /dev/null ; then sed -inE /"$app_name",.*/d failed.txt else echo -e "\n$app_name" From 8b1916c36f11bb68c62e48ef6c12ab22d86af598 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 14:40:55 -0600 Subject: [PATCH 006/218] uh --- 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 9369e095..e96c3135 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -56,7 +56,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 grep -qs "^$app_name," failed.txt ; then if diff <(grep "^$app_name," failed.txt | awk -F ',' '{print $2}') <(echo "$new_full_ver") &> /dev/null ; then - sed -inE /"$app_name",.*/d failed.txt + sed -i /"$app_name",/d failed.txt else echo -e "\n$app_name" echo "Skipping already failed version $new_full_ver" From 7ba7b1fd9d20b0d243307df918909b9c896789e7 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 14:46:00 -0600 Subject: [PATCH 007/218] test string compare instead of diff --- 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 e96c3135..18f17b9e 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -55,12 +55,13 @@ 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}') if grep -qs "^$app_name," failed.txt ; then - if diff <(grep "^$app_name," failed.txt | awk -F ',' '{print $2}') <(echo "$new_full_ver") &> /dev/null ; then - sed -i /"$app_name",/d failed.txt - else + failed_ver=$(grep "^$app_name," failed.txt | awk -F ',' '{print $2}') + if [[ "$failed_ver" == "$new_full_ver" ]] ; then echo -e "\n$app_name" echo "Skipping already failed version $new_full_ver" return 0 + else + sed -i /"$app_name",/d failed.txt fi fi if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update From c3a4915de22dca72204b4bf6d31d877412f1ac39 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 16:08:45 -0600 Subject: [PATCH 008/218] better skip message --- 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 18f17b9e..b511c850 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -58,10 +58,10 @@ if grep -qs "^$app_name," failed.txt ; then failed_ver=$(grep "^$app_name," failed.txt | awk -F ',' '{print $2}') if [[ "$failed_ver" == "$new_full_ver" ]] ; then echo -e "\n$app_name" - echo "Skipping already failed version $new_full_ver" + echo -e "Skipping previously failed version:\n$new_full_ver" return 0 else - sed -i /"$app_name",/d failed.txt + sed -i /"$app_name",/d failed.txt fi fi if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update From 42af8744b4fed00436c2e81a92c43bb1819d302d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 16:48:55 -0600 Subject: [PATCH 009/218] change after_update_actions --- functions/update_apps.sh | 55 +++++++++++++--------------------------- 1 file changed, 18 insertions(+), 37 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index b511c850..e7b97d33 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -108,7 +108,7 @@ export -f update_apps after_update_actions(){ SECONDS=0 count=0 -if [[ $rollback == "true" ]]; then +if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then while true do (( count++ )) @@ -117,15 +117,22 @@ if [[ $rollback == "true" ]]; 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") break - elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" && "$failed" != "true" ]]; then - 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 - echo "$app_name,$new_full_ver" >> failed.txt - break - elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" && "$failed" == "true" ]]; then - 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 [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then + if [[ $rollback == "true" ]]; then + if [[ "$failed" != "true" ]]; then + 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 + echo "$app_name,$new_full_ver" >> failed.txt + break + elif [[ "$failed" == "true" ]]; then + 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 + fi + else + echo_array+=("Error: Run Time($SECONDS) has exceeded Timeout($timeout)") + break + fi 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 @@ -142,35 +149,9 @@ if [[ $rollback == "true" ]]; then 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=$( 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 - 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 - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 15 && continue #if reports active on FIRST time through loop, double check - [[ "$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_array+=("Error: Run Time($SECONDS) has exceeded Timeout($timeout)") - break - else - [[ "$verbose" == "true" ]] && echo_array+=("Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE") - sleep 10 - continue - fi - done - fi fi + #Dump the echo_array, ensures all output is in a neat order. for i in "${echo_array[@]}" do From 2ba8a6c084a07b753dd927689b721c41da7b4b45 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 16:51:10 -0600 Subject: [PATCH 010/218] after update action call after update --- 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 e7b97d33..503e7afc 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -69,7 +69,7 @@ if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #con 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") + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=("Updated\n$old_full_ver\n$new_full_ver") || echo_array+=("FAILED") return 0 else # if status was not STOPPED, stop the app prior to updating echo_array+=("\n$app_name") @@ -81,7 +81,7 @@ if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #con 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_array+=("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") || echo_array+=("Failed to update") break elif [[ "$SECONDS" -ge "$timeout" ]]; then echo_array+=("Error: Run Time($SECONDS) has exceeded Timeout($timeout)") @@ -95,12 +95,13 @@ if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #con 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_array+=("FAILED") + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=("Updated\n$old_full_ver\n$new_full_ver") || echo_array+=("FAILED") fi else echo_array+=("\n$app_name\nMajor Release, update manually") return 0 fi +after_update_actions } export -f update_apps From 0a6926c0d6567c6a9b05cdb023f4146e0bc0319a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 17:19:44 -0600 Subject: [PATCH 011/218] nested active check --- functions/update_apps.sh | 55 +++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 503e7afc..ec211d87 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -114,36 +114,45 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then do (( count++ )) 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") - break - elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then - if [[ $rollback == "true" ]]; then - if [[ "$failed" != "true" ]]; then - 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 - echo "$app_name,$new_full_ver" >> failed.txt - break - elif [[ "$failed" == "true" ]]; then - 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 - fi - else - echo_array+=("Error: Run Time($SECONDS) has exceeded Timeout($timeout)") + if [[ "$status" == "ACTIVE" ]]; then + if [[ "$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") break + else + [[ "$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. fi 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. - 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. + elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then + if [[ $rollback == "true" ]]; then + if [[ "$failed" != "true" ]]; then + echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)") + echo_array+=("If this is a slow starting application, set a higher timeout with -t") + echo_array+=("If this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration") + echo_array+=("Reverting 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 + echo "$app_name,$new_full_ver" >> failed.txt + break + else + echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)") + echo_array+=("The application failed to be ACTIVE even after a rollback") + echo_array+=("Manual intervention is required\nAbandoning") + break + fi + else + echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)") + echo_array+=("If this is a slow starting application, set a higher timeout with -t") + echo_array+=("If this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration") + break + fi else [[ "$verbose" == "true" ]] && echo_array+=("Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE") sleep 15 From 1ad4690a2a9c875236d5d44ab07b1fd49323595b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 17:31:21 -0600 Subject: [PATCH 012/218] changed some error messages --- functions/update_apps.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index ec211d87..421576e4 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -74,7 +74,8 @@ if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #con 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..") - midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && SECONDS=0 || echo_array+=("FAILED") + midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null || echo_array+=("Error: Failed to stop $app_name") + SECONDS=0 while [[ "$status" != "STOPPED" ]] do status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') @@ -117,7 +118,8 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then if [[ "$status" == "ACTIVE" ]]; then if [[ "$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") + midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null || { echo_array+=("Error: Failed to stop $app_name") ; break ; } + echo_array+=("Stopped") break else [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 15 && continue #if reports active on FIRST time through loop, double check @@ -130,15 +132,15 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then [[ "$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. - elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then + elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then if [[ $rollback == "true" ]]; then if [[ "$failed" != "true" ]]; then echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)") echo_array+=("If this is a slow starting application, set a higher timeout with -t") echo_array+=("If this applicaion is always DEPLOYING, you can disable all probes under the Healthcheck Probes Liveness section in the edit configuration") echo_array+=("Reverting 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 + midclt call chart.release.rollback "$app_name" "{\"item_version\": \"$rollback_version\"}" &> /dev/null || { echo_array+=("Error: Failed to rollback $app_name") ; break ; } + [[ "$startstatus" == "STOPPED" ]] && failed="true" && after_update_actions #run back after_update_actions function if the app was stopped prior to update echo "$app_name,$new_full_ver" >> failed.txt break else From 3eae25deded291726587a74f68f0a3292f11461f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 18:23:15 -0600 Subject: [PATCH 013/218] test more aggressive loop --- functions/update_apps.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 421576e4..ab30afd2 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -25,9 +25,12 @@ do if [[ "$proc_count" -ge "$update_limit" ]]; then sleep 3 elif [[ $it -lt ${#array[@]} ]]; then - update_apps "${array[$it]}" & - processes+=($!) - ((it++)) + until [[ ${#processes[@]} -ge "$update_limit" || ${#processes[@]} -ge ${#array[@]} ]] + do + update_apps "${array[$it]}" & + processes+=($!) + ((it++)) + done elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 3 else # All processes must be completed, break out of loop From c83354d1a57e742a034fd3e428a6994e9fff98d9 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 18:54:15 -0600 Subject: [PATCH 014/218] update async --- 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 ab30afd2..5df910ab 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -25,10 +25,11 @@ do if [[ "$proc_count" -ge "$update_limit" ]]; then sleep 3 elif [[ $it -lt ${#array[@]} ]]; then - until [[ ${#processes[@]} -ge "$update_limit" || ${#processes[@]} -ge ${#array[@]} ]] + until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] do update_apps "${array[$it]}" & processes+=($!) + ((proc_count++)) ((it++)) done elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish From cad29364a5095f62eb38c9af12607ffa705154d6 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 19:07:33 -0600 Subject: [PATCH 015/218] sleep to avoid call timeout --- functions/update_apps.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 5df910ab..793dc826 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -32,6 +32,7 @@ do ((proc_count++)) ((it++)) done + sleep 3 elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 3 else # All processes must be completed, break out of loop From 17914fada84ab01c12505ef87e930cc5fe63c0fe Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 19:10:02 -0600 Subject: [PATCH 016/218] if gt than 1 sleep --- 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 793dc826..2cfb6526 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -25,14 +25,16 @@ do if [[ "$proc_count" -ge "$update_limit" ]]; then sleep 3 elif [[ $it -lt ${#array[@]} ]]; then + new_updates=0 until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] do update_apps "${array[$it]}" & processes+=($!) ((proc_count++)) ((it++)) + ((new_updates++)) done - sleep 3 + [[ $new_updates -gt 1 ]] && sleep 3 elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 3 else # All processes must be completed, break out of loop From 561b84797a9f9c7a4b891c2726a078f46a69028f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 19:28:52 -0600 Subject: [PATCH 017/218] greater sleep for updates --- 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 2cfb6526..7bf55310 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -34,7 +34,7 @@ do ((it++)) ((new_updates++)) done - [[ $new_updates -gt 1 ]] && sleep 3 + [[ $new_updates -gt 1 ]] && sleep 6 elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 3 else # All processes must be completed, break out of loop From 33a77e0687087788f689f72bcae0543a1cee0597 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 19:32:14 -0600 Subject: [PATCH 018/218] assigning array # to string is off? --- functions/update_apps.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 7bf55310..96ff50ed 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -9,13 +9,12 @@ 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" - +proc_count=0 it=0 while true do 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[@]}" do From 033db8d4a56e53f05b09599566ecfb37a51fd46d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 19:52:08 -0600 Subject: [PATCH 019/218] return array append --- functions/update_apps.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 96ff50ed..42d8a3c8 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -11,10 +11,12 @@ echo "Asynchronous Updates: $update_limit" proc_count=0 it=0 +ttl=0 while true do 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[@]}" do @@ -25,15 +27,21 @@ do sleep 3 elif [[ $it -lt ${#array[@]} ]]; then new_updates=0 - until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] + until [[ "$proc_count" -eq "$update_limit" || $it -eq ${#array[@]} ]] do update_apps "${array[$it]}" & processes+=($!) - ((proc_count++)) ((it++)) ((new_updates++)) done - [[ $new_updates -gt 1 ]] && sleep 6 + ((ttl++)) + if [[ $ttl -eq 1 ]]; then + sleep 15 + elif [[ $new_updates -gt 1 ]]; then + sleep 6 + else + sleep 3 + fi elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 3 else # All processes must be completed, break out of loop From 4faf03d1a00b7e1349750db60385d802b7d74920 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 19:58:19 -0600 Subject: [PATCH 020/218] ge instead of eq --- 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 42d8a3c8..6c56b332 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -27,7 +27,7 @@ do sleep 3 elif [[ $it -lt ${#array[@]} ]]; then new_updates=0 - until [[ "$proc_count" -eq "$update_limit" || $it -eq ${#array[@]} ]] + until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] do update_apps "${array[$it]}" & processes+=($!) From 0fefd885e07d31d65687617f96c3030cd8c61a0d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 20:02:36 -0600 Subject: [PATCH 021/218] wow --- functions/update_apps.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 6c56b332..2e1394d5 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -33,6 +33,7 @@ do processes+=($!) ((it++)) ((new_updates++)) + ((proc_count++)) done ((ttl++)) if [[ $ttl -eq 1 ]]; then From 1d9ca34227057b36abd575c4a0e25ba825c67171 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 20:08:57 -0600 Subject: [PATCH 022/218] raise sleep globally --- functions/update_apps.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 2e1394d5..c9773bbb 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -38,13 +38,13 @@ do ((ttl++)) if [[ $ttl -eq 1 ]]; then sleep 15 - elif [[ $new_updates -gt 1 ]]; then - sleep 6 + # elif [[ $new_updates -gt 1 ]]; then + # sleep 15 else - sleep 3 + sleep 10 fi elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish - sleep 3 + sleep 10 else # All processes must be completed, break out of loop break fi @@ -104,7 +104,7 @@ if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #con break elif [[ "$status" != "STOPPED" ]]; then [[ "$verbose" == "true" ]] && echo_array+=("Waiting $((timeout-SECONDS)) more seconds for $app_name to be STOPPED") - sleep 10 + sleep 15 fi done fi From 65d32d2155bcf70532310d4385448557bb46fe7d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 20:13:44 -0600 Subject: [PATCH 023/218] forgot a sleep timer --- 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 c9773bbb..bb778075 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -24,7 +24,7 @@ do ((count++)) done if [[ "$proc_count" -ge "$update_limit" ]]; then - sleep 3 + sleep 10 elif [[ $it -lt ${#array[@]} ]]; then new_updates=0 until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] From 3cb21aa86ad7158fe50e73d85052fdfbfc473165 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 20:14:06 -0600 Subject: [PATCH 024/218] +5 to first sleep --- 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 bb778075..50288dde 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -37,7 +37,7 @@ do done ((ttl++)) if [[ $ttl -eq 1 ]]; then - sleep 15 + sleep 20 # elif [[ $new_updates -gt 1 ]]; then # sleep 15 else From fc022a13c5dd8f182175be4869c04eedb9552331 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 20:26:17 -0600 Subject: [PATCH 025/218] remove commentedout --- functions/update_apps.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 50288dde..2dfd897c 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -38,8 +38,6 @@ do ((ttl++)) if [[ $ttl -eq 1 ]]; then sleep 20 - # elif [[ $new_updates -gt 1 ]]; then - # sleep 15 else sleep 10 fi From d448916d5bf1fc6df27ce1fec2b523024e443535 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 20:27:44 -0600 Subject: [PATCH 026/218] reasigns to 0, un-needed --- 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 2dfd897c..504a76f7 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -9,7 +9,7 @@ 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" -proc_count=0 + it=0 ttl=0 while true From e496fc4c14f081149d542e94e10b67b9703c669d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 20:29:06 -0600 Subject: [PATCH 027/218] removed variable --- functions/update_apps.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 504a76f7..afaf1bd6 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -26,13 +26,11 @@ do if [[ "$proc_count" -ge "$update_limit" ]]; then sleep 10 elif [[ $it -lt ${#array[@]} ]]; then - new_updates=0 until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] do update_apps "${array[$it]}" & processes+=($!) ((it++)) - ((new_updates++)) ((proc_count++)) done ((ttl++)) From 8a5237960992032a15271383e77fd02fda1f5817 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 20:29:57 -0600 Subject: [PATCH 028/218] test sleep time in until update --- functions/update_apps.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index afaf1bd6..f6e57e48 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -29,6 +29,7 @@ do until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] do update_apps "${array[$it]}" & + sleep 0.5 processes+=($!) ((it++)) ((proc_count++)) From a3d75393b2f511a9791dbf469d5bd5d61be4bf15 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 20:30:33 -0600 Subject: [PATCH 029/218] raise sleep to 1 --- 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 f6e57e48..cb41a046 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -29,7 +29,7 @@ do until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] do update_apps "${array[$it]}" & - sleep 0.5 + sleep 1 processes+=($!) ((it++)) ((proc_count++)) From e5e309ecaf72ffbec8ff9dafb25119713740a3cf Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 20:37:08 -0600 Subject: [PATCH 030/218] try 2 for sleep --- 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 cb41a046..ceedeaed 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -29,7 +29,7 @@ do until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] do update_apps "${array[$it]}" & - sleep 1 + sleep 2 processes+=($!) ((it++)) ((proc_count++)) From 2d39df3601d483adf42145e6736563806ba4378b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 21:05:01 -0600 Subject: [PATCH 031/218] racing original --- functions/update_apps.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index ceedeaed..f7ca7045 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -24,12 +24,12 @@ do ((count++)) done if [[ "$proc_count" -ge "$update_limit" ]]; then - sleep 10 + sleep 6 elif [[ $it -lt ${#array[@]} ]]; then until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] do update_apps "${array[$it]}" & - sleep 2 + sleep 1 processes+=($!) ((it++)) ((proc_count++)) @@ -38,10 +38,10 @@ do if [[ $ttl -eq 1 ]]; then sleep 20 else - sleep 10 + sleep 6 fi elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish - sleep 10 + sleep 6 else # All processes must be completed, break out of loop break fi From fdcf899d56e75dd89ad19aa229fded4d0042ae64 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 21:16:17 -0600 Subject: [PATCH 032/218] test sleep after updates instead --- functions/update_apps.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index f7ca7045..85d04f47 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -29,17 +29,17 @@ do until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] do update_apps "${array[$it]}" & - sleep 1 + sleep 4 processes+=($!) ((it++)) ((proc_count++)) done ((ttl++)) - if [[ $ttl -eq 1 ]]; then - sleep 20 - else - sleep 6 - fi + # if [[ $ttl -eq 1 ]]; then + # sleep 20 + # else + # sleep 6 + # fi elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 6 else # All processes must be completed, break out of loop From 0323ba526e6fa6f56e7820162263aef197a2bb15 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 21:23:50 -0600 Subject: [PATCH 033/218] test sleep 3/4 --- 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 85d04f47..ffde4255 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -9,7 +9,7 @@ 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" - +# previous 20% 2 min 9 seconds it=0 ttl=0 while true @@ -29,7 +29,7 @@ do until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] do update_apps "${array[$it]}" & - sleep 4 + sleep 3 processes+=($!) ((it++)) ((proc_count++)) From 59bd4c18bd751b0c147de26661a558a4a0cdd8f7 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 21:32:23 -0600 Subject: [PATCH 034/218] new race test --- functions/update_apps.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index ffde4255..e7273a25 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -29,17 +29,17 @@ do until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] do update_apps "${array[$it]}" & - sleep 3 + sleep 1 processes+=($!) ((it++)) ((proc_count++)) done ((ttl++)) - # if [[ $ttl -eq 1 ]]; then - # sleep 20 - # else - # sleep 6 - # fi + if [[ $ttl -eq 1 ]]; then + sleep 20 + else + sleep 6 + fi elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 6 else # All processes must be completed, break out of loop From 382f6d2f6adcf0a74ac6e02c71183f008096d843 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 21:39:54 -0600 Subject: [PATCH 035/218] revert to fastest --- functions/update_apps.sh | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index e7273a25..91390eb0 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -29,17 +29,12 @@ do until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] do update_apps "${array[$it]}" & - sleep 1 + sleep 4 processes+=($!) ((it++)) ((proc_count++)) done ((ttl++)) - if [[ $ttl -eq 1 ]]; then - sleep 20 - else - sleep 6 - fi elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 6 else # All processes must be completed, break out of loop From c52e1e86f930c1ba6f0bddc39904f880580668b4 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 21:46:37 -0600 Subject: [PATCH 036/218] test --- functions/update_apps.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 91390eb0..470c342a 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -29,12 +29,16 @@ do until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] do update_apps "${array[$it]}" & - sleep 4 processes+=($!) ((it++)) ((proc_count++)) done ((ttl++)) + if [[ $ttl -eq 1 ]]; then + sleep 15 + else + sleep 6 + fi elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 6 else # All processes must be completed, break out of loop From b1d7471eee7f046eeed6c0d562a5286ee76c1d32 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 21:56:26 -0600 Subject: [PATCH 037/218] test_rearrange --- functions/update_apps.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 470c342a..1dd6508d 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -9,6 +9,26 @@ 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" +#rearange array +for i in ${array[$@]} +do + if printf '%s\0' "${ignore[@]}" | grep -iFxqz "$i" ; then + new_array+=("$i") + elif grep -qs "^$i," failed.txt ; then + new_array+=("$i") + fi +done + +for i in ${array[$@]} +do + printf '%s\0' "${new_array[@]}" | grep -iFxqz "$i" || new_array+=("$i") +done + +for i in ${new_array[$@]} +do + echo "$i" +done + # previous 20% 2 min 9 seconds it=0 ttl=0 From 116492cb92401a4ba883b995751366c78adcb7b4 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 22:00:18 -0600 Subject: [PATCH 038/218] 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 1dd6508d..d32bf7da 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -12,7 +12,8 @@ echo "Asynchronous Updates: $update_limit" #rearange array for i in ${array[$@]} do - if printf '%s\0' "${ignore[@]}" | grep -iFxqz "$i" ; then + in=$(awk -F ',' '{print $1}') + if printf '%s\0' "${ignore[@]}" | grep -iFxqz "$in" ; then new_array+=("$i") elif grep -qs "^$i," failed.txt ; then new_array+=("$i") @@ -21,7 +22,8 @@ done for i in ${array[$@]} do - printf '%s\0' "${new_array[@]}" | grep -iFxqz "$i" || new_array+=("$i") + in=$(awk -F ',' '{print $1}') + printf '%s\0' "${new_array[@]}" | grep -iFxqz "$in" || new_array+=("$i") done for i in ${new_array[$@]} From 17fa578eb4f5931362f02472f353930e4bac7480 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 4 Aug 2022 22:03:25 -0600 Subject: [PATCH 039/218] test --- functions/update_apps.sh | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index d32bf7da..470c342a 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -9,28 +9,6 @@ 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" -#rearange array -for i in ${array[$@]} -do - in=$(awk -F ',' '{print $1}') - if printf '%s\0' "${ignore[@]}" | grep -iFxqz "$in" ; then - new_array+=("$i") - elif grep -qs "^$i," failed.txt ; then - new_array+=("$i") - fi -done - -for i in ${array[$@]} -do - in=$(awk -F ',' '{print $1}') - printf '%s\0' "${new_array[@]}" | grep -iFxqz "$in" || new_array+=("$i") -done - -for i in ${new_array[$@]} -do - echo "$i" -done - # previous 20% 2 min 9 seconds it=0 ttl=0 From edb437b7181c833a56b98b0198e007b0e92ec0b5 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 18:56:56 -0600 Subject: [PATCH 040/218] add branch variable --- functions/self_update.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index 98a3e19e..b7b3e884 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -2,10 +2,11 @@ args=("$@") self_update() { +branch="ignore-file" git fetch &> /dev/null echo "🅂 🄴 🄻 🄵" echo "🅄 🄿 🄳 🄰 🅃 🄴" -if git diff --name-only origin/main | grep -qs ".sh" ; then +if git diff --name-only origin/$branch | grep -qs ".sh" ; then echo "Found a new version of HeavyScript, updating myself..." git reset --hard -q git pull --force -q From 6bafce8181f488252b67690a8bce2cdebdda7a7b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 20:12:09 -0600 Subject: [PATCH 041/218] cmd to container initial --- functions/menu.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/functions/menu.sh b/functions/menu.sh index 22e4ac76..6d9063c9 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -11,6 +11,7 @@ echo "5) Restore a Backup" echo "6) Delete a Backup" echo "7) Update HeavyScript" echo "8) Update Applications" +echo "9) Command to Container" echo echo "0) Exit" read -rt 120 -p "Please select an option by number: " selection @@ -212,6 +213,40 @@ case $selection in esac done ;; + + 9) + title + clear -x + app_name=$(k3s kubectl get pods -A | awk '{print $1}' | sort -u | grep -v "system" | sed '1d' | sed 's/^[^-]*-//' | nl -s ") " | column -t) + echo "$app_name" + echo + echo "0) Exit" + [[ $selection == 0 ]] && echo "Exiting.." && exit + read -rt 120 -p "Please type a number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } + app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') + search=$(k3s crictl ps -a -s running) + mapfile -t pod_id < <(echo "$search" | grep "$app_name" | awk '{print $9}') + + containers=$( + for pod in "${pod_id[@]}" + do + echo "$search" | grep "$pod" | awk '{print $7}' + done | nl -s ") " | column -t) + clear -x + title + echo "$containers" + echo + echo "0) Exit" + read -rt 120 -p "Choose a container by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } + [[ $selection == 0 ]] && echo "Exiting.." && exit + + container=$(echo "$containers" | grep ^"$selection)" | awk '{print $2}') + container_id=$(echo "$search" | grep "$container" | awk '{print $1}') + + read -rt 120 -p "What command would you like to submit to $app_name on $container?: " command || { echo -e "\nFailed to make a selection in time" ; exit; } + k3s crictl exec "$container_id" $command + container=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') + ;; *) echo "\"$selection\" was not an option, please try agian" && sleep 3 && menu ;; From 887e69cb36caac435935acfb81adf0657adbea0e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 20:28:36 -0600 Subject: [PATCH 042/218] while loops to cmd to cnter --- functions/menu.sh | 63 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 46 insertions(+), 17 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 6d9063c9..b4cd224b 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -215,14 +215,26 @@ case $selection in ;; 9) - title - clear -x app_name=$(k3s kubectl get pods -A | awk '{print $1}' | sort -u | grep -v "system" | sed '1d' | sed 's/^[^-]*-//' | nl -s ") " | column -t) - echo "$app_name" - echo - echo "0) Exit" - [[ $selection == 0 ]] && echo "Exiting.." && exit - read -rt 120 -p "Please type a number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } + while true + do + clear -x + title + echo "$app_name" + echo + echo "0) Exit" + read -rt 120 -p "Please type a number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } + if [[ $selection == 0 ]]; then + echo "Exitting.." + exit + elif ! echo -e "$app_name" | grep -qs ^"$selection)" ; then + echo "Error: \"$selection\" was not an option.. Try again" + sleep 3 + continue + else + break + fi + done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') search=$(k3s crictl ps -a -s running) mapfile -t pod_id < <(echo "$search" | grep "$app_name" | awk '{print $9}') @@ -232,18 +244,35 @@ case $selection in do echo "$search" | grep "$pod" | awk '{print $7}' done | nl -s ") " | column -t) - clear -x - title - echo "$containers" - echo - echo "0) Exit" - read -rt 120 -p "Choose a container by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } - [[ $selection == 0 ]] && echo "Exiting.." && exit - + while true + do + clear -x + title + echo "$containers" + echo + echo "0) Exit" + read -rt 120 -p "Choose a container by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } + if [[ $selection == 0 ]]; then + echo "Exitting.." + exit + elif ! echo -e "$containers" | grep -qs ^"$selection)" ; then + echo "Error: \"$selection\" was not an option.. Try again" + sleep 3 + continue + else + break + fi + done container=$(echo "$containers" | grep ^"$selection)" | awk '{print $2}') container_id=$(echo "$search" | grep "$container" | awk '{print $1}') - - read -rt 120 -p "What command would you like to submit to $app_name on $container?: " command || { echo -e "\nFailed to make a selection in time" ; exit; } + clear -x + title + echo "App Name: $app_name" + echo "Container $container" + echo + echo "0) Exit" + read -rt 120 -p "What command would you like to run?: " command || { echo -e "\nFailed to make a selection in time" ; exit; } + [[ $command == 0 ]] && echo "Exitting.." && exit k3s crictl exec "$container_id" $command container=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') ;; From 6a1c216da3c49e78a64c42859d70398f5a74dbd4 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 20:29:58 -0600 Subject: [PATCH 043/218] Spelling --- functions/menu.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index b4cd224b..a59df8c9 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -225,7 +225,7 @@ case $selection in echo "0) Exit" read -rt 120 -p "Please type a number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } if [[ $selection == 0 ]]; then - echo "Exitting.." + echo "Exiting.." exit elif ! echo -e "$app_name" | grep -qs ^"$selection)" ; then echo "Error: \"$selection\" was not an option.. Try again" @@ -253,7 +253,7 @@ case $selection in echo "0) Exit" read -rt 120 -p "Choose a container by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } if [[ $selection == 0 ]]; then - echo "Exitting.." + echo "Exiting.." exit elif ! echo -e "$containers" | grep -qs ^"$selection)" ; then echo "Error: \"$selection\" was not an option.. Try again" @@ -272,7 +272,7 @@ case $selection in echo echo "0) Exit" read -rt 120 -p "What command would you like to run?: " command || { echo -e "\nFailed to make a selection in time" ; exit; } - [[ $command == 0 ]] && echo "Exitting.." && exit + [[ $command == 0 ]] && echo "Exiting.." && exit k3s crictl exec "$container_id" $command container=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') ;; From b6a796eb5bed41126ca1b2c78356e70d47fe40f4 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 20:36:53 -0600 Subject: [PATCH 044/218] grep appname --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index a59df8c9..e05353bc 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -237,7 +237,7 @@ case $selection in done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') search=$(k3s crictl ps -a -s running) - mapfile -t pod_id < <(echo "$search" | grep "$app_name" | awk '{print $9}') + mapfile -t pod_id < <(echo "$search" | grep " $app_name " | awk '{print $9}') containers=$( for pod in "${pod_id[@]}" From b845b650c5068098db3fc8f31e66cba7ce1900ed Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 20:41:53 -0600 Subject: [PATCH 045/218] search regex --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index e05353bc..ddf13880 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -237,7 +237,7 @@ case $selection in done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') search=$(k3s crictl ps -a -s running) - mapfile -t pod_id < <(echo "$search" | grep " $app_name " | awk '{print $9}') + mapfile -t pod_id < <(echo "$search" | grep -E " $app_name(-)?" | awk '{print $9}') containers=$( for pod in "${pod_id[@]}" From a1ab1ffb8b89fff34507502f8d5bf94aebed3068 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 20:43:07 -0600 Subject: [PATCH 046/218] space or hyphen --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index ddf13880..88df690d 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -237,7 +237,7 @@ case $selection in done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') search=$(k3s crictl ps -a -s running) - mapfile -t pod_id < <(echo "$search" | grep -E " $app_name(-)?" | awk '{print $9}') + mapfile -t pod_id < <(echo "$search" | grep -E " $app_name( |-)?" | awk '{print $9}') containers=$( for pod in "${pod_id[@]}" From c10ea958f30a9f93af138d1371f1207a08649210 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 20:46:06 -0600 Subject: [PATCH 047/218] test new regex --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index 88df690d..704f9a46 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -237,7 +237,7 @@ case $selection in done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') search=$(k3s crictl ps -a -s running) - mapfile -t pod_id < <(echo "$search" | grep -E " $app_name( |-)?" | awk '{print $9}') + mapfile -t pod_id < <(echo "$search" | grep -E " $app_name( *|-?)" | awk '{print $9}') containers=$( for pod in "${pod_id[@]}" From 65eaf1682d89020cea5a71cbe3666275d47bd3ac Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 20:52:35 -0600 Subject: [PATCH 048/218] test regex --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index 704f9a46..14ad312a 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -237,7 +237,7 @@ case $selection in done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') search=$(k3s crictl ps -a -s running) - mapfile -t pod_id < <(echo "$search" | grep -E " $app_name( *|-?)" | awk '{print $9}') + mapfile -t pod_id < <(echo "$search" | grep -E " $app_name(-|[[:alnum:]])*[[:space:]]" | awk '{print $9}') containers=$( for pod in "${pod_id[@]}" From df34a87089917a1e8e2c271275d2fbb5816ef25a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 20:53:29 -0600 Subject: [PATCH 049/218] test --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index 14ad312a..a79fa21a 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -237,7 +237,7 @@ case $selection in done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') search=$(k3s crictl ps -a -s running) - mapfile -t pod_id < <(echo "$search" | grep -E " $app_name(-|[[:alnum:]])*[[:space:]]" | awk '{print $9}') + mapfile -t pod_id < <(echo "$search" | grep -E " $app_name(-)?[[:alnum:]]*[[:space:]]" | awk '{print $9}') containers=$( for pod in "${pod_id[@]}" From 76f54786ba114099cc2a957d17b3343768fc5046 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 20:56:52 -0600 Subject: [PATCH 050/218] test again --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index a79fa21a..d0f595df 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -237,7 +237,7 @@ case $selection in done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') search=$(k3s crictl ps -a -s running) - mapfile -t pod_id < <(echo "$search" | grep -E " $app_name(-)?[[:alnum:]]*[[:space:]]" | awk '{print $9}') + mapfile -t pod_id < <(echo "$search" | grep -E " $app_name( |-[[:alnum:]]*[[:space:]])" | awk '{print $9}') containers=$( for pod in "${pod_id[@]}" From bb453ec320ed8f9a7a6260281482f794dd212c56 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 21:00:04 -0600 Subject: [PATCH 051/218] final regex edit for now --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index d0f595df..a0f16986 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -237,7 +237,7 @@ case $selection in done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') search=$(k3s crictl ps -a -s running) - mapfile -t pod_id < <(echo "$search" | grep -E " $app_name( |-[[:alnum:]]*[[:space:]])" | awk '{print $9}') + mapfile -t pod_id < <(echo "$search" | grep -E " $app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $9}') containers=$( for pod in "${pod_id[@]}" From 99ad0cd1fe2e3aab717b40c4f894dead860ba3bd Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 21:51:56 -0600 Subject: [PATCH 052/218] test --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index a0f16986..53ec177c 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -264,7 +264,7 @@ case $selection in fi done container=$(echo "$containers" | grep ^"$selection)" | awk '{print $2}') - container_id=$(echo "$search" | grep "$container" | awk '{print $1}') + container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') clear -x title echo "App Name: $app_name" From 08e98759783c5d3d3cff356330c203179c924595 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 21:58:54 -0600 Subject: [PATCH 053/218] exit message on no pods --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index 53ec177c..0ae95ff3 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -238,7 +238,7 @@ case $selection in app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') search=$(k3s crictl ps -a -s running) mapfile -t pod_id < <(echo "$search" | grep -E " $app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $9}') - + [[ "${#pod_id[@]}" == 0 ]] && echo "Are you sure the application in running?" && exit containers=$( for pod in "${pod_id[@]}" do From 835528a8c15fb6504d3830a98dbbf5f6ac8e5ad2 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 21:59:58 -0600 Subject: [PATCH 054/218] better message --- functions/menu.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/menu.sh b/functions/menu.sh index 0ae95ff3..077fd917 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -238,7 +238,7 @@ case $selection in app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') search=$(k3s crictl ps -a -s running) mapfile -t pod_id < <(echo "$search" | grep -E " $app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $9}') - [[ "${#pod_id[@]}" == 0 ]] && echo "Are you sure the application in running?" && exit + [[ "${#pod_id[@]}" == 0 ]] && echo -e "No containers available\nAre you sure the application in running?" && exit containers=$( for pod in "${pod_id[@]}" do From bd2e381bb8c5da6c330e873cf152dd2f40e41d78 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 22:17:15 -0600 Subject: [PATCH 055/218] test new call --- functions/cmd_to_container.sh | 66 +++++++++ functions/menu.sh | 248 ++-------------------------------- functions/script_create.sh | 174 ++++++++++++++++++++++++ heavy_script.sh | 11 +- 4 files changed, 256 insertions(+), 243 deletions(-) create mode 100644 functions/cmd_to_container.sh create mode 100644 functions/script_create.sh diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh new file mode 100644 index 00000000..00d2a0b4 --- /dev/null +++ b/functions/cmd_to_container.sh @@ -0,0 +1,66 @@ +#!/bin/bash + + +cmd_to_container(){ + app_name=$(k3s kubectl get pods -A | awk '{print $1}' | sort -u | grep -v "system" | sed '1d' | sed 's/^[^-]*-//' | nl -s ") " | column -t) + while true + do + clear -x + title + echo "$app_name" + echo + echo "0) Exit" + read -rt 120 -p "Please type a number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } + if [[ $selection == 0 ]]; then + echo "Exiting.." + exit + elif ! echo -e "$app_name" | grep -qs ^"$selection)" ; then + echo "Error: \"$selection\" was not an option.. Try again" + sleep 3 + continue + else + break + fi + done + app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') + search=$(k3s crictl ps -a -s running) + mapfile -t pod_id < <(echo "$search" | grep -E " $app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $9}') + [[ "${#pod_id[@]}" == 0 ]] && echo -e "No containers available\nAre you sure the application in running?" && exit + containers=$( + for pod in "${pod_id[@]}" + do + echo "$search" | grep "$pod" | awk '{print $7}' + done | nl -s ") " | column -t) + while true + do + clear -x + title + echo "$containers" + echo + echo "0) Exit" + read -rt 120 -p "Choose a container by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } + if [[ $selection == 0 ]]; then + echo "Exiting.." + exit + elif ! echo -e "$containers" | grep -qs ^"$selection)" ; then + echo "Error: \"$selection\" was not an option.. Try again" + sleep 3 + continue + else + break + fi + done + container=$(echo "$containers" | grep ^"$selection)" | awk '{print $2}') + container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') + clear -x + title + echo "App Name: $app_name" + echo "Container: $container" + echo + echo "0) Exit" + read -rt 120 -p "What command would you like to run?: " command || { echo -e "\nFailed to make a selection in time" ; exit; } + [[ $command == 0 ]] && echo "Exiting.." && exit + k3s crictl exec "$container_id" $command + container=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') +} +export -f cmd_to_container \ No newline at end of file diff --git a/functions/menu.sh b/functions/menu.sh index 077fd917..9ac93713 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -21,260 +21,38 @@ case $selection in exit ;; 1) - help="true" + help + exit ;; 2) - dns="true" + dns + exit ;; 3) - mount="true" + mount + exit ;; 4) read -rt 120 -p "What is the maximun number of backups you would like?: " number_of_backups || echo "Failed to make a selection" backup="true" ;; 5) - restore="true" + restore + exit ;; 6) - deleteBackup="true" + deleteBackup + exit ;; 7) - self_update="true" + self_update ;; 8) - 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 120 -p "Type the Number or Flag: " current_selection || { echo -e "\nFailed to make a selection in time" ; exit; } - case $current_selection in - 0 | [Ee][Xx][Ii][Tt]) - echo "Exiting.." - exit - ;; - 1 | -U) - while true - do - echo -e "\nHow many applications do you want updating at the same time?" - read -rt 120 -p "Please type an integer greater than 0: " up_async || { echo -e "\nFailed to make a selection in time" ; exit; } - if [[ $up_async == 0 ]]; then - echo "Error: \"$up_async\" is less than 1" - echo "NOT adding it to the list" - sleep 3 - 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 3 - continue - else - update_selection+=("-U" "$up_async") - break - fi - done - break - ;; - 2 | -u) - while true - do - echo -e "\nHow many applications do you want updating at the same time?" - read -rt 120 -p "Please type an integer greater than 0: " up_async || { echo -e "\nFailed to make a selection in time" ; exit; } - if [[ $up_async == 0 ]]; then - echo "Error: \"$up_async\" is less than 1" - echo "NOT adding it to the list" - sleep 3 - 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 3 - continue - else - update_selection+=("-u" "$up_async") - break - fi - done - break - ;; - *) - echo "$current_selection was not an option, try again" && sleep 3 - continue - ;; - esac - done - while true - do - clear -x - title - echo "Update Options" - echo "--------------" - echo "1) -r | Roll-back applications if they fail to update" - echo "2) -i | Add application to ignore list" - echo "3) -S | Shutdown applications prior to updating" - echo "4) -v | verbose output" - echo "5) -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 - echo "Additional Options" - echo "------------------" - echo "6) -b | Back-up your ix-applications dataset, specify a number after -b" - 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" - 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 || { echo -e "\nFailed to make a selection in time" ; exit; } - case $current_selection in - 0 | [Ee][Xx][Ii][Tt]) - echo "Exiting.." - exit - ;; - 00) - clear -x - echo "Running \"bash heavy_script.sh ${update_selection[*]}\"" - echo - exec bash "$script_name" "${update_selection[@]}" - exit - ;; - 1 | -r) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-r" && echo -e "\"-r\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - update_selection+=("-r") - ;; - 2 | -i) - read -rt 120 -p "What is the name of the application we should ignore?: " up_ignore || { echo -e "\nFailed to make a selection in time" ; exit; } - ! [[ $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 3 && continue - update_selection+=("-i" "$up_ignore") - ;; - 3 | -S) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-S" && echo -e "\"-S\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - update_selection+=("-S") - ;; - 4 | -v) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-v" && echo -e "\"-v\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - update_selection+=("-v") - ;; - 5 | -t) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-t" && echo -e "\"-t\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - echo "What do you want your timeout to be?" - read -rt 120 -p "Please type an integer: " up_timeout || { echo -e "\nFailed to make a selection in time" ; exit; } - ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 3 && continue - update_selection+=("-t" "$up_timeout") - ;; - 6 | -b) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-b" && echo -e "\"-b\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - echo "Up to how many backups should we keep?" - read -rt 120 -p "Please type an integer: " up_backups || { echo -e "\nFailed to make a selection in time" ; exit; } - ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 3 && continue - [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 3 && continue - update_selection+=("-b" "$up_backups") - ;; - 7 | -s) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-s" && echo -e "\"-s\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - update_selection+=("-s") - ;; - 8 | -p) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-p" && echo -e "\"-p\" is already on here, skipping" && sleep 3 && 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 3 && continue #If option is already on there, skip it - update_selection+=("--self-update") - ;; - 99) - count=2 - echo "restarting" - for i in "${update_selection[@]:2}" - do - unset "update_selection[$count]" - echo "$i removed" - ((count++)) - done - sleep 3 - continue - ;; - *) - echo "\"$current_selection\" was not an option, try again" && sleep 3 && continue - ;; - esac - done + script_create ;; 9) - app_name=$(k3s kubectl get pods -A | awk '{print $1}' | sort -u | grep -v "system" | sed '1d' | sed 's/^[^-]*-//' | nl -s ") " | column -t) - while true - do - clear -x - title - echo "$app_name" - echo - echo "0) Exit" - read -rt 120 -p "Please type a number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } - if [[ $selection == 0 ]]; then - echo "Exiting.." - exit - elif ! echo -e "$app_name" | grep -qs ^"$selection)" ; then - echo "Error: \"$selection\" was not an option.. Try again" - sleep 3 - continue - else - break - fi - done - app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') - search=$(k3s crictl ps -a -s running) - mapfile -t pod_id < <(echo "$search" | grep -E " $app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $9}') - [[ "${#pod_id[@]}" == 0 ]] && echo -e "No containers available\nAre you sure the application in running?" && exit - containers=$( - for pod in "${pod_id[@]}" - do - echo "$search" | grep "$pod" | awk '{print $7}' - done | nl -s ") " | column -t) - while true - do - clear -x - title - echo "$containers" - echo - echo "0) Exit" - read -rt 120 -p "Choose a container by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } - if [[ $selection == 0 ]]; then - echo "Exiting.." - exit - elif ! echo -e "$containers" | grep -qs ^"$selection)" ; then - echo "Error: \"$selection\" was not an option.. Try again" - sleep 3 - continue - else - break - fi - done - container=$(echo "$containers" | grep ^"$selection)" | awk '{print $2}') - container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') - clear -x - title - echo "App Name: $app_name" - echo "Container $container" - echo - echo "0) Exit" - read -rt 120 -p "What command would you like to run?: " command || { echo -e "\nFailed to make a selection in time" ; exit; } - [[ $command == 0 ]] && echo "Exiting.." && exit - k3s crictl exec "$container_id" $command - container=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') + cmd_to_container ;; *) echo "\"$selection\" was not an option, please try agian" && sleep 3 && menu diff --git a/functions/script_create.sh b/functions/script_create.sh new file mode 100644 index 00000000..78b4d287 --- /dev/null +++ b/functions/script_create.sh @@ -0,0 +1,174 @@ +#!/bin/bash + +script_create(){ + 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 120 -p "Type the Number or Flag: " current_selection || { echo -e "\nFailed to make a selection in time" ; exit; } + case $current_selection in + 0 | [Ee][Xx][Ii][Tt]) + echo "Exiting.." + exit + ;; + 1 | -U) + while true + do + echo -e "\nHow many applications do you want updating at the same time?" + read -rt 120 -p "Please type an integer greater than 0: " up_async || { echo -e "\nFailed to make a selection in time" ; exit; } + if [[ $up_async == 0 ]]; then + echo "Error: \"$up_async\" is less than 1" + echo "NOT adding it to the list" + sleep 3 + 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 3 + continue + else + update_selection+=("-U" "$up_async") + break + fi + done + break + ;; + 2 | -u) + while true + do + echo -e "\nHow many applications do you want updating at the same time?" + read -rt 120 -p "Please type an integer greater than 0: " up_async || { echo -e "\nFailed to make a selection in time" ; exit; } + if [[ $up_async == 0 ]]; then + echo "Error: \"$up_async\" is less than 1" + echo "NOT adding it to the list" + sleep 3 + 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 3 + continue + else + update_selection+=("-u" "$up_async") + break + fi + done + break + ;; + *) + echo "$current_selection was not an option, try again" && sleep 3 + continue + ;; + esac + done + while true + do + clear -x + title + echo "Update Options" + echo "--------------" + echo "1) -r | Roll-back applications if they fail to update" + echo "2) -i | Add application to ignore list" + echo "3) -S | Shutdown applications prior to updating" + echo "4) -v | verbose output" + echo "5) -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 + echo "Additional Options" + echo "------------------" + echo "6) -b | Back-up your ix-applications dataset, specify a number after -b" + 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" + 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 || { echo -e "\nFailed to make a selection in time" ; exit; } + case $current_selection in + 0 | [Ee][Xx][Ii][Tt]) + echo "Exiting.." + exit + ;; + 00) + clear -x + echo "Running \"bash heavy_script.sh ${update_selection[*]}\"" + echo + exec bash "$script_name" "${update_selection[@]}" + exit + ;; + 1 | -r) + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-r" && echo -e "\"-r\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it + update_selection+=("-r") + ;; + 2 | -i) + read -rt 120 -p "What is the name of the application we should ignore?: " up_ignore || { echo -e "\nFailed to make a selection in time" ; exit; } + ! [[ $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 3 && continue + update_selection+=("-i" "$up_ignore") + ;; + 3 | -S) + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-S" && echo -e "\"-S\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it + update_selection+=("-S") + ;; + 4 | -v) + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-v" && echo -e "\"-v\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it + update_selection+=("-v") + ;; + 5 | -t) + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-t" && echo -e "\"-t\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it + echo "What do you want your timeout to be?" + read -rt 120 -p "Please type an integer: " up_timeout || { echo -e "\nFailed to make a selection in time" ; exit; } + ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 3 && continue + update_selection+=("-t" "$up_timeout") + ;; + 6 | -b) + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-b" && echo -e "\"-b\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it + echo "Up to how many backups should we keep?" + read -rt 120 -p "Please type an integer: " up_backups || { echo -e "\nFailed to make a selection in time" ; exit; } + ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 3 && continue + [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 3 && continue + update_selection+=("-b" "$up_backups") + ;; + 7 | -s) + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-s" && echo -e "\"-s\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it + update_selection+=("-s") + ;; + 8 | -p) + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-p" && echo -e "\"-p\" is already on here, skipping" && sleep 3 && 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 3 && continue #If option is already on there, skip it + update_selection+=("--self-update") + ;; + 99) + count=2 + echo "restarting" + for i in "${update_selection[@]:2}" + do + unset "update_selection[$count]" + echo "$i removed" + ((count++)) + done + sleep 3 + continue + ;; + *) + echo "\"$current_selection\" was not an option, try again" && sleep 3 && continue + ;; + esac + done +} +export -f script_create \ No newline at end of file diff --git a/heavy_script.sh b/heavy_script.sh index efecf333..3b970e9f 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -8,20 +8,15 @@ script_name="heavy_script.sh" cd "$script_path" || { echo "Error: Failed to change to script directory" ; exit ; } -# 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 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 +source functions/cmd_to_container.sh +source functions/script_create.sh @@ -139,8 +134,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 -[[ "$help" == "true" ]] && help [[ "$self_update" == "true" ]] && self_update +[[ "$help" == "true" ]] && help [[ "$deleteBackup" == "true" ]] && deleteBackup && exit [[ "$dns" == "true" ]] && dns && exit [[ "$restore" == "true" ]] && restore && exit From f3e66e9327e4686fe40ce49c4ce6c8905dcdd116 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 22:18:37 -0600 Subject: [PATCH 056/218] remove exits --- functions/menu.sh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 9ac93713..79993400 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -22,15 +22,12 @@ case $selection in ;; 1) help - exit ;; 2) dns - exit ;; 3) mount - exit ;; 4) read -rt 120 -p "What is the maximun number of backups you would like?: " number_of_backups || echo "Failed to make a selection" @@ -38,11 +35,9 @@ case $selection in ;; 5) restore - exit ;; 6) deleteBackup - exit ;; 7) self_update From 721dadf09ed59cc5a901e831698aac1c18a0e11b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 22:28:09 -0600 Subject: [PATCH 057/218] remove indents, test sleep timer async --- functions/cmd_to_container.sh | 120 ++++++------ functions/script_create.sh | 334 +++++++++++++++++----------------- functions/update_apps.sh | 13 +- 3 files changed, 234 insertions(+), 233 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 00d2a0b4..8b51cf76 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -2,65 +2,65 @@ cmd_to_container(){ - app_name=$(k3s kubectl get pods -A | awk '{print $1}' | sort -u | grep -v "system" | sed '1d' | sed 's/^[^-]*-//' | nl -s ") " | column -t) - while true - do - clear -x - title - echo "$app_name" - echo - echo "0) Exit" - read -rt 120 -p "Please type a number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } - if [[ $selection == 0 ]]; then - echo "Exiting.." - exit - elif ! echo -e "$app_name" | grep -qs ^"$selection)" ; then - echo "Error: \"$selection\" was not an option.. Try again" - sleep 3 - continue - else - break - fi - done - app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') - search=$(k3s crictl ps -a -s running) - mapfile -t pod_id < <(echo "$search" | grep -E " $app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $9}') - [[ "${#pod_id[@]}" == 0 ]] && echo -e "No containers available\nAre you sure the application in running?" && exit - containers=$( - for pod in "${pod_id[@]}" - do - echo "$search" | grep "$pod" | awk '{print $7}' - done | nl -s ") " | column -t) - while true - do - clear -x - title - echo "$containers" - echo - echo "0) Exit" - read -rt 120 -p "Choose a container by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } - if [[ $selection == 0 ]]; then - echo "Exiting.." - exit - elif ! echo -e "$containers" | grep -qs ^"$selection)" ; then - echo "Error: \"$selection\" was not an option.. Try again" - sleep 3 - continue - else - break - fi - done - container=$(echo "$containers" | grep ^"$selection)" | awk '{print $2}') - container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') - clear -x - title - echo "App Name: $app_name" - echo "Container: $container" - echo - echo "0) Exit" - read -rt 120 -p "What command would you like to run?: " command || { echo -e "\nFailed to make a selection in time" ; exit; } - [[ $command == 0 ]] && echo "Exiting.." && exit - k3s crictl exec "$container_id" $command - container=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') +app_name=$(k3s kubectl get pods -A | awk '{print $1}' | sort -u | grep -v "system" | sed '1d' | sed 's/^[^-]*-//' | nl -s ") " | column -t) +while true +do + clear -x + title + echo "$app_name" + echo + echo "0) Exit" + read -rt 120 -p "Please type a number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } + if [[ $selection == 0 ]]; then + echo "Exiting.." + exit + elif ! echo -e "$app_name" | grep -qs ^"$selection)" ; then + echo "Error: \"$selection\" was not an option.. Try again" + sleep 3 + continue + else + break + fi +done +app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') +search=$(k3s crictl ps -a -s running) +mapfile -t pod_id < <(echo "$search" | grep -E " $app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $9}') +[[ "${#pod_id[@]}" == 0 ]] && echo -e "No containers available\nAre you sure the application in running?" && exit +containers=$( +for pod in "${pod_id[@]}" +do + echo "$search" | grep "$pod" | awk '{print $7}' +done | nl -s ") " | column -t) +while true +do + clear -x + title + echo "$containers" + echo + echo "0) Exit" + read -rt 120 -p "Choose a container by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } + if [[ $selection == 0 ]]; then + echo "Exiting.." + exit + elif ! echo -e "$containers" | grep -qs ^"$selection)" ; then + echo "Error: \"$selection\" was not an option.. Try again" + sleep 3 + continue + else + break + fi +done +container=$(echo "$containers" | grep ^"$selection)" | awk '{print $2}') +container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') +clear -x +title +echo "App Name: $app_name" +echo "Container: $container" +echo +echo "0) Exit" +read -rt 120 -p "What command would you like to run?: " command || { echo -e "\nFailed to make a selection in time" ; exit; } +[[ $command == 0 ]] && echo "Exiting.." && exit +k3s crictl exec "$container_id" $command +container=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') } export -f cmd_to_container \ No newline at end of file diff --git a/functions/script_create.sh b/functions/script_create.sh index 78b4d287..b1448218 100644 --- a/functions/script_create.sh +++ b/functions/script_create.sh @@ -1,174 +1,174 @@ #!/bin/bash script_create(){ - 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 120 -p "Type the Number or Flag: " current_selection || { echo -e "\nFailed to make a selection in time" ; exit; } - case $current_selection in - 0 | [Ee][Xx][Ii][Tt]) - echo "Exiting.." - exit - ;; - 1 | -U) - while true - do - echo -e "\nHow many applications do you want updating at the same time?" - read -rt 120 -p "Please type an integer greater than 0: " up_async || { echo -e "\nFailed to make a selection in time" ; exit; } - if [[ $up_async == 0 ]]; then - echo "Error: \"$up_async\" is less than 1" - echo "NOT adding it to the list" - sleep 3 - 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 3 - continue - else - update_selection+=("-U" "$up_async") - break - fi - done - break - ;; - 2 | -u) - while true - do - echo -e "\nHow many applications do you want updating at the same time?" - read -rt 120 -p "Please type an integer greater than 0: " up_async || { echo -e "\nFailed to make a selection in time" ; exit; } - if [[ $up_async == 0 ]]; then - echo "Error: \"$up_async\" is less than 1" - echo "NOT adding it to the list" - sleep 3 - 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 3 - continue - else - update_selection+=("-u" "$up_async") - break - fi - done - break - ;; - *) - echo "$current_selection was not an option, try again" && sleep 3 - continue - ;; - esac - done - while true - do - clear -x - title - echo "Update Options" - echo "--------------" - echo "1) -r | Roll-back applications if they fail to update" - echo "2) -i | Add application to ignore list" - echo "3) -S | Shutdown applications prior to updating" - echo "4) -v | verbose output" - echo "5) -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 - echo "Additional Options" - echo "------------------" - echo "6) -b | Back-up your ix-applications dataset, specify a number after -b" - 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" - 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 || { echo -e "\nFailed to make a selection in time" ; exit; } - case $current_selection in - 0 | [Ee][Xx][Ii][Tt]) - echo "Exiting.." - exit - ;; - 00) - clear -x - echo "Running \"bash heavy_script.sh ${update_selection[*]}\"" - echo - exec bash "$script_name" "${update_selection[@]}" - exit - ;; - 1 | -r) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-r" && echo -e "\"-r\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - update_selection+=("-r") - ;; - 2 | -i) - read -rt 120 -p "What is the name of the application we should ignore?: " up_ignore || { echo -e "\nFailed to make a selection in time" ; exit; } - ! [[ $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 3 && continue - update_selection+=("-i" "$up_ignore") - ;; - 3 | -S) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-S" && echo -e "\"-S\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - update_selection+=("-S") - ;; - 4 | -v) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-v" && echo -e "\"-v\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - update_selection+=("-v") - ;; - 5 | -t) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-t" && echo -e "\"-t\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - echo "What do you want your timeout to be?" - read -rt 120 -p "Please type an integer: " up_timeout || { echo -e "\nFailed to make a selection in time" ; exit; } - ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 3 && continue - update_selection+=("-t" "$up_timeout") - ;; - 6 | -b) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-b" && echo -e "\"-b\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - echo "Up to how many backups should we keep?" - read -rt 120 -p "Please type an integer: " up_backups || { echo -e "\nFailed to make a selection in time" ; exit; } - ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 3 && continue - [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 3 && continue - update_selection+=("-b" "$up_backups") - ;; - 7 | -s) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-s" && echo -e "\"-s\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it - update_selection+=("-s") - ;; - 8 | -p) - printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-p" && echo -e "\"-p\" is already on here, skipping" && sleep 3 && 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 3 && continue #If option is already on there, skip it - update_selection+=("--self-update") - ;; - 99) - count=2 - echo "restarting" - for i in "${update_selection[@]:2}" - do - unset "update_selection[$count]" - echo "$i removed" - ((count++)) - done +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 120 -p "Type the Number or Flag: " current_selection || { echo -e "\nFailed to make a selection in time" ; exit; } + case $current_selection in + 0 | [Ee][Xx][Ii][Tt]) + echo "Exiting.." + exit + ;; + 1 | -U) + while true + do + echo -e "\nHow many applications do you want updating at the same time?" + read -rt 120 -p "Please type an integer greater than 0: " up_async || { echo -e "\nFailed to make a selection in time" ; exit; } + if [[ $up_async == 0 ]]; then + echo "Error: \"$up_async\" is less than 1" + echo "NOT adding it to the list" sleep 3 continue - ;; - *) - echo "\"$current_selection\" was not an option, try again" && sleep 3 && continue - ;; - esac - done + 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 3 + continue + else + update_selection+=("-U" "$up_async") + break + fi + done + break + ;; + 2 | -u) + while true + do + echo -e "\nHow many applications do you want updating at the same time?" + read -rt 120 -p "Please type an integer greater than 0: " up_async || { echo -e "\nFailed to make a selection in time" ; exit; } + if [[ $up_async == 0 ]]; then + echo "Error: \"$up_async\" is less than 1" + echo "NOT adding it to the list" + sleep 3 + 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 3 + continue + else + update_selection+=("-u" "$up_async") + break + fi + done + break + ;; + *) + echo "$current_selection was not an option, try again" && sleep 3 + continue + ;; + esac +done +while true +do + clear -x + title + echo "Update Options" + echo "--------------" + echo "1) -r | Roll-back applications if they fail to update" + echo "2) -i | Add application to ignore list" + echo "3) -S | Shutdown applications prior to updating" + echo "4) -v | verbose output" + echo "5) -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 + echo "Additional Options" + echo "------------------" + echo "6) -b | Back-up your ix-applications dataset, specify a number after -b" + 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" + 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 || { echo -e "\nFailed to make a selection in time" ; exit; } + case $current_selection in + 0 | [Ee][Xx][Ii][Tt]) + echo "Exiting.." + exit + ;; + 00) + clear -x + echo "Running \"bash heavy_script.sh ${update_selection[*]}\"" + echo + exec bash "$script_name" "${update_selection[@]}" + exit + ;; + 1 | -r) + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-r" && echo -e "\"-r\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it + update_selection+=("-r") + ;; + 2 | -i) + read -rt 120 -p "What is the name of the application we should ignore?: " up_ignore || { echo -e "\nFailed to make a selection in time" ; exit; } + ! [[ $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 3 && continue + update_selection+=("-i" "$up_ignore") + ;; + 3 | -S) + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-S" && echo -e "\"-S\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it + update_selection+=("-S") + ;; + 4 | -v) + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-v" && echo -e "\"-v\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it + update_selection+=("-v") + ;; + 5 | -t) + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-t" && echo -e "\"-t\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it + echo "What do you want your timeout to be?" + read -rt 120 -p "Please type an integer: " up_timeout || { echo -e "\nFailed to make a selection in time" ; exit; } + ! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 3 && continue + update_selection+=("-t" "$up_timeout") + ;; + 6 | -b) + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-b" && echo -e "\"-b\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it + echo "Up to how many backups should we keep?" + read -rt 120 -p "Please type an integer: " up_backups || { echo -e "\nFailed to make a selection in time" ; exit; } + ! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 3 && continue + [[ $up_backups == 0 ]] && echo -e "Error: Number of backups cannot be 0\nNOT adding it to the list" && sleep 3 && continue + update_selection+=("-b" "$up_backups") + ;; + 7 | -s) + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-s" && echo -e "\"-s\" is already on here, skipping" && sleep 3 && continue #If option is already on there, skip it + update_selection+=("-s") + ;; + 8 | -p) + printf '%s\0' "${update_selection[@]}" | grep -Fxqz -- "-p" && echo -e "\"-p\" is already on here, skipping" && sleep 3 && 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 3 && continue #If option is already on there, skip it + update_selection+=("--self-update") + ;; + 99) + count=2 + echo "restarting" + for i in "${update_selection[@]:2}" + do + unset "update_selection[$count]" + echo "$i removed" + ((count++)) + done + sleep 3 + continue + ;; + *) + echo "\"$current_selection\" was not an option, try again" && sleep 3 && continue + ;; + esac +done } export -f script_create \ No newline at end of file diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 470c342a..ccc4cf4c 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -30,15 +30,16 @@ do do update_apps "${array[$it]}" & processes+=($!) + sleep 2 ((it++)) ((proc_count++)) done - ((ttl++)) - if [[ $ttl -eq 1 ]]; then - sleep 15 - else - sleep 6 - fi + # ((ttl++)) + # if [[ $ttl -eq 1 ]]; then + # sleep 15 + # else + # sleep 6 + # fi elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 6 else # All processes must be completed, break out of loop From 1b238e22519ca6d052f2632ab86ff4c855a37a6d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 22:43:07 -0600 Subject: [PATCH 058/218] test timeout --- functions/update_apps.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index ccc4cf4c..d6069fe3 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -14,8 +14,16 @@ it=0 ttl=0 while true do - while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status') - echo "$while_status" > temp.txt + while true + do + if ! while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null); then + sleep 5 + else + echo "$while_status" > temp.txt + break + fi + done + proc_count=${#processes[@]} count=0 for proc in "${processes[@]}" @@ -30,7 +38,7 @@ do do update_apps "${array[$it]}" & processes+=($!) - sleep 2 + sleep 3 ((it++)) ((proc_count++)) done From 4df204e15b2f380ca287214d817f6e3b97be68d9 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 22:44:51 -0600 Subject: [PATCH 059/218] combo sleep --- functions/update_apps.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index d6069fe3..57daeb88 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -38,16 +38,16 @@ do do update_apps "${array[$it]}" & processes+=($!) - sleep 3 + sleep 1 ((it++)) ((proc_count++)) done - # ((ttl++)) - # if [[ $ttl -eq 1 ]]; then - # sleep 15 - # else - # sleep 6 - # fi + ((ttl++)) + if [[ $ttl -eq 1 ]]; then + sleep 15 + else + sleep 6 + fi elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 6 else # All processes must be completed, break out of loop From 9155fd135dc7006b8fc5b3addc2fa870cacfaa67 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 22:45:47 -0600 Subject: [PATCH 060/218] message --- functions/update_apps.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 57daeb88..a6ac26e2 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -17,6 +17,7 @@ do while true do if ! while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null); then + echo "Middlewared timed out, consider lowering your async updates" sleep 5 else echo "$while_status" > temp.txt From 68daf5f343c7cbe99ed43b5302fb2a196847a170 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 23:14:53 -0600 Subject: [PATCH 061/218] test sleep --- functions/update_apps.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index a6ac26e2..cfeecea8 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -24,7 +24,6 @@ do break fi done - proc_count=${#processes[@]} count=0 for proc in "${processes[@]}" @@ -45,7 +44,7 @@ do done ((ttl++)) if [[ $ttl -eq 1 ]]; then - sleep 15 + sleep 25 else sleep 6 fi From 99208d516590c352a0b107e76d4730ab4877ddb2 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 23:30:41 -0600 Subject: [PATCH 062/218] who knows --- functions/update_apps.sh | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index cfeecea8..b278a31e 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -11,7 +11,7 @@ echo "Asynchronous Updates: $update_limit" # previous 20% 2 min 9 seconds it=0 -ttl=0 +first_run=0 while true do while true @@ -34,19 +34,24 @@ do if [[ "$proc_count" -ge "$update_limit" ]]; then sleep 6 elif [[ $it -lt ${#array[@]} ]]; then + ttl=0 until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] do update_apps "${array[$it]}" & processes+=($!) - sleep 1 ((it++)) ((proc_count++)) + ((ttl++)) done - ((ttl++)) - if [[ $ttl -eq 1 ]]; then - sleep 25 - else - sleep 6 + ((first_run++)) + if [[ $first_run == 1 ]]; then + if [[ $ttl -le 5 ]]; then + sleep 15 + elif [[ $ttl -le 10 ]]; then + sleep 25 + elif [[ $ttl -gt 10 ]]; then + sleep 35 + fi fi elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 6 From 68f8934708c5b47a784a54abb156d6103dda70ed Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 23:47:34 -0600 Subject: [PATCH 063/218] test trigger --- functions/update_apps.sh | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index b278a31e..d5ab9391 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -12,18 +12,23 @@ echo "Asynchronous Updates: $update_limit" # previous 20% 2 min 9 seconds it=0 first_run=0 +while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) while true do - while true - do - if ! while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null); then - echo "Middlewared timed out, consider lowering your async updates" - sleep 5 - else - echo "$while_status" > temp.txt - break - fi - done + # while true + # do + # if ! while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null); then + # echo "Middlewared timed out, consider lowering your async updates" + # sleep 5 + # else + # echo "$while_status" > temp.txt + # break + # fi + # done + if [ ! -e "$file" ] ; then + while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) + echo "$while_status" > temp.txt + fi proc_count=${#processes[@]} count=0 for proc in "${processes[@]}" @@ -101,6 +106,7 @@ if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #con [[ "$verbose" == "true" ]] && echo_array+=("Stopping prior to update..") midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null || echo_array+=("Error: Failed to stop $app_name") SECONDS=0 + [[ ! -e trigger ]] && touch trigger while [[ "$status" != "STOPPED" ]] do status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') @@ -135,6 +141,7 @@ export -f update_apps after_update_actions(){ SECONDS=0 count=0 +[[ ! -e trigger ]] && touch trigger if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then while true do From a5b6f912fdbec29dca20edef94bdbb9a696105ec Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 23:48:02 -0600 Subject: [PATCH 064/218] forgot to rm trigger --- functions/update_apps.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index d5ab9391..25868faf 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -65,6 +65,7 @@ do fi done rm temp.txt +rm trigger echo echo } From 9a0bc10b8eb63ae6d79a20d8e15921413f7ec5c5 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 23:48:29 -0600 Subject: [PATCH 065/218] comment out un-needed --- functions/update_apps.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 25868faf..76d78053 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -48,16 +48,16 @@ do ((proc_count++)) ((ttl++)) done - ((first_run++)) - if [[ $first_run == 1 ]]; then - if [[ $ttl -le 5 ]]; then - sleep 15 - elif [[ $ttl -le 10 ]]; then - sleep 25 - elif [[ $ttl -gt 10 ]]; then - sleep 35 - fi - fi + # ((first_run++)) + # if [[ $first_run == 1 ]]; then + # if [[ $ttl -le 5 ]]; then + # sleep 15 + # elif [[ $ttl -le 10 ]]; then + # sleep 25 + # elif [[ $ttl -gt 10 ]]; then + # sleep 35 + # fi + # fi elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 6 else # All processes must be completed, break out of loop From da8df6b1807291c6818fb61343b7df70b3a87e61 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 23:53:01 -0600 Subject: [PATCH 066/218] temp creation --- 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 76d78053..cdb9fd2e 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -11,8 +11,8 @@ echo "Asynchronous Updates: $update_limit" # previous 20% 2 min 9 seconds it=0 -first_run=0 -while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) +# first_run=0 +while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) > temp.txt while true do # while true From 053d971f7a8c57a6e05fe827657e234da46544c4 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 23:58:07 -0600 Subject: [PATCH 067/218] wooo trigger works --- functions/update_apps.sh | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index cdb9fd2e..e9cd4d37 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -11,20 +11,9 @@ echo "Asynchronous Updates: $update_limit" # previous 20% 2 min 9 seconds it=0 -# first_run=0 while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) > temp.txt while true do - # while true - # do - # if ! while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null); then - # echo "Middlewared timed out, consider lowering your async updates" - # sleep 5 - # else - # echo "$while_status" > temp.txt - # break - # fi - # done if [ ! -e "$file" ] ; then while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) echo "$while_status" > temp.txt @@ -48,16 +37,6 @@ do ((proc_count++)) ((ttl++)) done - # ((first_run++)) - # if [[ $first_run == 1 ]]; then - # if [[ $ttl -le 5 ]]; then - # sleep 15 - # elif [[ $ttl -le 10 ]]; then - # sleep 25 - # elif [[ $ttl -gt 10 ]]; then - # sleep 35 - # fi - # fi elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 6 else # All processes must be completed, break out of loop From fbfce5ce269b795684441416ad539487ba94ec5e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 8 Aug 2022 23:59:32 -0600 Subject: [PATCH 068/218] uhh --- functions/update_apps.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index e9cd4d37..2ef0f803 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -14,7 +14,7 @@ it=0 while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) > temp.txt while true do - if [ ! -e "$file" ] ; then + if [ ! -e trigger ] ; then while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) echo "$while_status" > temp.txt fi @@ -28,14 +28,12 @@ do if [[ "$proc_count" -ge "$update_limit" ]]; then sleep 6 elif [[ $it -lt ${#array[@]} ]]; then - ttl=0 until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] do update_apps "${array[$it]}" & processes+=($!) ((it++)) ((proc_count++)) - ((ttl++)) done elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 6 From e97b61b2726c9e8aca901770ab64309e68870909 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 00:03:27 -0600 Subject: [PATCH 069/218] 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 2ef0f803..aecb5a6d 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -14,7 +14,7 @@ it=0 while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) > temp.txt while true do - if [ ! -e trigger ] ; then + if [ -f trigger ]; then while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) echo "$while_status" > temp.txt fi From ba1f1f5358c21339edc066d612f2ab2130d5523c Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 00:31:04 -0600 Subject: [PATCH 070/218] global sleep 5 --- functions/update_apps.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index aecb5a6d..70641491 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -98,7 +98,7 @@ if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #con break elif [[ "$status" != "STOPPED" ]]; then [[ "$verbose" == "true" ]] && echo_array+=("Waiting $((timeout-SECONDS)) more seconds for $app_name to be STOPPED") - sleep 15 + sleep 5 fi done fi @@ -132,14 +132,14 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then echo_array+=("Stopped") break else - [[ "$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 + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 5 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && sleep 5 && 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. fi 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 + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 5 && continue #if reports stopped on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && sleep 5 && 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. elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then @@ -167,7 +167,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then fi else [[ "$verbose" == "true" ]] && echo_array+=("Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE") - sleep 15 + sleep 5 continue fi done From f0b95738500d4810cb08c273306c54091d6e456c Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 00:48:12 -0600 Subject: [PATCH 071/218] regression in speed --- functions/update_apps.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 70641491..e8733940 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -32,6 +32,7 @@ do do update_apps "${array[$it]}" & processes+=($!) + sleep 3 ((it++)) ((proc_count++)) done From d75003c6f01d44ee37bcebf1a3ca3757e4817d37 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 12:05:18 -0600 Subject: [PATCH 072/218] revert global --- functions/update_apps.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index e8733940..00ffeead 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -133,14 +133,14 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then echo_array+=("Stopped") break else - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 5 && continue #if reports active on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 5 && 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_array+=("Active") break #if reports active any time after the first loop, assume actually active. fi elif [[ "$status" == "STOPPED" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 5 && continue #if reports stopped on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 5 && 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_array+=("Stopped") break #if reports stopped any time after the first loop, assume its extermal services. elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then @@ -168,7 +168,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then fi else [[ "$verbose" == "true" ]] && echo_array+=("Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE") - sleep 5 + sleep 15 continue fi done From 8dafa5eb44ddbe6ab4a7254c1f67213c324ca0a8 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 12:16:15 -0600 Subject: [PATCH 073/218] major release 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 00ffeead..fab7ada7 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -109,7 +109,7 @@ if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #con cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=("Updated\n$old_full_ver\n$new_full_ver") || echo_array+=("FAILED") fi else - echo_array+=("\n$app_name\nMajor Release, update manually") + echo -e "\n$app_name\nMajor Release, update manually" return 0 fi after_update_actions From 734f1b7ebc7eaf4fd85212cf81acba2c37425c3f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 12:19:24 -0600 Subject: [PATCH 074/218] check for file before deletion --- 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 fab7ada7..e1c7b45d 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -43,7 +43,7 @@ do fi done rm temp.txt -rm trigger +[[ -e trigger ]] && rm trigger echo echo } From bac1658480eec127bd44ca758ce430871549a34c Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 12:24:13 -0600 Subject: [PATCH 075/218] file rather than anything --- 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 e1c7b45d..9516b0a3 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -43,7 +43,7 @@ do fi done rm temp.txt -[[ -e trigger ]] && rm trigger +[[ -f trigger ]] && rm trigger echo echo } From 495205253a7f437a5b293b6513a8f87c1fc0fb76 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 17:32:47 -0600 Subject: [PATCH 076/218] test new update --- functions/update_apps.sh | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 9516b0a3..0c51132e 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -78,8 +78,7 @@ if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #con 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") || echo_array+=("FAILED") - return 0 + update 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..") @@ -92,8 +91,7 @@ if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #con 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") || echo_array+=("Failed to update") - break + update elif [[ "$SECONDS" -ge "$timeout" ]]; then echo_array+=("Error: Run Time($SECONDS) has exceeded Timeout($timeout)") break @@ -106,7 +104,7 @@ if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #con 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") || echo_array+=("FAILED") + update fi else echo -e "\n$app_name\nMajor Release, update manually" @@ -117,6 +115,23 @@ after_update_actions export -f update_apps +update(){ +count=0 +while [[ $count -lt 3 ]] +do + updated=$(grep "^$app_name," temp.txt | awk -F ',' '{print $3}') + if cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null || [[ $updated == "false" ]]; then + echo_array+=("Updated\n$old_full_ver\n$new_full_ver") + break + else + echo_array+=("Failed, trying again..") + ((count++)) + sleep 5 + fi +done +} +export -f update + after_update_actions(){ SECONDS=0 count=0 From b8616e988c639a189cbf380f08a6c31c3a649357 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 17:46:59 -0600 Subject: [PATCH 077/218] error message on failed update --- functions/update_apps.sh | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 0c51132e..f5c9e086 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -78,7 +78,12 @@ if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #con if [[ "$startstatus" == "STOPPED" ]]; then # if status is already stopped, skip while loop echo_array+=("\n$app_name") [[ "$verbose" == "true" ]] && echo_array+=("Updating..") - update + if update ;then + echo_array+=("Updated\n$old_full_ver\n$new_full_ver") + else + echo_array+=("Failed to update") + return + fi 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..") @@ -91,7 +96,12 @@ if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #con if [[ "$status" == "STOPPED" ]]; then echo_array+=("Stopped") [[ "$verbose" == "true" ]] && echo_array+=("Updating..") - update + if update ;then + echo_array+=("Updated\n$old_full_ver\n$new_full_ver") + else + echo_array+=("Failed to update") + return + fi elif [[ "$SECONDS" -ge "$timeout" ]]; then echo_array+=("Error: Run Time($SECONDS) has exceeded Timeout($timeout)") break @@ -104,7 +114,12 @@ if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #con else #user must not be using -S, just update echo_array+=("\n$app_name") [[ "$verbose" == "true" ]] && echo_array+=("Updating..") - update + if update ;then + echo_array+=("Updated\n$old_full_ver\n$new_full_ver") + else + echo_array+=("Failed to update") + return + fi fi else echo -e "\n$app_name\nMajor Release, update manually" @@ -121,10 +136,8 @@ while [[ $count -lt 3 ]] do updated=$(grep "^$app_name," temp.txt | awk -F ',' '{print $3}') if cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null || [[ $updated == "false" ]]; then - echo_array+=("Updated\n$old_full_ver\n$new_full_ver") break else - echo_array+=("Failed, trying again..") ((count++)) sleep 5 fi From ad4f507f6f1070af89bdcd969c7d5375e429248f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 17:52:11 -0600 Subject: [PATCH 078/218] return codes for failures --- 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 f5c9e086..ce410810 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -137,9 +137,11 @@ do updated=$(grep "^$app_name," temp.txt | awk -F ',' '{print $3}') if cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null || [[ $updated == "false" ]]; then break - else + elif [[ $count -lt 3 ]]; then ((count++)) sleep 5 + else + return 1 fi done } From 03c16717ccadaa603cb413812208695aa4b1e688 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 17:52:56 -0600 Subject: [PATCH 079/218] lower sleep --- 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 ce410810..7e1941a9 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -32,7 +32,7 @@ do do update_apps "${array[$it]}" & processes+=($!) - sleep 3 + sleep 2 ((it++)) ((proc_count++)) done From 0d30de9e22ef2bfbdbc5a6769cf79004f56a7095 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 21:50:22 -0600 Subject: [PATCH 080/218] test shell --- functions/cmd_to_container.sh | 53 ++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 8b51cf76..e7603d74 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -52,15 +52,48 @@ do done container=$(echo "$containers" | grep ^"$selection)" | awk '{print $2}') container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') -clear -x -title -echo "App Name: $app_name" -echo "Container: $container" -echo -echo "0) Exit" -read -rt 120 -p "What command would you like to run?: " command || { echo -e "\nFailed to make a selection in time" ; exit; } -[[ $command == 0 ]] && echo "Exiting.." && exit -k3s crictl exec "$container_id" $command -container=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') +while true +do + clear -x + title + echo "App Name: $app_name" + echo "Container: $container" + echo + echo "1) Run a single command" + echo "2) Open Shell" + echo + echo "0) Exit" + read -rt 120 -p "Please choose an option: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } + case $selection in + 0) + echo "Exiting.." + exit + ;; + + 1) + clear -x + title + read -rt 120 -p "What command do you want to run?: " command || { echo -e "\nFailed to make a selection in time" ; exit; } + k3s crictl exec -it "$container_id" $command + break + ;; + + 2) + clear -x + title + + if ! k3s crictl exec -it "$container_id" /bin/bash ; then + k3s crictl exec -it "$container_id" /bin/sh + fi + break + ;; + + *) + echo "That was not an option.. Try again" + sleep 3 + ;; + esac +done + } export -f cmd_to_container \ No newline at end of file From 6b9be5102c052fb4dfebddd2bf117d7d536c33aa Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 21:53:47 -0600 Subject: [PATCH 081/218] error code --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index e7603d74..49b8ab29 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -82,7 +82,7 @@ do clear -x title - if ! k3s crictl exec -it "$container_id" /bin/bash ; then + if ! k3s crictl exec -it "$container_id" /bin/bash && $? != 130 ; then k3s crictl exec -it "$container_id" /bin/sh fi break From 7842b83700d6c5b04dfb6fb77f6ee3942204c247 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 22:06:41 -0600 Subject: [PATCH 082/218] test --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 49b8ab29..e7603d74 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -82,7 +82,7 @@ do clear -x title - if ! k3s crictl exec -it "$container_id" /bin/bash && $? != 130 ; then + if ! k3s crictl exec -it "$container_id" /bin/bash ; then k3s crictl exec -it "$container_id" /bin/sh fi break From 9c1258e02ece1a2245a64181c633cc249ed8d030 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 22:11:07 -0600 Subject: [PATCH 083/218] error message upon both sh and bash failure --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index e7603d74..24492c91 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -83,7 +83,7 @@ do title if ! k3s crictl exec -it "$container_id" /bin/bash ; then - k3s crictl exec -it "$container_id" /bin/sh + k3s crictl exec -it "$container_id" /bin/sh || echo "This application does not accept shell access apparently" fi break ;; From e331dc2deb727215336261229a44fa7545a5b471 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 22:12:15 -0600 Subject: [PATCH 084/218] better message --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 24492c91..9b3f128d 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -83,7 +83,7 @@ do title if ! k3s crictl exec -it "$container_id" /bin/bash ; then - k3s crictl exec -it "$container_id" /bin/sh || echo "This application does not accept shell access apparently" + k3s crictl exec -it "$container_id" /bin/sh || echo "This container does not accept shell access, try a different one." fi break ;; From c69d1b29831211f724be0c3c6328104e08b10ea2 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 22:14:27 -0600 Subject: [PATCH 085/218] remove error messages --- functions/cmd_to_container.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 9b3f128d..d86e82b4 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -82,8 +82,8 @@ do clear -x title - if ! k3s crictl exec -it "$container_id" /bin/bash ; then - k3s crictl exec -it "$container_id" /bin/sh || echo "This container does not accept shell access, try a different one." + if ! k3s crictl exec -it "$container_id" /bin/bash 2>/dev/null; then + k3s crictl exec -it "$container_id" /bin/sh 2>/dev/null || echo "This container does not accept shell access, try a different one." fi break ;; From b935c755c9befcfa81c2f28380dd8f9fb59b9a50 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 22:15:21 -0600 Subject: [PATCH 086/218] hide both error and info --- functions/cmd_to_container.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index d86e82b4..3c50d5bf 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -82,8 +82,8 @@ do clear -x title - if ! k3s crictl exec -it "$container_id" /bin/bash 2>/dev/null; then - k3s crictl exec -it "$container_id" /bin/sh 2>/dev/null || echo "This container does not accept shell access, try a different one." + if ! k3s crictl exec -it "$container_id" /bin/bash &>/dev/null; then + k3s crictl exec -it "$container_id" /bin/sh &>/dev/null || echo "This container does not accept shell access, try a different one." fi break ;; From d05b8674b3a68119e0a99e65fd63fab25a7aa9e3 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 22:16:49 -0600 Subject: [PATCH 087/218] only show stdout --- functions/cmd_to_container.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 3c50d5bf..d86e82b4 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -82,8 +82,8 @@ do clear -x title - if ! k3s crictl exec -it "$container_id" /bin/bash &>/dev/null; then - k3s crictl exec -it "$container_id" /bin/sh &>/dev/null || echo "This container does not accept shell access, try a different one." + if ! k3s crictl exec -it "$container_id" /bin/bash 2>/dev/null; then + k3s crictl exec -it "$container_id" /bin/sh 2>/dev/null || echo "This container does not accept shell access, try a different one." fi break ;; From 1c0e223648f2ceba1b8553be21d69c95628f5a47 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 22:27:16 -0600 Subject: [PATCH 088/218] cleanup --- functions/cmd_to_container.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index d86e82b4..ef378b14 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -69,7 +69,6 @@ do echo "Exiting.." exit ;; - 1) clear -x title @@ -77,17 +76,14 @@ do k3s crictl exec -it "$container_id" $command break ;; - 2) clear -x title - if ! k3s crictl exec -it "$container_id" /bin/bash 2>/dev/null; then k3s crictl exec -it "$container_id" /bin/sh 2>/dev/null || echo "This container does not accept shell access, try a different one." fi break ;; - *) echo "That was not an option.. Try again" sleep 3 From 51a5e5fcc2c447c41aa3f47eaaf7aee32518c1c2 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 22:47:59 -0600 Subject: [PATCH 089/218] better update handler --- functions/update_apps.sh | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 7e1941a9..362cadab 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -134,14 +134,19 @@ update(){ count=0 while [[ $count -lt 3 ]] do - updated=$(grep "^$app_name," temp.txt | awk -F ',' '{print $3}') - if cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null || [[ $updated == "false" ]]; then + update_avail=$(grep "^$app_name," temp.txt | awk -F ',' '{print $3}') + if [[ $update_avail == "true" ]]; then + if ! cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null ; then + sleep 6 + ((count++)) + continue + fi + break + elif [[ $update_avail == "false" ]]; then break - elif [[ $count -lt 3 ]]; then - ((count++)) - sleep 5 else - return 1 + ((count++)) + sleep 6 fi done } From dcd562462bbfcdc3fffd6f94abbe6067159e3b95 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 23:03:39 -0600 Subject: [PATCH 090/218] add trigger to update --- 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 362cadab..7fa3327d 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -12,6 +12,7 @@ echo "Asynchronous Updates: $update_limit" # previous 20% 2 min 9 seconds it=0 while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) > temp.txt +echo "$while_status" > temp.txt while true do if [ -f trigger ]; then @@ -131,6 +132,7 @@ export -f update_apps update(){ +[[ ! -e trigger ]] && touch trigger count=0 while [[ $count -lt 3 ]] do @@ -155,7 +157,7 @@ export -f update after_update_actions(){ SECONDS=0 count=0 -[[ ! -e trigger ]] && touch trigger +# [[ ! -e trigger ]] && touch trigger if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then while true do From 96b462fd5d4b05ad62d35452fe9001426bb368cd Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 9 Aug 2022 23:34:06 -0600 Subject: [PATCH 091/218] trigger fix --- 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 7fa3327d..38462066 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -13,9 +13,10 @@ echo "Asynchronous Updates: $update_limit" it=0 while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) > temp.txt echo "$while_status" > temp.txt +rm trigger &>/dev/null while true do - if [ -f trigger ]; then + if [[ -f trigger ]]; then while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) echo "$while_status" > temp.txt fi From 591120e2fe0afdea3e77385e06bed526d953d517 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 11:52:34 -0600 Subject: [PATCH 092/218] better placements of trigger file --- 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 38462066..dec7a1fc 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -133,13 +133,13 @@ export -f update_apps update(){ -[[ ! -e trigger ]] && touch trigger count=0 while [[ $count -lt 3 ]] do update_avail=$(grep "^$app_name," temp.txt | awk -F ',' '{print $3}') if [[ $update_avail == "true" ]]; then if ! cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null ; then + [[ ! -e trigger ]] && touch trigger sleep 6 ((count++)) continue @@ -158,8 +158,8 @@ export -f update after_update_actions(){ SECONDS=0 count=0 -# [[ ! -e trigger ]] && touch trigger if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then + [[ ! -e trigger ]] && touch trigger while true do (( count++ )) From fcd07cfa4fa4882745b2219f57cad7c4380d48f1 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 11:53:24 -0600 Subject: [PATCH 093/218] slightly lower commander sleep timer --- 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 dec7a1fc..74641ac9 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -28,7 +28,7 @@ do ((count++)) done if [[ "$proc_count" -ge "$update_limit" ]]; then - sleep 6 + sleep 4 elif [[ $it -lt ${#array[@]} ]]; then until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] do @@ -39,7 +39,7 @@ do ((proc_count++)) done elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish - sleep 6 + sleep 4 else # All processes must be completed, break out of loop break fi From e3e85cf38e5d435c97ca3fd66957b9f3c63b59e7 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 13:57:50 -0600 Subject: [PATCH 094/218] pod_id regex --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index ef378b14..173aaca7 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -24,7 +24,7 @@ do done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') search=$(k3s crictl ps -a -s running) -mapfile -t pod_id < <(echo "$search" | grep -E " $app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $9}') +mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $9}') [[ "${#pod_id[@]}" == 0 ]] && echo -e "No containers available\nAre you sure the application in running?" && exit containers=$( for pod in "${pod_id[@]}" From 82a2deffa071668d2c53fa88cc79286a46f79a8b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 14:14:24 -0600 Subject: [PATCH 095/218] print only last column for pod --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 173aaca7..0dca8e79 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -29,7 +29,7 @@ mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]] containers=$( for pod in "${pod_id[@]}" do - echo "$search" | grep "$pod" | awk '{print $7}' + echo "$search" | grep "$pod" | awk '{print $(NF)}' done | nl -s ") " | column -t) while true do From 84c1fcd006d98bd91e45e0e25415a85f460ed669 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 14:16:31 -0600 Subject: [PATCH 096/218] whoops --- functions/cmd_to_container.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 0dca8e79..e5ae6e7b 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -24,12 +24,12 @@ do done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') search=$(k3s crictl ps -a -s running) -mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $9}') +mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') [[ "${#pod_id[@]}" == 0 ]] && echo -e "No containers available\nAre you sure the application in running?" && exit containers=$( for pod in "${pod_id[@]}" do - echo "$search" | grep "$pod" | awk '{print $(NF)}' + echo "$search" | grep "$pod" | awk '{print $7}' done | nl -s ") " | column -t) while true do From 0852e29d8a9696a15baca61e49d8f70c0ecb5146 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 14:33:41 -0600 Subject: [PATCH 097/218] test remove dates, they messed up awk --- functions/cmd_to_container.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index e5ae6e7b..1428c4a1 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -23,13 +23,13 @@ do fi done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') -search=$(k3s crictl ps -a -s running) +search=$(k3s crictl ps -a -s running | sed -E 's/([0-9]*|About)[[:space:]](an|hours)[[:space:]](hour)?[[:space:]]?ago//') mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') [[ "${#pod_id[@]}" == 0 ]] && echo -e "No containers available\nAre you sure the application in running?" && exit containers=$( for pod in "${pod_id[@]}" do - echo "$search" | grep "$pod" | awk '{print $7}' + echo "$search" | grep "$pod" | awk '{print $4}' done | nl -s ") " | column -t) while true do From 074b3d09cf2e2dafbbd169daf3c1a324b4fed4d6 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 14:51:01 -0600 Subject: [PATCH 098/218] incase days are added --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 1428c4a1..85061063 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -23,7 +23,7 @@ do fi done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') -search=$(k3s crictl ps -a -s running | sed -E 's/([0-9]*|About)[[:space:]](an|hours)[[:space:]](hour)?[[:space:]]?ago//') +search=$(k3s crictl ps -a -s running | sed -E 's/([0-9]*|About)[[:space:]][a-z]{2,5}[[:space:]](hour)?[[:space:]]?ago//') mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') [[ "${#pod_id[@]}" == 0 ]] && echo -e "No containers available\nAre you sure the application in running?" && exit containers=$( From 6f7f18d6a4a5b0ed5b8390277bd3ac0588f31179 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 16:30:07 -0600 Subject: [PATCH 099/218] if only one container, auto select it --- functions/cmd_to_container.sh | 46 +++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 85061063..5af6cb4a 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -31,27 +31,31 @@ for pod in "${pod_id[@]}" do echo "$search" | grep "$pod" | awk '{print $4}' done | nl -s ") " | column -t) -while true -do - clear -x - title - echo "$containers" - echo - echo "0) Exit" - read -rt 120 -p "Choose a container by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } - if [[ $selection == 0 ]]; then - echo "Exiting.." - exit - elif ! echo -e "$containers" | grep -qs ^"$selection)" ; then - echo "Error: \"$selection\" was not an option.. Try again" - sleep 3 - continue - else - break - fi -done -container=$(echo "$containers" | grep ^"$selection)" | awk '{print $2}') -container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') +if [[ "${#pod_id[@]}" == 1 ]]; then + container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') +else + while true + do + clear -x + title + echo "$containers" + echo + echo "0) Exit" + read -rt 120 -p "Choose a container by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } + if [[ $selection == 0 ]]; then + echo "Exiting.." + exit + elif ! echo -e "$containers" | grep -qs ^"$selection)" ; then + echo "Error: \"$selection\" was not an option.. Try again" + sleep 3 + continue + else + break + fi + done + container=$(echo "$containers" | grep ^"$selection)" | awk '{print $2}') + container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') +fi while true do clear -x From d830f7e10cc1dc4981114d9c4489b083ec9ac95d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 16:31:29 -0600 Subject: [PATCH 100/218] replace with podid --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 5af6cb4a..1effb5f0 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -32,7 +32,7 @@ do echo "$search" | grep "$pod" | awk '{print $4}' done | nl -s ") " | column -t) if [[ "${#pod_id[@]}" == 1 ]]; then - container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') + container_id=$(echo "$search" | grep -E "[[:space:]]${pod_id[*]}[[:space:]]" | awk '{print $1}') else while true do From 2dc9cc4742a98dbd88c61223765d72b7c0a7f033 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 16:33:59 -0600 Subject: [PATCH 101/218] whew --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 1effb5f0..9c198555 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -32,7 +32,7 @@ do echo "$search" | grep "$pod" | awk '{print $4}' done | nl -s ") " | column -t) if [[ "${#pod_id[@]}" == 1 ]]; then - container_id=$(echo "$search" | grep -E "[[:space:]]${pod_id[*]}[[:space:]]" | awk '{print $1}') + container_id=$(echo "$search" | grep -E "[[:space:]]${containers}[[:space:]]" | awk '{print $1}') else while true do From 26362944a5eb1d0ecc1374bd5c7657caf430d9e4 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 16:39:42 -0600 Subject: [PATCH 102/218] fix --- functions/cmd_to_container.sh | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 9c198555..56274270 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -25,15 +25,19 @@ done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') search=$(k3s crictl ps -a -s running | sed -E 's/([0-9]*|About)[[:space:]][a-z]{2,5}[[:space:]](hour)?[[:space:]]?ago//') mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') -[[ "${#pod_id[@]}" == 0 ]] && echo -e "No containers available\nAre you sure the application in running?" && exit -containers=$( -for pod in "${pod_id[@]}" -do - echo "$search" | grep "$pod" | awk '{print $4}' -done | nl -s ") " | column -t) + if [[ "${#pod_id[@]}" == 1 ]]; then - container_id=$(echo "$search" | grep -E "[[:space:]]${containers}[[:space:]]" | awk '{print $1}') + container=$(echo "$search" | grep "${pod_id[*]}" | awk '{print $4}') + container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') +elif [[ "${#pod_id[@]}" == 0 ]]; then + echo -e "No containers available\nAre you sure the application in running?" + exit else + containers=$( + for pod in "${pod_id[@]}" + do + echo "$search" | grep "$pod" | awk '{print $4}' + done | nl -s ") " | column -t) while true do clear -x From a8b60f5c7175cd95c0aa6426991367067873cb7d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 16:58:07 -0600 Subject: [PATCH 103/218] check for number of containers not pods --- functions/cmd_to_container.sh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 56274270..8c68f768 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -25,24 +25,30 @@ done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') search=$(k3s crictl ps -a -s running | sed -E 's/([0-9]*|About)[[:space:]][a-z]{2,5}[[:space:]](hour)?[[:space:]]?ago//') mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') +for pod in "${pod_id[@]}" +do + mapfile -t containers < <(echo "$search" | grep "$pod" | awk '{print $4}') +done -if [[ "${#pod_id[@]}" == 1 ]]; then +if [[ "${#containers[@]}" == 1 ]]; then container=$(echo "$search" | grep "${pod_id[*]}" | awk '{print $4}') container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') -elif [[ "${#pod_id[@]}" == 0 ]]; then +elif [[ "${#containers[@]}" == 0 ]]; then echo -e "No containers available\nAre you sure the application in running?" exit else - containers=$( for pod in "${pod_id[@]}" do - echo "$search" | grep "$pod" | awk '{print $4}' - done | nl -s ") " | column -t) + mapfile -t containers < <(echo "$search" | grep "$pod" | awk '{print $4}') + done while true do clear -x title - echo "$containers" + for container in "${containers[@]}" + do + echo "$container" + done | nl -s ") " | column -t echo echo "0) Exit" read -rt 120 -p "Choose a container by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } From bc694852a9709826821fb3220ba4949ffd6f7774 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 17:00:10 -0600 Subject: [PATCH 104/218] expand all for grep --- functions/cmd_to_container.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 8c68f768..d8eee929 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -55,7 +55,7 @@ else if [[ $selection == 0 ]]; then echo "Exiting.." exit - elif ! echo -e "$containers" | grep -qs ^"$selection)" ; then + elif ! echo -e "${containers[*]}" | grep -qs ^"$selection)" ; then echo "Error: \"$selection\" was not an option.. Try again" sleep 3 continue @@ -63,7 +63,7 @@ else break fi done - container=$(echo "$containers" | grep ^"$selection)" | awk '{print $2}') + container=$(echo "${containers[*]}" | grep ^"$selection)" | awk '{print $2}') container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') fi while true From a9b4cd02ed8df95edf50cc7b39f88a3eabb114ba Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 17:03:37 -0600 Subject: [PATCH 105/218] add nl to grep --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index d8eee929..9b30bbe1 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -55,7 +55,7 @@ else if [[ $selection == 0 ]]; then echo "Exiting.." exit - elif ! echo -e "${containers[*]}" | grep -qs ^"$selection)" ; then + elif ! echo -e "${containers[*]}" | nl -s ") " | grep -qs ^"$selection)" ; then echo "Error: \"$selection\" was not an option.. Try again" sleep 3 continue From dc5fd00681a335f2982c82986dfe542059a9187e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 17:04:46 -0600 Subject: [PATCH 106/218] expand by row --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 9b30bbe1..0362dead 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -55,7 +55,7 @@ else if [[ $selection == 0 ]]; then echo "Exiting.." exit - elif ! echo -e "${containers[*]}" | nl -s ") " | grep -qs ^"$selection)" ; then + elif ! echo -e "${containers[@]}" | nl -s ") " | grep -qs ^"$selection)" ; then echo "Error: \"$selection\" was not an option.. Try again" sleep 3 continue From 1949c2100c7878e676aa4705a63ad6cbcd8021cb Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 17:09:30 -0600 Subject: [PATCH 107/218] append to variable to search works --- functions/cmd_to_container.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 0362dead..b6da7333 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -45,17 +45,20 @@ else do clear -x title + cont_search=$( for container in "${containers[@]}" do echo "$container" done | nl -s ") " | column -t + ) + echo "$cont_search" echo echo "0) Exit" read -rt 120 -p "Choose a container by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } if [[ $selection == 0 ]]; then echo "Exiting.." exit - elif ! echo -e "${containers[@]}" | nl -s ") " | grep -qs ^"$selection)" ; then + elif ! echo -e "$cont_search}" | nl -s ") " | grep -qs ^"$selection)" ; then echo "Error: \"$selection\" was not an option.. Try again" sleep 3 continue @@ -63,7 +66,7 @@ else break fi done - container=$(echo "${containers[*]}" | grep ^"$selection)" | awk '{print $2}') + container=$(echo "$cont_search" | grep ^"$selection)" | awk '{print $2}') container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') fi while true From bff29b16378142a79feff80a97c355e821c415f8 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 17:11:01 -0600 Subject: [PATCH 108/218] remove nl --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index b6da7333..5ce76e68 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -58,7 +58,7 @@ else if [[ $selection == 0 ]]; then echo "Exiting.." exit - elif ! echo -e "$cont_search}" | nl -s ") " | grep -qs ^"$selection)" ; then + elif ! echo -e "$cont_search}" | grep -qs ^"$selection)" ; then echo "Error: \"$selection\" was not an option.. Try again" sleep 3 continue From 04c0a983a2fc9b0ca67a63d67f2ed348d0d3788a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 17:13:48 -0600 Subject: [PATCH 109/218] pod id and container check --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 5ce76e68..00c0e6d5 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -30,7 +30,7 @@ do mapfile -t containers < <(echo "$search" | grep "$pod" | awk '{print $4}') done -if [[ "${#containers[@]}" == 1 ]]; then +if [[ "${#containers[@]}" == 1 && "${#pod_id[@]}" == 1 ]]; then container=$(echo "$search" | grep "${pod_id[*]}" | awk '{print $4}') container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') elif [[ "${#containers[@]}" == 0 ]]; then From dc1f9bb6030b5c4dd98bee095be2e534ba8e1f41 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 17:16:45 -0600 Subject: [PATCH 110/218] replace ind check with count --- functions/cmd_to_container.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 00c0e6d5..6df7509e 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -25,12 +25,14 @@ done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') search=$(k3s crictl ps -a -s running | sed -E 's/([0-9]*|About)[[:space:]][a-z]{2,5}[[:space:]](hour)?[[:space:]]?ago//') mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') +count=0 for pod in "${pod_id[@]}" do mapfile -t containers < <(echo "$search" | grep "$pod" | awk '{print $4}') + ((count++)) done -if [[ "${#containers[@]}" == 1 && "${#pod_id[@]}" == 1 ]]; then +if [[ $count == 1 ]]; then container=$(echo "$search" | grep "${pod_id[*]}" | awk '{print $4}') container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') elif [[ "${#containers[@]}" == 0 ]]; then From 94e78f756b21b1b89e0d915c6c053628820085eb Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 17:20:34 -0600 Subject: [PATCH 111/218] variable is only being saved once --- functions/cmd_to_container.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 6df7509e..4f335a49 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -48,9 +48,9 @@ else clear -x title cont_search=$( - for container in "${containers[@]}" + for i in "${containers[@]}" do - echo "$container" + echo "$i" done | nl -s ") " | column -t ) echo "$cont_search" From b18818bbd503c932547f9876a439b918278d1b36 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 17:25:13 -0600 Subject: [PATCH 112/218] attempt new for loop --- functions/cmd_to_container.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 4f335a49..f1c35399 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -41,7 +41,8 @@ elif [[ "${#containers[@]}" == 0 ]]; then else for pod in "${pod_id[@]}" do - mapfile -t containers < <(echo "$search" | grep "$pod" | awk '{print $4}') + # mapfile -t containers < <(echo "$search" | grep "$pod" | awk '{print $4}') + IFS=" " read -r -a containers <<< "$(echo "$search" | grep "$pod" | awk '{print $4}')" done while true do From fd1b04279eed0db30717c566e4e770c495ba7777 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 17:28:42 -0600 Subject: [PATCH 113/218] testing --- functions/cmd_to_container.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index f1c35399..856b3756 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -41,8 +41,7 @@ elif [[ "${#containers[@]}" == 0 ]]; then else for pod in "${pod_id[@]}" do - # mapfile -t containers < <(echo "$search" | grep "$pod" | awk '{print $4}') - IFS=" " read -r -a containers <<< "$(echo "$search" | grep "$pod" | awk '{print $4}')" + echo "$pod" done while true do From a03eebb4beb43077a8bd94355b724b642453fd48 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 17:33:19 -0600 Subject: [PATCH 114/218] remove different pod id --- functions/cmd_to_container.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 856b3756..c4d0e34d 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -39,10 +39,6 @@ elif [[ "${#containers[@]}" == 0 ]]; then echo -e "No containers available\nAre you sure the application in running?" exit else - for pod in "${pod_id[@]}" - do - echo "$pod" - done while true do clear -x From 7b0cacbfebd04968352a44fab531018b51180547 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 17:36:42 -0600 Subject: [PATCH 115/218] sanity check --- functions/cmd_to_container.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index c4d0e34d..1f1c8d51 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -43,13 +43,13 @@ else do clear -x title - cont_search=$( + for i in "${containers[@]}" do echo "$i" done | nl -s ") " | column -t - ) - echo "$cont_search" + + echo echo "0) Exit" read -rt 120 -p "Choose a container by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } From a5b17cdb964a34caf4e6b36b160f37e5d5d666ca Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 17:37:53 -0600 Subject: [PATCH 116/218] what the hell --- functions/cmd_to_container.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 1f1c8d51..3a55241a 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -29,6 +29,7 @@ count=0 for pod in "${pod_id[@]}" do mapfile -t containers < <(echo "$search" | grep "$pod" | awk '{print $4}') + echo "${#containers[@]}" ((count++)) done @@ -43,13 +44,13 @@ else do clear -x title - + cont_search=$( for i in "${containers[@]}" do echo "$i" done | nl -s ") " | column -t - - + ) + echo "$cont_search" echo echo "0) Exit" read -rt 120 -p "Choose a container by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } From ba58fecf89cb5894a17e3ea5d5089673111d620b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 17:40:33 -0600 Subject: [PATCH 117/218] new array append method --- functions/cmd_to_container.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 3a55241a..70484252 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -25,15 +25,13 @@ done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') search=$(k3s crictl ps -a -s running | sed -E 's/([0-9]*|About)[[:space:]][a-z]{2,5}[[:space:]](hour)?[[:space:]]?ago//') mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') -count=0 for pod in "${pod_id[@]}" do - mapfile -t containers < <(echo "$search" | grep "$pod" | awk '{print $4}') + containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}')") echo "${#containers[@]}" - ((count++)) done -if [[ $count == 1 ]]; then +if [[ "${#containers[@]}" == 1 ]]; then container=$(echo "$search" | grep "${pod_id[*]}" | awk '{print $4}') container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') elif [[ "${#containers[@]}" == 0 ]]; then From c6d0926fc2b2aa390aa57974814e6c22d8e03757 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 17:41:51 -0600 Subject: [PATCH 118/218] works --- functions/cmd_to_container.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 70484252..d1dc1870 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -28,15 +28,14 @@ mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]] for pod in "${pod_id[@]}" do containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}')") - echo "${#containers[@]}" done -if [[ "${#containers[@]}" == 1 ]]; then - container=$(echo "$search" | grep "${pod_id[*]}" | awk '{print $4}') - container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') -elif [[ "${#containers[@]}" == 0 ]]; then +if [[ "${#containers[@]}" == 0 ]]; then echo -e "No containers available\nAre you sure the application in running?" exit +elif [[ "${#containers[@]}" == 1 ]]; then + container=$(echo "$search" | grep "${pod_id[*]}" | awk '{print $4}') + container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') else while true do From 665db11d8cb0c31d021a1780b99c2d11c0c4c290 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 17:46:01 -0600 Subject: [PATCH 119/218] replace ugly if statement with case --- functions/cmd_to_container.sh | 109 +++++++++++++++++++++++----------- 1 file changed, 75 insertions(+), 34 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index d1dc1870..787b1c62 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -30,41 +30,82 @@ do containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}')") done -if [[ "${#containers[@]}" == 0 ]]; then - echo -e "No containers available\nAre you sure the application in running?" - exit -elif [[ "${#containers[@]}" == 1 ]]; then - container=$(echo "$search" | grep "${pod_id[*]}" | awk '{print $4}') - container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') -else - while true - do - clear -x - title - cont_search=$( - for i in "${containers[@]}" +case "${#containers[@]}" in + 0) + echo -e "No containers available\nAre you sure the application in running?" + exit + ;; + 1) + container=$(echo "$search" | grep "${pod_id[*]}" | awk '{print $4}') + container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') + ;; + + *) + while true do - echo "$i" - done | nl -s ") " | column -t - ) - echo "$cont_search" - echo - echo "0) Exit" - read -rt 120 -p "Choose a container by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } - if [[ $selection == 0 ]]; then - echo "Exiting.." - exit - elif ! echo -e "$cont_search}" | grep -qs ^"$selection)" ; then - echo "Error: \"$selection\" was not an option.. Try again" - sleep 3 - continue - else - break - fi - done - container=$(echo "$cont_search" | grep ^"$selection)" | awk '{print $2}') - container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') -fi + clear -x + title + cont_search=$( + for i in "${containers[@]}" + do + echo "$i" + done | nl -s ") " | column -t + ) + echo "$cont_search" + echo + echo "0) Exit" + read -rt 120 -p "Choose a container by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } + if [[ $selection == 0 ]]; then + echo "Exiting.." + exit + elif ! echo -e "$cont_search}" | grep -qs ^"$selection)" ; then + echo "Error: \"$selection\" was not an option.. Try again" + sleep 3 + continue + else + break + fi + done + container=$(echo "$cont_search" | grep ^"$selection)" | awk '{print $2}') + container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') + ;; +esac + +# if [[ "${#containers[@]}" == 0 ]]; then +# echo -e "No containers available\nAre you sure the application in running?" +# exit +# elif [[ "${#containers[@]}" == 1 ]]; then +# container=$(echo "$search" | grep "${pod_id[*]}" | awk '{print $4}') +# container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') +# else +# while true +# do +# clear -x +# title +# cont_search=$( +# for i in "${containers[@]}" +# do +# echo "$i" +# done | nl -s ") " | column -t +# ) +# echo "$cont_search" +# echo +# echo "0) Exit" +# read -rt 120 -p "Choose a container by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } +# if [[ $selection == 0 ]]; then +# echo "Exiting.." +# exit +# elif ! echo -e "$cont_search}" | grep -qs ^"$selection)" ; then +# echo "Error: \"$selection\" was not an option.. Try again" +# sleep 3 +# continue +# else +# break +# fi +# done +# container=$(echo "$cont_search" | grep ^"$selection)" | awk '{print $2}') +# container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') +# fi while true do clear -x From fc8dba252a018873be44788081d734c254d88b6d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 17:47:37 -0600 Subject: [PATCH 120/218] remove commented out if statement --- functions/cmd_to_container.sh | 37 ----------------------------------- 1 file changed, 37 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 787b1c62..2d011172 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -29,7 +29,6 @@ for pod in "${pod_id[@]}" do containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}')") done - case "${#containers[@]}" in 0) echo -e "No containers available\nAre you sure the application in running?" @@ -70,42 +69,6 @@ case "${#containers[@]}" in container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') ;; esac - -# if [[ "${#containers[@]}" == 0 ]]; then -# echo -e "No containers available\nAre you sure the application in running?" -# exit -# elif [[ "${#containers[@]}" == 1 ]]; then -# container=$(echo "$search" | grep "${pod_id[*]}" | awk '{print $4}') -# container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') -# else -# while true -# do -# clear -x -# title -# cont_search=$( -# for i in "${containers[@]}" -# do -# echo "$i" -# done | nl -s ") " | column -t -# ) -# echo "$cont_search" -# echo -# echo "0) Exit" -# read -rt 120 -p "Choose a container by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } -# if [[ $selection == 0 ]]; then -# echo "Exiting.." -# exit -# elif ! echo -e "$cont_search}" | grep -qs ^"$selection)" ; then -# echo "Error: \"$selection\" was not an option.. Try again" -# sleep 3 -# continue -# else -# break -# fi -# done -# container=$(echo "$cont_search" | grep ^"$selection)" | awk '{print $2}') -# container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') -# fi while true do clear -x From 83e7657c37de4647a8d3be21e445f2c895a5181a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 17:50:39 -0600 Subject: [PATCH 121/218] increase timeout for command submission --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 2d011172..115ad619 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -89,7 +89,7 @@ do 1) clear -x title - read -rt 120 -p "What command do you want to run?: " command || { echo -e "\nFailed to make a selection in time" ; exit; } + read -rt 500 -p "What command do you want to run?: " command || { echo -e "\nFailed to make a selection in time" ; exit; } k3s crictl exec -it "$container_id" $command break ;; From e21736cb8b0e5d3171362139de8b82f311b9478b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 18:44:52 -0600 Subject: [PATCH 122/218] sleep 1.5 instead of 2 --- 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 74641ac9..44e78211 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -11,7 +11,7 @@ echo "Asynchronous Updates: $update_limit" # previous 20% 2 min 9 seconds it=0 -while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) > temp.txt +while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) echo "$while_status" > temp.txt rm trigger &>/dev/null while true @@ -34,7 +34,7 @@ do do update_apps "${array[$it]}" & processes+=($!) - sleep 2 + sleep 1.5 ((it++)) ((proc_count++)) done From 2e146d1e581db8e44181b1b254b3e19a4af37dc5 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 18:57:50 -0600 Subject: [PATCH 123/218] if status check times out, try again immediately --- functions/update_apps.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 44e78211..20095e28 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -17,8 +17,11 @@ rm trigger &>/dev/null while true do if [[ -f trigger ]]; then - while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) - echo "$while_status" > temp.txt + if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then + echo "$while_status" > temp.txt + else + continue + fi fi proc_count=${#processes[@]} count=0 From ffd23b7e154fc735e30ba31afeb52e13e6762508 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 19:05:10 -0600 Subject: [PATCH 124/218] set delay higher on trigger --- 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 20095e28..a2c78df3 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -14,9 +14,11 @@ it=0 while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) echo "$while_status" > temp.txt rm trigger &>/dev/null +delay=2 while true do if [[ -f trigger ]]; then + delay=4 if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then echo "$while_status" > temp.txt else @@ -31,7 +33,7 @@ do ((count++)) done if [[ "$proc_count" -ge "$update_limit" ]]; then - sleep 4 + sleep $delay elif [[ $it -lt ${#array[@]} ]]; then until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] do @@ -42,7 +44,7 @@ do ((proc_count++)) done elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish - sleep 4 + sleep $delay else # All processes must be completed, break out of loop break fi From 984b51e6b0a093398fab62c4103a2ec6dd6e6fd2 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 19:11:52 -0600 Subject: [PATCH 125/218] echo error on middleware timeout --- functions/update_apps.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index a2c78df3..cd2ea0b5 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -22,6 +22,7 @@ do if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then echo "$while_status" > temp.txt else + echo "Middlewared timed out. Consider setting a lower number for async applications" continue fi fi From 5511cbde46b7a5320be3574c560dc3557efb904e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 20:04:15 -0600 Subject: [PATCH 126/218] global sleep to 10, proper loop check for stopped --- functions/update_apps.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index cd2ea0b5..252158e8 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -172,19 +172,21 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') if [[ "$status" == "ACTIVE" ]]; then if [[ "$startstatus" == "STOPPED" ]]; then + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 10 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && sleep 10 && continue #if reports active on FIRST time through loop, double check [[ "$verbose" == "true" ]] && echo_array+=("Returing to STOPPED state..") midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null || { echo_array+=("Error: Failed to stop $app_name") ; break ; } echo_array+=("Stopped") break else - [[ "$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 + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 10 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && sleep 10 && 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. fi 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 + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 10 && continue #if reports stopped on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && sleep 10 && 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. elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then @@ -212,7 +214,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then fi else [[ "$verbose" == "true" ]] && echo_array+=("Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE") - sleep 15 + sleep 5 continue fi done From e57cb90642417e449a355a8cad3dd926f36f985b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 20:15:38 -0600 Subject: [PATCH 127/218] test --- functions/update_apps.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 252158e8..0a0c6bf0 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -172,21 +172,21 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') if [[ "$status" == "ACTIVE" ]]; then if [[ "$startstatus" == "STOPPED" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 10 && continue #if reports active on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 10 && 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_array+=("Returing to STOPPED state..") midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null || { echo_array+=("Error: Failed to stop $app_name") ; break ; } echo_array+=("Stopped") break else - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 10 && continue #if reports active on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 10 && 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_array+=("Active") break #if reports active any time after the first loop, assume actually active. fi elif [[ "$status" == "STOPPED" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 10 && continue #if reports stopped on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 10 && 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_array+=("Stopped") break #if reports stopped any time after the first loop, assume its extermal services. elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then From 83d65a2a8fbcea235b99ce05822d12b31e7a5502 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 20:23:03 -0600 Subject: [PATCH 128/218] replace manual counter with array 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 0a0c6bf0..2403ff2e 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -44,7 +44,7 @@ do ((it++)) ((proc_count++)) done - elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish + elif [[ ${#processes[@]} != 0 ]]; then # Wait for all processes to finish sleep $delay else # All processes must be completed, break out of loop break From 36002c59fbf75f821a4c755b01578faa04000fc8 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 20:36:24 -0600 Subject: [PATCH 129/218] once last check prior to exiting script --- 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 2403ff2e..d2a917ad 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -15,6 +15,7 @@ while_status=$(cli -m csv -c 'app chart_release query name,update_available,huma echo "$while_status" > temp.txt rm trigger &>/dev/null delay=2 +final_check=0 while true do if [[ -f trigger ]]; then @@ -44,9 +45,10 @@ do ((it++)) ((proc_count++)) done - elif [[ ${#processes[@]} != 0 ]]; then # Wait for all processes to finish + elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep $delay else # All processes must be completed, break out of loop + [[ $final_check == 0 ]] && ((final_check++)) && continue break fi done From 0ff74e42a7d27334aa1e7cab35cf635f0e37077d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 20:40:33 -0600 Subject: [PATCH 130/218] first app waits after trigger --- 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 d2a917ad..7e5ec6de 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -147,7 +147,7 @@ do update_avail=$(grep "^$app_name," temp.txt | awk -F ',' '{print $3}') if [[ $update_avail == "true" ]]; then if ! cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null ; then - [[ ! -e trigger ]] && touch trigger + [[ ! -e trigger ]] && touch trigger && sleep 10 sleep 6 ((count++)) continue @@ -167,7 +167,7 @@ after_update_actions(){ SECONDS=0 count=0 if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then - [[ ! -e trigger ]] && touch trigger + [[ ! -e trigger ]] && touch trigger && sleep 10 while true do (( count++ )) From 3e0ad6d18e88d8cfae44871982ef1b387805fa8f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 21:09:20 -0600 Subject: [PATCH 131/218] test new sleep. just racing --- functions/update_apps.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 7e5ec6de..aa885700 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -41,7 +41,7 @@ do do update_apps "${array[$it]}" & processes+=($!) - sleep 1.5 + # sleep 1.5 ((it++)) ((proc_count++)) done @@ -174,21 +174,21 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') if [[ "$status" == "ACTIVE" ]]; then if [[ "$startstatus" == "STOPPED" ]]; 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 + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 10 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && sleep 10 && continue #if reports active on FIRST time through loop, double check [[ "$verbose" == "true" ]] && echo_array+=("Returing to STOPPED state..") midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null || { echo_array+=("Error: Failed to stop $app_name") ; break ; } echo_array+=("Stopped") break else - [[ "$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 + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 10 && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && sleep 10 && 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. fi 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 + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 10 && continue #if reports stopped on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && sleep 10 && 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. elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then From 006d47503eec55c349730418ce40e0e8f076ee83 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 21:23:21 -0600 Subject: [PATCH 132/218] internal sleep 2 --- 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 aa885700..c69aa950 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -41,7 +41,7 @@ do do update_apps "${array[$it]}" & processes+=($!) - # sleep 1.5 + sleep 2 ((it++)) ((proc_count++)) done From 2bf137fbc55ba089c0a1f7f31aedde328c9294cd Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 21:37:29 -0600 Subject: [PATCH 133/218] longer sleep --- 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 c69aa950..1f78da16 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -41,7 +41,7 @@ do do update_apps "${array[$it]}" & processes+=($!) - sleep 2 + sleep 4 ((it++)) ((proc_count++)) done From 31285a8d68f20e4ded74586e93de63e964f7f418 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 21:46:08 -0600 Subject: [PATCH 134/218] revert to original method +2 at a time --- functions/update_apps.sh | 84 +++++++++++++++++++++++++++++----------- 1 file changed, 62 insertions(+), 22 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 1f78da16..05a2edec 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -10,23 +10,64 @@ echo "Asynchronous Updates: $update_limit" [[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips" # previous 20% 2 min 9 seconds -it=0 -while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) -echo "$while_status" > temp.txt -rm trigger &>/dev/null -delay=2 +# it=0 +# while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) +# echo "$while_status" > temp.txt +# rm trigger &>/dev/null +# delay=2 +# final_check=0 +# while true +# do +# if [[ -f trigger ]]; then +# delay=4 +# if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then +# echo "$while_status" > temp.txt +# else +# echo "Middlewared timed out. Consider setting a lower number for async applications" +# continue +# fi +# fi +# proc_count=${#processes[@]} +# count=0 +# 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 $delay +# elif [[ $it -lt ${#array[@]} ]]; then +# until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] +# do +# update_apps "${array[$it]}" & +# processes+=($!) +# sleep 4 +# ((it++)) +# ((proc_count++)) +# done +# elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish +# sleep $delay +# else # All processes must be completed, break out of loop +# [[ $final_check == 0 ]] && ((final_check++)) && continue +# break +# fi +# done +# rm temp.txt +# [[ -f trigger ]] && rm trigger +# echo +# echo + final_check=0 +it=0 while true do - if [[ -f trigger ]]; then - delay=4 - if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then - echo "$while_status" > temp.txt - else - echo "Middlewared timed out. Consider setting a lower number for async applications" - continue - fi + if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then + echo "$while_status" > temp.txt + else + echo "Middlewared timed out. Consider setting a lower number for async applications" + continue fi + echo "$while_status" > temp.txt proc_count=${#processes[@]} count=0 for proc in "${processes[@]}" @@ -35,27 +76,26 @@ do ((count++)) done if [[ "$proc_count" -ge "$update_limit" ]]; then - sleep $delay + sleep 3 elif [[ $it -lt ${#array[@]} ]]; then - until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] + until [[ "$proc_count" -ge 2 || $it -ge ${#array[@]} ]]; do update_apps "${array[$it]}" & processes+=($!) - sleep 4 - ((it++)) ((proc_count++)) + ((it++)) done elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish - sleep $delay + sleep 3 else # All processes must be completed, break out of loop [[ $final_check == 0 ]] && ((final_check++)) && continue break fi done rm temp.txt -[[ -f trigger ]] && rm trigger echo echo + } export -f commander @@ -99,7 +139,7 @@ if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #con [[ "$verbose" == "true" ]] && echo_array+=("Stopping prior to update..") midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null || echo_array+=("Error: Failed to stop $app_name") SECONDS=0 - [[ ! -e trigger ]] && touch trigger + # [[ ! -e trigger ]] && touch trigger while [[ "$status" != "STOPPED" ]] do status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') @@ -147,7 +187,7 @@ do update_avail=$(grep "^$app_name," temp.txt | awk -F ',' '{print $3}') if [[ $update_avail == "true" ]]; then if ! cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null ; then - [[ ! -e trigger ]] && touch trigger && sleep 10 + # [[ ! -e trigger ]] && touch trigger && sleep 10 sleep 6 ((count++)) continue @@ -167,7 +207,7 @@ after_update_actions(){ SECONDS=0 count=0 if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then - [[ ! -e trigger ]] && touch trigger && sleep 10 + # [[ ! -e trigger ]] && touch trigger && sleep 10 while true do (( count++ )) From eddf0937c440e8750be50bec09df5558bc142a37 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 21:50:32 -0600 Subject: [PATCH 135/218] give until loop its own variable.. --- 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 05a2edec..73f1b7b6 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -78,11 +78,12 @@ do if [[ "$proc_count" -ge "$update_limit" ]]; then sleep 3 elif [[ $it -lt ${#array[@]} ]]; then - until [[ "$proc_count" -ge 2 || $it -ge ${#array[@]} ]]; + loop=0 + until [[ "$loop" -ge 2 || $it -ge ${#array[@]} ]]; do update_apps "${array[$it]}" & processes+=($!) - ((proc_count++)) + ((loop++)) ((it++)) done elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish From b012416a07c4972b407a70392506b114b47605f9 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 22:04:33 -0600 Subject: [PATCH 136/218] test --- functions/update_apps.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 73f1b7b6..fc0bdae3 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -78,14 +78,14 @@ do if [[ "$proc_count" -ge "$update_limit" ]]; then sleep 3 elif [[ $it -lt ${#array[@]} ]]; then - loop=0 - until [[ "$loop" -ge 2 || $it -ge ${#array[@]} ]]; - do + # loop=0 + # until [[ "$loop" -ge 2 || $it -ge ${#array[@]} ]]; + # do update_apps "${array[$it]}" & processes+=($!) ((loop++)) ((it++)) - done + # done elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 3 else # All processes must be completed, break out of loop From 06bb4e569f6cc9b2e0fa8c6493deff9d03290501 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 22:14:30 -0600 Subject: [PATCH 137/218] racing --- functions/update_apps.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index fc0bdae3..45a24abc 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -57,7 +57,6 @@ echo "Asynchronous Updates: $update_limit" # echo # echo -final_check=0 it=0 while true do @@ -78,18 +77,17 @@ do if [[ "$proc_count" -ge "$update_limit" ]]; then sleep 3 elif [[ $it -lt ${#array[@]} ]]; then - # loop=0 - # until [[ "$loop" -ge 2 || $it -ge ${#array[@]} ]]; - # do + loop=0 + until [[ "$loop" -ge 2 || $it -ge ${#array[@]} ]]; + do update_apps "${array[$it]}" & processes+=($!) ((loop++)) ((it++)) - # done + done elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 3 else # All processes must be completed, break out of loop - [[ $final_check == 0 ]] && ((final_check++)) && continue break fi done From c7afe81a387d129c595936658583639fa8339479 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 22:26:39 -0600 Subject: [PATCH 138/218] add proc count to Until loop --- 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 45a24abc..afa35d51 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -78,11 +78,12 @@ do sleep 3 elif [[ $it -lt ${#array[@]} ]]; then loop=0 - until [[ "$loop" -ge 2 || $it -ge ${#array[@]} ]]; + until [[ $loop -ge 2 || $proc_count -ge $update_limit || $it -ge ${#array[@]} ]]; do update_apps "${array[$it]}" & processes+=($!) ((loop++)) + ((proc_count++)) ((it++)) done elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish From 8af787f2d4f77055bf91b3acfa5e000ee25249dd Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 22:27:49 -0600 Subject: [PATCH 139/218] revert, un-needed due to condition above it --- functions/update_apps.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index afa35d51..078b6cd8 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -78,12 +78,11 @@ do sleep 3 elif [[ $it -lt ${#array[@]} ]]; then loop=0 - until [[ $loop -ge 2 || $proc_count -ge $update_limit || $it -ge ${#array[@]} ]]; + until [[ $loop -ge 2 || $it -ge ${#array[@]} ]]; do update_apps "${array[$it]}" & processes+=($!) ((loop++)) - ((proc_count++)) ((it++)) done elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish From 116279db37b41b722c8c087724abe6c2f3dcb0b0 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 22:35:30 -0600 Subject: [PATCH 140/218] sticking to one at a time, anymore is overloading --- 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 078b6cd8..b5f08e75 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -77,14 +77,14 @@ do if [[ "$proc_count" -ge "$update_limit" ]]; then sleep 3 elif [[ $it -lt ${#array[@]} ]]; then - loop=0 - until [[ $loop -ge 2 || $it -ge ${#array[@]} ]]; - do - update_apps "${array[$it]}" & - processes+=($!) - ((loop++)) - ((it++)) - done + # loop=0 + # until [[ $loop -ge 2 || $it -ge ${#array[@]} ]]; + # do + update_apps "${array[$it]}" & + processes+=($!) + ((loop++)) + ((it++)) + # done elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 3 else # All processes must be completed, break out of loop From 4f944a62997eac30b9fa0ac4160c1763b9c75735 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 22:50:44 -0600 Subject: [PATCH 141/218] add count to the status file for cont change --- 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 b5f08e75..8397f580 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -61,7 +61,7 @@ it=0 while true do if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then - echo "$while_status" > temp.txt + echo -e "$it\n$while_status" > temp.txt else echo "Middlewared timed out. Consider setting a lower number for async applications" continue @@ -255,7 +255,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then fi else [[ "$verbose" == "true" ]] && echo_array+=("Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE") - sleep 5 + sleep 10 continue fi done From 54e4c3876e4ca7037511f8988ba4a5d9c49e7228 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 22:51:58 -0600 Subject: [PATCH 142/218] use its own count --- 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 8397f580..74012adc 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -58,10 +58,12 @@ echo "Asynchronous Updates: $update_limit" # echo it=0 +while_count=0 while true do if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then - echo -e "$it\n$while_status" > temp.txt + ((while_count++)) + echo -e "$while_count\n$while_status" > temp.txt else echo "Middlewared timed out. Consider setting a lower number for async applications" continue From 5edeb8c80bc1558c06f3757ba028dc0ed0accf59 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 22:55:20 -0600 Subject: [PATCH 143/218] count was not being appended --- 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 74012adc..4a241f64 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -63,7 +63,8 @@ while true do if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then ((while_count++)) - echo -e "$while_count\n$while_status" > temp.txt + echo "$while_status" > temp.txt + echo "$while_count" >> temp.txt else echo "Middlewared timed out. Consider setting a lower number for async applications" continue From 4e617893470473bac49f3fbe9fc4f2842c8d366d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 22:58:51 -0600 Subject: [PATCH 144/218] remove redundant creation --- functions/update_apps.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 4a241f64..95b9030a 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -63,13 +63,11 @@ while true do if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then ((while_count++)) - echo "$while_status" > temp.txt - echo "$while_count" >> temp.txt + echo -e "$while_count\n$while_status" > temp.txt else echo "Middlewared timed out. Consider setting a lower number for async applications" continue fi - echo "$while_status" > temp.txt proc_count=${#processes[@]} count=0 for proc in "${processes[@]}" From 5888efa3d7a62af7bffe75556b2d70749d3a2da7 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 23:27:11 -0600 Subject: [PATCH 145/218] wait for file change before continuing --- functions/update_apps.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 95b9030a..28801d9d 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -210,8 +210,18 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then # [[ ! -e trigger ]] && touch trigger && sleep 10 while true do - (( count++ )) + if [[ $count -lt 1 ]]; then + while_count=$(head -n 1 temp.txt) + else + until [[ $while_count -lt $current_count ]] # Wait for a change in the file BEFORE continuing + do + current_count=$(head -n 1 temp.txt) + sleep 2 + done + while_count=$current_count + fi status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') + (( count++ )) if [[ "$status" == "ACTIVE" ]]; then if [[ "$startstatus" == "STOPPED" ]]; then [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 10 && continue #if reports active on FIRST time through loop, double check From c1793c530691a2e6abd664a5f8bfa7ca9a079903 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 23:37:53 -0600 Subject: [PATCH 146/218] reduce sleep on file difference check --- 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 28801d9d..2c20ca27 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -216,7 +216,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then until [[ $while_count -lt $current_count ]] # Wait for a change in the file BEFORE continuing do current_count=$(head -n 1 temp.txt) - sleep 2 + sleep 1 done while_count=$current_count fi From c62da2c13dfaf614eb6b4b71399375ef15f253a7 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 23:41:20 -0600 Subject: [PATCH 147/218] attempt removal of status double checks --- functions/update_apps.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 2c20ca27..16a03446 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -224,21 +224,21 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then (( count++ )) if [[ "$status" == "ACTIVE" ]]; then if [[ "$startstatus" == "STOPPED" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 10 && continue #if reports active on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 10 && continue #if reports active on FIRST time through loop, double check + # [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 10 && continue #if reports active on FIRST time through loop, double check + # [[ "$count" -le 1 && -z "$verbose" ]] && sleep 10 && continue #if reports active on FIRST time through loop, double check [[ "$verbose" == "true" ]] && echo_array+=("Returing to STOPPED state..") midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null || { echo_array+=("Error: Failed to stop $app_name") ; break ; } echo_array+=("Stopped") break else - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 10 && continue #if reports active on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 10 && continue #if reports active on FIRST time through loop, double check + # [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 10 && continue #if reports active on FIRST time through loop, double check + # [[ "$count" -le 1 && -z "$verbose" ]] && sleep 10 && 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. fi elif [[ "$status" == "STOPPED" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 10 && continue #if reports stopped on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && sleep 10 && continue #if reports stopped on FIRST time through loop, double check + # [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 10 && continue #if reports stopped on FIRST time through loop, double check + # [[ "$count" -le 1 && -z "$verbose" ]] && sleep 10 && 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. elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then From f56b03c0ebd5c34c63a769f6f4161a88f09f80da Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 23:45:46 -0600 Subject: [PATCH 148/218] still need the counter. --- functions/update_apps.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 16a03446..4d69cb16 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -224,21 +224,21 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then (( count++ )) if [[ "$status" == "ACTIVE" ]]; then if [[ "$startstatus" == "STOPPED" ]]; then - # [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 10 && continue #if reports active on FIRST time through loop, double check - # [[ "$count" -le 1 && -z "$verbose" ]] && sleep 10 && 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_array+=("Returing to STOPPED state..") midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null || { echo_array+=("Error: Failed to stop $app_name") ; break ; } echo_array+=("Stopped") break else - # [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && sleep 10 && continue #if reports active on FIRST time through loop, double check - # [[ "$count" -le 1 && -z "$verbose" ]] && sleep 10 && 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_array+=("Active") break #if reports active any time after the first loop, assume actually active. fi elif [[ "$status" == "STOPPED" ]]; then - # [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && sleep 10 && continue #if reports stopped on FIRST time through loop, double check - # [[ "$count" -le 1 && -z "$verbose" ]] && sleep 10 && 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_array+=("Stopped") break #if reports stopped any time after the first loop, assume its extermal services. elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then From 850303e3287806c6d73a36561b871ef1c627033e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 23:55:45 -0600 Subject: [PATCH 149/218] try app specific status check instead of global --- functions/update_apps.sh | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 4d69cb16..946249ec 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -210,35 +210,46 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then # [[ ! -e trigger ]] && touch trigger && sleep 10 while true do - if [[ $count -lt 1 ]]; then - while_count=$(head -n 1 temp.txt) + if [[ $count -lt 1 ]]; then + old_status=$(grep "^$app_name," temp.txt) else - until [[ $while_count -lt $current_count ]] # Wait for a change in the file BEFORE continuing + until [[ "$new_status" != "$old_status" ]] # Wait for a change in the file BEFORE continuing do - current_count=$(head -n 1 temp.txt) + new_status=$(grep "^$app_name," temp.txt) sleep 1 done - while_count=$current_count + old_status=$new_status fi + + # if [[ $count -lt 1 ]]; then + # while_count=$(head -n 1 temp.txt) + # else + # until [[ $while_count -lt $current_count ]] # Wait for a change in the file BEFORE continuing + # do + # current_count=$(head -n 1 temp.txt) + # sleep 1 + # done + # while_count=$current_count + # fi status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') (( count++ )) if [[ "$status" == "ACTIVE" ]]; then if [[ "$startstatus" == "STOPPED" ]]; 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 + # [[ "$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_array+=("Returing to STOPPED state..") midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null || { echo_array+=("Error: Failed to stop $app_name") ; break ; } echo_array+=("Stopped") break else - [[ "$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 + # [[ "$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. fi 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 + # [[ "$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. elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then From bef42eaaebf704ad1cc8a54021d10c7c209f6523 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 11 Aug 2022 00:18:53 -0600 Subject: [PATCH 150/218] check for file changes and specific status --- functions/update_apps.sh | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 946249ec..bc44d24c 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -213,10 +213,15 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then if [[ $count -lt 1 ]]; then old_status=$(grep "^$app_name," temp.txt) else - until [[ "$new_status" != "$old_status" ]] # Wait for a change in the file BEFORE continuing + before_loop=$(head -n 1 temp.txt) + until [[ "$new_status" != "$old_status" || $current_loop -gt 3 ]] # Wait for a change in the file BEFORE continuing do new_status=$(grep "^$app_name," temp.txt) sleep 1 + if ! echo -e "$(head -n 1 temp.txt)" | grep -qs ^"$before_loop" ; then + before_loop=$(head -n 1 temp.txt) + ((current_loop++)) + fi done old_status=$new_status fi @@ -235,21 +240,21 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then (( count++ )) if [[ "$status" == "ACTIVE" ]]; then if [[ "$startstatus" == "STOPPED" ]]; 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 + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && continue #if reports active on FIRST time through loop, double check [[ "$verbose" == "true" ]] && echo_array+=("Returing to STOPPED state..") midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null || { echo_array+=("Error: Failed to stop $app_name") ; break ; } echo_array+=("Stopped") break else - # [[ "$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 + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && 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. fi 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 + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && continue #if reports stopped on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && 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. elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then From 06f0f7ea3aac75c4c53116794d4b1a6ff680cdc0 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 11 Aug 2022 01:48:31 -0600 Subject: [PATCH 151/218] fix status check --- functions/update_apps.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index bc44d24c..339fb7bf 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -214,6 +214,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then old_status=$(grep "^$app_name," temp.txt) else before_loop=$(head -n 1 temp.txt) + new_status=old_status until [[ "$new_status" != "$old_status" || $current_loop -gt 3 ]] # Wait for a change in the file BEFORE continuing do new_status=$(grep "^$app_name," temp.txt) From ec422e8db9e2e19226b34b067fd3d4508213e6bd Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 11 Aug 2022 01:50:41 -0600 Subject: [PATCH 152/218] assigned literal on accident.. --- 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 339fb7bf..f3734dc5 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -214,7 +214,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then old_status=$(grep "^$app_name," temp.txt) else before_loop=$(head -n 1 temp.txt) - new_status=old_status + new_status=$old_status until [[ "$new_status" != "$old_status" || $current_loop -gt 3 ]] # Wait for a change in the file BEFORE continuing do new_status=$(grep "^$app_name," temp.txt) From ea7a3e94907ff4f478d7021d0f44d0627aee7f3c Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 11 Aug 2022 16:37:19 -0600 Subject: [PATCH 153/218] remove commented stuff --- functions/update_apps.sh | 76 ++++------------------------------------ 1 file changed, 7 insertions(+), 69 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index f3734dc5..4cadd7f5 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -9,54 +9,6 @@ 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" -# previous 20% 2 min 9 seconds -# it=0 -# while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) -# echo "$while_status" > temp.txt -# rm trigger &>/dev/null -# delay=2 -# final_check=0 -# while true -# do -# if [[ -f trigger ]]; then -# delay=4 -# if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then -# echo "$while_status" > temp.txt -# else -# echo "Middlewared timed out. Consider setting a lower number for async applications" -# continue -# fi -# fi -# proc_count=${#processes[@]} -# count=0 -# 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 $delay -# elif [[ $it -lt ${#array[@]} ]]; then -# until [[ "$proc_count" -ge "$update_limit" || $it -ge ${#array[@]} ]] -# do -# update_apps "${array[$it]}" & -# processes+=($!) -# sleep 4 -# ((it++)) -# ((proc_count++)) -# done -# elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish -# sleep $delay -# else # All processes must be completed, break out of loop -# [[ $final_check == 0 ]] && ((final_check++)) && continue -# break -# fi -# done -# rm temp.txt -# [[ -f trigger ]] && rm trigger -# echo -# echo - it=0 while_count=0 while true @@ -83,8 +35,8 @@ do # do update_apps "${array[$it]}" & processes+=($!) - ((loop++)) ((it++)) + # ((loop++)) # done elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish sleep 3 @@ -182,12 +134,13 @@ export -f update_apps update(){ count=0 -while [[ $count -lt 3 ]] +while true do update_avail=$(grep "^$app_name," temp.txt | awk -F ',' '{print $3}') - if [[ $update_avail == "true" ]]; then + if [[ $count -gt 2 ]]; then + return 1 + elif [[ $update_avail == "true" ]]; then if ! cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null ; then - # [[ ! -e trigger ]] && touch trigger && sleep 10 sleep 6 ((count++)) continue @@ -195,9 +148,6 @@ do break elif [[ $update_avail == "false" ]]; then break - else - ((count++)) - sleep 6 fi done } @@ -207,15 +157,14 @@ after_update_actions(){ SECONDS=0 count=0 if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then - # [[ ! -e trigger ]] && touch trigger && sleep 10 while true do - if [[ $count -lt 1 ]]; then + if [[ $count -lt 1 ]]; then old_status=$(grep "^$app_name," temp.txt) else before_loop=$(head -n 1 temp.txt) new_status=$old_status - until [[ "$new_status" != "$old_status" || $current_loop -gt 3 ]] # Wait for a change in the file BEFORE continuing + until [[ "$new_status" != "$old_status" || $current_loop -gt 3 ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. do new_status=$(grep "^$app_name," temp.txt) sleep 1 @@ -226,17 +175,6 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then done old_status=$new_status fi - - # if [[ $count -lt 1 ]]; then - # while_count=$(head -n 1 temp.txt) - # else - # until [[ $while_count -lt $current_count ]] # Wait for a change in the file BEFORE continuing - # do - # current_count=$(head -n 1 temp.txt) - # sleep 1 - # done - # while_count=$current_count - # fi status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') (( count++ )) if [[ "$status" == "ACTIVE" ]]; then From 5d3470c2dd4b3cbb3c7404bc9fe87b06a3210eda Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 11 Aug 2022 20:30:49 -0600 Subject: [PATCH 154/218] loop on update failure --- functions/update_apps.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 4cadd7f5..4ec0713a 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -141,9 +141,19 @@ do return 1 elif [[ $update_avail == "true" ]]; then if ! cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null ; then - sleep 6 - ((count++)) - continue + # sleep 6 + # ((count++)) + # continue + before_loop=$(head -n 1 temp.txt) + current_loop=0 + until [[ "$(grep "^$app_name," temp.txt | awk -F ',' '{print $3}')" != "$update_avail" || $current_loop -gt 3 ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. + do + sleep 1 + if ! echo -e "$(head -n 1 temp.txt)" | grep -qs ^"$before_loop" ; then + before_loop=$(head -n 1 temp.txt) + ((current_loop++)) + fi + done fi break elif [[ $update_avail == "false" ]]; then @@ -164,6 +174,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then else before_loop=$(head -n 1 temp.txt) new_status=$old_status + current_loop=0 until [[ "$new_status" != "$old_status" || $current_loop -gt 3 ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. do new_status=$(grep "^$app_name," temp.txt) From e2942dd6264fe2a9eed8a94fd0f5fd0aff1f1a93 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 11 Aug 2022 20:41:31 -0600 Subject: [PATCH 155/218] update update function --- functions/update_apps.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 4ec0713a..b87e8a18 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -137,27 +137,31 @@ count=0 while true do update_avail=$(grep "^$app_name," temp.txt | awk -F ',' '{print $3}') - if [[ $count -gt 2 ]]; then - return 1 - elif [[ $update_avail == "true" ]]; then + # if [[ $count -gt 2 ]]; then + # return 1 + if [[ $update_avail == "true" ]]; then if ! cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null ; then # sleep 6 # ((count++)) # continue before_loop=$(head -n 1 temp.txt) current_loop=0 - until [[ "$(grep "^$app_name," temp.txt | awk -F ',' '{print $3}')" != "$update_avail" || $current_loop -gt 3 ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. + until [[ "$(grep "^$app_name," temp.txt | awk -F ',' '{print $3}')" != "$update_avail" ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. do - sleep 1 - if ! echo -e "$(head -n 1 temp.txt)" | grep -qs ^"$before_loop" ; then + if [[ $current_loop -gt 3 ]]; then + return 1 #App failed to update, return error code to update_apps func + elif ! echo -e "$(head -n 1 temp.txt)" | grep -qs ^"$before_loop" ; then # The file has been updated, but nothing changed specifically for the app. before_loop=$(head -n 1 temp.txt) ((current_loop++)) fi + sleep 1 done fi break elif [[ $update_avail == "false" ]]; then break + else + sleep 3 fi done } From d926bf938d46d164e708473801a6019d11223363 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 11 Aug 2022 20:51:42 -0600 Subject: [PATCH 156/218] only enter loop if status is not deploying --- 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 b87e8a18..99d169fa 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -175,7 +175,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then do if [[ $count -lt 1 ]]; then old_status=$(grep "^$app_name," temp.txt) - else + elif [[ $status != "DEPLOYING" ]]; then before_loop=$(head -n 1 temp.txt) new_status=$old_status current_loop=0 From 1473a969e275e6557329cce1f64a0ebf14fcd782 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 11 Aug 2022 20:55:37 -0600 Subject: [PATCH 157/218] change status to activity specific --- 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 99d169fa..7427fcfc 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -173,15 +173,16 @@ count=0 if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then while true do + status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') if [[ $count -lt 1 ]]; then - old_status=$(grep "^$app_name," temp.txt) + old_status=$status elif [[ $status != "DEPLOYING" ]]; then before_loop=$(head -n 1 temp.txt) new_status=$old_status current_loop=0 until [[ "$new_status" != "$old_status" || $current_loop -gt 3 ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. do - new_status=$(grep "^$app_name," temp.txt) + new_status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') sleep 1 if ! echo -e "$(head -n 1 temp.txt)" | grep -qs ^"$before_loop" ; then before_loop=$(head -n 1 temp.txt) @@ -190,7 +191,6 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then done old_status=$new_status fi - status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') (( count++ )) if [[ "$status" == "ACTIVE" ]]; then if [[ "$startstatus" == "STOPPED" ]]; then From 99dc8fcef83d2a55368b1850b8af9f3bd79dff9f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 11 Aug 2022 21:20:04 -0600 Subject: [PATCH 158/218] use bool to only verify if active/stopped 1st time --- 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 7427fcfc..b5844fa0 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -176,7 +176,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') if [[ $count -lt 1 ]]; then old_status=$status - elif [[ $status != "DEPLOYING" ]]; then + elif [[ $verify == "true" ]]; then before_loop=$(head -n 1 temp.txt) new_status=$old_status current_loop=0 @@ -194,21 +194,21 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then (( count++ )) if [[ "$status" == "ACTIVE" ]]; then if [[ "$startstatus" == "STOPPED" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && continue #if reports active on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && verify="true" && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && verify="true" && continue #if reports active on FIRST time through loop, double check [[ "$verbose" == "true" ]] && echo_array+=("Returing to STOPPED state..") midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null || { echo_array+=("Error: Failed to stop $app_name") ; break ; } echo_array+=("Stopped") break else - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && continue #if reports active on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && verify="true" && continue #if reports active on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && verify="true" && 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. fi elif [[ "$status" == "STOPPED" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Stopped..") && continue #if reports stopped on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && continue #if reports stopped on FIRST time through loop, double check + [[ "$count" -le 1 && "$verbose" == "true" ]] && verify="true" && echo_array+=("Verifying Stopped..") && continue #if reports stopped on FIRST time through loop, double check + [[ "$count" -le 1 && -z "$verbose" ]] && verify="true" && 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. elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then @@ -236,7 +236,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then fi else [[ "$verbose" == "true" ]] && echo_array+=("Waiting $((timeout-SECONDS)) more seconds for $app_name to be ACTIVE") - sleep 10 + sleep 5 continue fi done From 97896b27a2aac9362b7a1690d921af8df2ac1752 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 11 Aug 2022 21:37:38 -0600 Subject: [PATCH 159/218] status check when leaving verify --- functions/update_apps.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index b5844fa0..766ace10 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -190,6 +190,8 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then fi done old_status=$new_status + status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') + unset verify fi (( count++ )) if [[ "$status" == "ACTIVE" ]]; then From 61eea4c9a5f25fc72607ebda2ac51445de300a83 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 11 Aug 2022 21:43:15 -0600 Subject: [PATCH 160/218] remove newstatus variable, just use status instead --- functions/update_apps.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 766ace10..ec807f5d 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -178,19 +178,16 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then old_status=$status elif [[ $verify == "true" ]]; then before_loop=$(head -n 1 temp.txt) - new_status=$old_status current_loop=0 - until [[ "$new_status" != "$old_status" || $current_loop -gt 3 ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. + until [[ "$status" != "$old_status" || $current_loop -gt 3 ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. do - new_status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') + status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') sleep 1 if ! echo -e "$(head -n 1 temp.txt)" | grep -qs ^"$before_loop" ; then before_loop=$(head -n 1 temp.txt) ((current_loop++)) fi done - old_status=$new_status - status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') unset verify fi (( count++ )) From 653e54804ad31db04280ad9136e1d3d9321e3c7b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 11 Aug 2022 21:55:09 -0600 Subject: [PATCH 161/218] testing update function --- 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 ec807f5d..82f4fe7d 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -133,7 +133,7 @@ export -f update_apps update(){ -count=0 +# count=0 while true do update_avail=$(grep "^$app_name," temp.txt | awk -F ',' '{print $3}') From c45bf0a5887477ac35ccf63b07285d4ba1d3c8d2 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 11 Aug 2022 22:15:17 -0600 Subject: [PATCH 162/218] add trigger for debugging --- functions/update_apps.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 82f4fe7d..00a1c32f 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -141,6 +141,7 @@ do # return 1 if [[ $update_avail == "true" ]]; then if ! cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null ; then + echo "Fail Trigger - Debugging" # sleep 6 # ((count++)) # continue From 4469d96cb69ea97157094b1d3e47db4d95c74788 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 11 Aug 2022 22:42:43 -0600 Subject: [PATCH 163/218] if while status is empty.. call again --- 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 00a1c32f..0aaea2e2 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -14,8 +14,8 @@ while_count=0 while true do if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then - ((while_count++)) - echo -e "$while_count\n$while_status" > temp.txt + ((while_count++)) + [[ -z $while_status ]] && continue || echo -e "$while_count\n$while_status" > temp.txt else echo "Middlewared timed out. Consider setting a lower number for async applications" continue From 3f5d8d4c734d10c58c5a7d8c5ab1ce77b5be9e63 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 11 Aug 2022 22:52:45 -0600 Subject: [PATCH 164/218] attempt second update, if while_status empty, skip --- 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 0aaea2e2..cf0b6f77 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -150,7 +150,7 @@ do until [[ "$(grep "^$app_name," temp.txt | awk -F ',' '{print $3}')" != "$update_avail" ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. do if [[ $current_loop -gt 3 ]]; then - return 1 #App failed to update, return error code to update_apps func + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null || return 1 # After waiting, attempt an update once more, if fails, return error code elif ! echo -e "$(head -n 1 temp.txt)" | grep -qs ^"$before_loop" ; then # The file has been updated, but nothing changed specifically for the app. before_loop=$(head -n 1 temp.txt) ((current_loop++)) From 592b739bf06d0fd2862c7e35480283668bd2ae04 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 06:37:30 -0600 Subject: [PATCH 165/218] stop app to cli rather than midctl, wait for compl --- functions/update_apps.sh | 71 +++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 33 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index cf0b6f77..12c5543e 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -89,29 +89,12 @@ if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #con 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..") - midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null || echo_array+=("Error: Failed to stop $app_name") - SECONDS=0 - # [[ ! -e trigger ]] && touch trigger - while [[ "$status" != "STOPPED" ]] - do - status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') - if [[ "$status" == "STOPPED" ]]; then - echo_array+=("Stopped") - [[ "$verbose" == "true" ]] && echo_array+=("Updating..") - if update ;then - echo_array+=("Updated\n$old_full_ver\n$new_full_ver") - else - echo_array+=("Failed to update") - return - fi - elif [[ "$SECONDS" -ge "$timeout" ]]; then - echo_array+=("Error: Run Time($SECONDS) has exceeded Timeout($timeout)") - break - elif [[ "$status" != "STOPPED" ]]; then - [[ "$verbose" == "true" ]] && echo_array+=("Waiting $((timeout-SECONDS)) more seconds for $app_name to be STOPPED") - sleep 5 - fi - done + if stop_app ; then + echo_array+=("Stopped") + else + echo_array+=("Error: Failed to stop $app_name") + return 1 + fi fi else #user must not be using -S, just update echo_array+=("\n$app_name") @@ -133,23 +116,18 @@ export -f update_apps update(){ -# count=0 +current_loop=0 while true do update_avail=$(grep "^$app_name," temp.txt | awk -F ',' '{print $3}') - # if [[ $count -gt 2 ]]; then - # return 1 if [[ $update_avail == "true" ]]; then if ! cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null ; then echo "Fail Trigger - Debugging" - # sleep 6 - # ((count++)) - # continue before_loop=$(head -n 1 temp.txt) current_loop=0 until [[ "$(grep "^$app_name," temp.txt | awk -F ',' '{print $3}')" != "$update_avail" ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. do - if [[ $current_loop -gt 3 ]]; then + if [[ $current_loop -gt 2 ]]; then cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null || return 1 # After waiting, attempt an update once more, if fails, return error code elif ! echo -e "$(head -n 1 temp.txt)" | grep -qs ^"$before_loop" ; then # The file has been updated, but nothing changed specifically for the app. before_loop=$(head -n 1 temp.txt) @@ -168,6 +146,29 @@ done } export -f update +stop_app(){ +count=0 +while [[ "$status" != "STOPPED" ]] +do + status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') + if [[ $count -gt 2 ]]; then # If failed to stop app 3 times, return failure to parent shell + return 1 + elif ! cli -c 'app chart_release scale release_name='\""$app_name"\"\ 'scale_options={"replica_count": 0}' &> /dev/null ; then + echo "Fail Trigger Stop - Debugging" + before_loop=$(head -n 1 temp.txt) + ((count++)) + until [[ $(head -n 1 temp.txt) != "$before_loop" ]] # Upon failure, wait for status update before continuing + do + sleep 1 + done + else + break + fi +done +} +export -f stop_app + + after_update_actions(){ SECONDS=0 count=0 @@ -197,8 +198,12 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && verify="true" && continue #if reports active on FIRST time through loop, double check [[ "$count" -le 1 && -z "$verbose" ]] && verify="true" && continue #if reports active on FIRST time through loop, double check [[ "$verbose" == "true" ]] && echo_array+=("Returing to STOPPED state..") - midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null || { echo_array+=("Error: Failed to stop $app_name") ; break ; } - echo_array+=("Stopped") + if stop_app ; then + echo_array+=("Stopped") + else + echo_array+=("Error: Failed to stop $app_name") + return 1 + fi break else [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && verify="true" && continue #if reports active on FIRST time through loop, double check @@ -249,4 +254,4 @@ do echo -e "$i" done } -export -f after_update_actions \ No newline at end of file +export -f after_update_actions From 7c7f42b9cb0348e35f602def497b9ea462760c05 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 06:53:35 -0600 Subject: [PATCH 166/218] always update prior to a_u_a --- functions/update_apps.sh | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 12c5543e..987dad83 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -79,13 +79,6 @@ if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #con 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 echo_array+=("\n$app_name") - [[ "$verbose" == "true" ]] && echo_array+=("Updating..") - if update ;then - echo_array+=("Updated\n$old_full_ver\n$new_full_ver") - else - echo_array+=("Failed to update") - return - fi 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..") @@ -98,18 +91,18 @@ if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #con fi else #user must not be using -S, just update echo_array+=("\n$app_name") - [[ "$verbose" == "true" ]] && echo_array+=("Updating..") - if update ;then - echo_array+=("Updated\n$old_full_ver\n$new_full_ver") - else - echo_array+=("Failed to update") - return - fi fi else echo -e "\n$app_name\nMajor Release, update manually" return 0 fi +[[ "$verbose" == "true" ]] && echo_array+=("Updating..") +if update ;then + echo_array+=("Updated\n$old_full_ver\n$new_full_ver") +else + echo_array+=("Failed to update") +return +fi after_update_actions } export -f update_apps From 714842a33f5d5a058a81b1accf365f181deb623f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 07:33:13 -0600 Subject: [PATCH 167/218] clean-up after_update_actions --- functions/update_apps.sh | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 987dad83..45f84f87 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -169,9 +169,9 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then while true do status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') - if [[ $count -lt 1 ]]; then + if [[ $count -lt 1 && $status != "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..") old_status=$status - elif [[ $verify == "true" ]]; then before_loop=$(head -n 1 temp.txt) current_loop=0 until [[ "$status" != "$old_status" || $current_loop -gt 3 ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. @@ -183,13 +183,10 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then ((current_loop++)) fi done - unset verify fi (( count++ )) if [[ "$status" == "ACTIVE" ]]; then if [[ "$startstatus" == "STOPPED" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && verify="true" && continue #if reports active on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && verify="true" && continue #if reports active on FIRST time through loop, double check [[ "$verbose" == "true" ]] && echo_array+=("Returing to STOPPED state..") if stop_app ; then echo_array+=("Stopped") @@ -199,16 +196,12 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then fi break else - [[ "$count" -le 1 && "$verbose" == "true" ]] && echo_array+=("Verifying Active..") && verify="true" && continue #if reports active on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && verify="true" && 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. + break fi elif [[ "$status" == "STOPPED" ]]; then - [[ "$count" -le 1 && "$verbose" == "true" ]] && verify="true" && echo_array+=("Verifying Stopped..") && continue #if reports stopped on FIRST time through loop, double check - [[ "$count" -le 1 && -z "$verbose" ]] && verify="true" && 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. + break elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then if [[ $rollback == "true" ]]; then if [[ "$failed" != "true" ]]; then From 0fbe428507e09e01771eba53cd14b3c1bfa64915 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 07:53:58 -0600 Subject: [PATCH 168/218] fix deploying comparison --- 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 45f84f87..afedf65a 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -169,7 +169,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then while true do status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') - if [[ $count -lt 1 && $status != "Deploying" ]]; then # If status shows up as Active or Stopped on the first check, verify that. Otherwise it may be a false report.. + if [[ $count -lt 1 && $status != "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..") old_status=$status before_loop=$(head -n 1 temp.txt) From 7f6018b5d591ff443bf5116f1d8ccd6ec601305b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 08:10:15 -0600 Subject: [PATCH 169/218] cmd to container regex --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 115ad619..d0a6c47b 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -23,7 +23,7 @@ do fi done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') -search=$(k3s crictl ps -a -s running | sed -E 's/([0-9]*|About)[[:space:]][a-z]{2,5}[[:space:]](hour)?[[:space:]]?ago//') +search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0-9 ]{5,12}ago[[:space:]]//') mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') for pod in "${pod_id[@]}" do From a03598b1b7f45abd3072f8ad733f8e90a2b5cb8f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 09:13:37 -0600 Subject: [PATCH 170/218] do not add duplicate containers --- functions/cmd_to_container.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index d0a6c47b..277da7bb 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -27,6 +27,7 @@ search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0- mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') for pod in "${pod_id[@]}" do + printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}')" && continue containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}')") done case "${#containers[@]}" in From 7cbcf11fb2c6a9cdadeaa678175f4e969c7abee1 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 09:22:00 -0600 Subject: [PATCH 171/218] try different method for rm-ing dupes --- functions/cmd_to_container.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 277da7bb..a4748c07 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -27,9 +27,9 @@ search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0- mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') for pod in "${pod_id[@]}" do - printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}')" && continue - containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}')") + containers_temp+=("$(echo "$search" | grep "$pod" | awk '{print $4}')") done +containers=(); while IFS= read -r -d '' x; do containers+=("$x"); done < <(printf "%s\0" "${containers_temp[@]}" | sort -uz) case "${#containers[@]}" in 0) echo -e "No containers available\nAre you sure the application in running?" From cc8a0d370805b067610284f0543bfca09b6ef53d Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 09:26:34 -0600 Subject: [PATCH 172/218] 3rd attempt --- functions/cmd_to_container.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index a4748c07..695c73ea 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -27,9 +27,9 @@ search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0- mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') for pod in "${pod_id[@]}" do - containers_temp+=("$(echo "$search" | grep "$pod" | awk '{print $4}')") + containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}')") done -containers=(); while IFS= read -r -d '' x; do containers+=("$x"); done < <(printf "%s\0" "${containers_temp[@]}" | sort -uz) +# containers=(); while IFS= read -r -d '' x; do containers+=("$x"); done < <(printf "%s\0" "${containers_temp[@]}" | sort -uz) case "${#containers[@]}" in 0) echo -e "No containers available\nAre you sure the application in running?" @@ -49,7 +49,7 @@ case "${#containers[@]}" in for i in "${containers[@]}" do echo "$i" - done | nl -s ") " | column -t + done | uniq | nl -s ") " | column -t ) echo "$cont_search" echo From 60418e846b738033b62f7875df8251d3315830ec Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 09:36:07 -0600 Subject: [PATCH 173/218] test --- functions/cmd_to_container.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 695c73ea..b2eda4cb 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -27,9 +27,9 @@ search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0- mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') for pod in "${pod_id[@]}" do - containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}')") + printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue + containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")") done -# containers=(); while IFS= read -r -d '' x; do containers+=("$x"); done < <(printf "%s\0" "${containers_temp[@]}" | sort -uz) case "${#containers[@]}" in 0) echo -e "No containers available\nAre you sure the application in running?" @@ -49,7 +49,7 @@ case "${#containers[@]}" in for i in "${containers[@]}" do echo "$i" - done | uniq | nl -s ") " | column -t + done | nl -s ") " | column -t ) echo "$cont_search" echo From 80d10a5df22d3b180a66367ecb8a44f5c9078f3e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 09:47:35 -0600 Subject: [PATCH 174/218] debugging --- functions/cmd_to_container.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index b2eda4cb..3b7fc50d 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -29,6 +29,7 @@ for pod in "${pod_id[@]}" do printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")") + echo "ADDED" "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" done case "${#containers[@]}" in 0) From b0a4119df0f4437811ef245233986f0c66b96acf Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 09:49:26 -0600 Subject: [PATCH 175/218] set array to 0 --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 3b7fc50d..b2938c9a 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -37,7 +37,7 @@ case "${#containers[@]}" in exit ;; 1) - container=$(echo "$search" | grep "${pod_id[*]}" | awk '{print $4}') + container=$(echo "$search" | grep "${pod_id[0]}" | awk '{print $4}') container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') ;; From 61e46514d9e3bcd35e0ed41e19ee375bfb3444ca Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 09:51:06 -0600 Subject: [PATCH 176/218] use 0 element in array if 0-1 are equal --- functions/cmd_to_container.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index b2938c9a..6e7be5d7 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -27,9 +27,8 @@ search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0- mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') for pod in "${pod_id[@]}" do - printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue - containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")") - echo "ADDED" "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" + printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}')" && continue + containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}')") done case "${#containers[@]}" in 0) From 3b90402416a1719c660396fc06d415c42ce5668f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 09:54:59 -0600 Subject: [PATCH 177/218] test --- functions/cmd_to_container.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 6e7be5d7..43d2b8a7 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -27,8 +27,8 @@ search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0- mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') for pod in "${pod_id[@]}" do - printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}')" && continue - containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}')") + printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue + containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")") done case "${#containers[@]}" in 0) From fc785b71b5102cada0a09ae7e7799429adcfb9dc Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 09:59:56 -0600 Subject: [PATCH 178/218] test rebuild --- functions/cmd_to_container.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 43d2b8a7..16d8f5a5 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -27,9 +27,10 @@ search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0- mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') for pod in "${pod_id[@]}" do - printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue - containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")") + printf '%s\0' "${containers_temp[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue + containers_temp+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")") done +containers=(); while IFS= read -r -d '' x; do containers+=("$x"); done < <(printf "%s\0" "${containers_temp[@]}" | sort -uz) case "${#containers[@]}" in 0) echo -e "No containers available\nAre you sure the application in running?" From 6aa4458b1402e5ac5dc48c4b08a87e2891e97299 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 10:07:33 -0600 Subject: [PATCH 179/218] test --- functions/cmd_to_container.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 16d8f5a5..35f045b6 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -27,10 +27,14 @@ search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0- mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') for pod in "${pod_id[@]}" do - printf '%s\0' "${containers_temp[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue - containers_temp+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")") + if [[ $(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r " | wc -l) -gt 1 ]]; then + readarray -t containers <<<"$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" + continue + fi + printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue + containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")") + done -containers=(); while IFS= read -r -d '' x; do containers+=("$x"); done < <(printf "%s\0" "${containers_temp[@]}" | sort -uz) case "${#containers[@]}" in 0) echo -e "No containers available\nAre you sure the application in running?" From dc51517ccb34d1cb10eadaed3c0c7a2abef65001 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 10:09:20 -0600 Subject: [PATCH 180/218] test --- functions/cmd_to_container.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 35f045b6..7be74b0b 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -27,12 +27,13 @@ search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0- mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') for pod in "${pod_id[@]}" do - if [[ $(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r " | wc -l) -gt 1 ]]; then - readarray -t containers <<<"$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" - continue - fi printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue - containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")") + # if [[ $(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r " | wc -l) -gt 1 ]]; then + readarray -t containers <<<"$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" + # continue + # fi + + # containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")") done case "${#containers[@]}" in From 4294a1565fc7316a64025a0052ec8040fffe36a7 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 10:10:32 -0600 Subject: [PATCH 181/218] revert --- functions/cmd_to_container.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 7be74b0b..35f045b6 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -27,13 +27,12 @@ search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0- mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') for pod in "${pod_id[@]}" do - printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue - # if [[ $(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r " | wc -l) -gt 1 ]]; then + if [[ $(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r " | wc -l) -gt 1 ]]; then readarray -t containers <<<"$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" - # continue - # fi - - # containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")") + continue + fi + printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue + containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")") done case "${#containers[@]}" in From c528757b887f23ffe2959ca933bc27575e3ef105 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 10:33:54 -0600 Subject: [PATCH 182/218] simplification of update_apps --- functions/update_apps.sh | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index afedf65a..ef554b5b 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -33,7 +33,7 @@ do # loop=0 # until [[ $loop -ge 2 || $it -ge ${#array[@]} ]]; # do - update_apps "${array[$it]}" & + pre_process "${array[$it]}" & processes+=($!) ((it++)) # ((loop++)) @@ -52,7 +52,7 @@ echo export -f commander -update_apps(){ +pre_process(){ 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 @@ -76,28 +76,23 @@ if grep -qs "^$app_name," failed.txt ; then fi fi 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 - echo_array+=("\n$app_name") - 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..") - if stop_app ; then - echo_array+=("Stopped") - else - echo_array+=("Error: Failed to stop $app_name") - return 1 - fi - fi - else #user must not be using -S, just update + if [[ $stop_before_update == "true" && "$startstatus" != "STOPPED" ]]; then # Check to see if user is using -S or not echo_array+=("\n$app_name") + [[ "$verbose" == "true" ]] && echo_array+=("Stopping prior to update..") + if stop_app ; then + echo_array+=("Stopped") + else + echo_array+=("Error: Failed to stop $app_name") + return 1 + fi fi else echo -e "\n$app_name\nMajor Release, update manually" return 0 fi +[[ ! $stop_before_update == "true" && "$startstatus" != "STOPPED" ]] && echo_array+=("\n$app_name") [[ "$verbose" == "true" ]] && echo_array+=("Updating..") -if update ;then +if update_app ;then echo_array+=("Updated\n$old_full_ver\n$new_full_ver") else echo_array+=("Failed to update") @@ -105,10 +100,10 @@ return fi after_update_actions } -export -f update_apps +export -f pre_process -update(){ +update_app(){ current_loop=0 while true do @@ -137,7 +132,7 @@ do fi done } -export -f update +export -f update_app stop_app(){ count=0 From bb50772fc2403f2d43a1bce45cf5571d931bb12f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 10:44:32 -0600 Subject: [PATCH 183/218] re-arrange echo array --- 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 ef554b5b..2807098f 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -75,9 +75,9 @@ if grep -qs "^$app_name," failed.txt ; then sed -i /"$app_name",/d failed.txt fi fi -if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update +echo_array+=("\n$app_name") +if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #Check for major versions or -U if [[ $stop_before_update == "true" && "$startstatus" != "STOPPED" ]]; then # Check to see if user is using -S or not - echo_array+=("\n$app_name") [[ "$verbose" == "true" ]] && echo_array+=("Stopping prior to update..") if stop_app ; then echo_array+=("Stopped") @@ -90,7 +90,6 @@ else echo -e "\n$app_name\nMajor Release, update manually" return 0 fi -[[ ! $stop_before_update == "true" && "$startstatus" != "STOPPED" ]] && echo_array+=("\n$app_name") [[ "$verbose" == "true" ]] && echo_array+=("Updating..") if update_app ;then echo_array+=("Updated\n$old_full_ver\n$new_full_ver") From edf40ced53c450332960a8fc43e66a6b2117667e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 11:08:51 -0600 Subject: [PATCH 184/218] echo array to function to control output better --- functions/update_apps.sh | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 2807098f..6846ed97 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -62,6 +62,7 @@ new_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{pr 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 +[[ "$diff_app" != "$diff_chart" ]] && echo -e "\n$app_name\nMajor Release, update manually" && return 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}') @@ -76,26 +77,23 @@ if grep -qs "^$app_name," failed.txt ; then fi fi echo_array+=("\n$app_name") -if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #Check for major versions or -U - if [[ $stop_before_update == "true" && "$startstatus" != "STOPPED" ]]; then # Check to see if user is using -S or not - [[ "$verbose" == "true" ]] && echo_array+=("Stopping prior to update..") - if stop_app ; then - echo_array+=("Stopped") - else - echo_array+=("Error: Failed to stop $app_name") - return 1 - fi +if [[ $stop_before_update == "true" && "$startstatus" != "STOPPED" ]]; then # Check to see if user is using -S or not + [[ "$verbose" == "true" ]] && echo_array+=("Stopping prior to update..") + if stop_app ; then + echo_array+=("Stopped") + else + echo_array+=("Error: Failed to stop $app_name") + echo_array + return 1 fi -else - echo -e "\n$app_name\nMajor Release, update manually" - return 0 fi [[ "$verbose" == "true" ]] && echo_array+=("Updating..") if update_app ;then echo_array+=("Updated\n$old_full_ver\n$new_full_ver") else echo_array+=("Failed to update") -return + echo_array + return fi after_update_actions } @@ -186,6 +184,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then echo_array+=("Stopped") else echo_array+=("Error: Failed to stop $app_name") + echo_array return 1 fi break @@ -226,12 +225,17 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then fi done fi +echo_array +} +export -f after_update_actions +echo_array(){ #Dump the echo_array, ensures all output is in a neat order. for i in "${echo_array[@]}" do echo -e "$i" done + } -export -f after_update_actions +export -f echo_array From 0a9d157821b70147414187c11be6602426c9db5e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 13 Aug 2022 00:35:24 -0600 Subject: [PATCH 185/218] limit major check to only -u not -U --- 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 6846ed97..2435b449 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -62,7 +62,7 @@ new_chart_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}' | awk -F '_' '{pr 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 -[[ "$diff_app" != "$diff_chart" ]] && echo -e "\n$app_name\nMajor Release, update manually" && return +[[ "$diff_app" != "$diff_chart" && $update_apps == "true" ]] && echo -e "\n$app_name\nMajor Release, update manually" && return 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}') From ad4b9b24617110c6903a483e63feb2a6d4ffe195 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 13 Aug 2022 10:37:48 -0600 Subject: [PATCH 186/218] test ext service --- functions/update_apps.sh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 2435b449..8d89fac5 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -8,6 +8,7 @@ echo -e "🅄 🄿 🄳 🄰 🅃 🄴 🅂" 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" +pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{print $3}' | awk -F '/' '{print $1}' | tr -d " \t\n\r") it=0 while_count=0 @@ -76,6 +77,21 @@ if grep -qs "^$app_name," failed.txt ; then sed -i /"$app_name",/d failed.txt fi fi + + +[[ ! -e external_services ]] && touch external_services + +if ! grep -qs "^$app_name," external_services ; then + if ! grep qs "/external-service" /mnt/"$pool"/ix-applications/releases/"$app_name"/charts/"$(find . -maxdepth 1 -type d -printf '%P\n' | sort -r | head -n 1)"/Chart.yaml ; then + echo "$app_name,false" >> external_services + else + echo "$app_name,true" >> external_services + fi +fi + + + + echo_array+=("\n$app_name") if [[ $stop_before_update == "true" && "$startstatus" != "STOPPED" ]]; then # Check to see if user is using -S or not [[ "$verbose" == "true" ]] && echo_array+=("Stopping prior to update..") @@ -166,7 +182,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then old_status=$status before_loop=$(head -n 1 temp.txt) current_loop=0 - until [[ "$status" != "$old_status" || $current_loop -gt 3 ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. + until [[ "$status" != "$old_status" || $current_loop -gt 4 ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. do status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') sleep 1 From d6f95fa76b3e4e3cf23ac8452029f7ffe570aaf2 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 13 Aug 2022 10:41:35 -0600 Subject: [PATCH 187/218] 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 8d89fac5..7ca830fc 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -82,7 +82,7 @@ fi [[ ! -e external_services ]] && touch external_services if ! grep -qs "^$app_name," external_services ; then - if ! grep qs "/external-service" /mnt/"$pool"/ix-applications/releases/"$app_name"/charts/"$(find . -maxdepth 1 -type d -printf '%P\n' | sort -r | head -n 1)"/Chart.yaml ; then + if ! grep qs "/external-service" /mnt/"$pool"/ix-applications/releases/"$app_name"/charts/"$(find /mnt/"$pool"/ix-applications/releases/"$app_name"/charts/ -maxdepth 1 -type d -printf '%P\n' | sort -r | head -n 1)"/Chart.yaml ; then echo "$app_name,false" >> external_services else echo "$app_name,true" >> external_services From be064a818b07fb6536b6fa015d6b1c5ee01548ec Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 13 Aug 2022 10:49:47 -0600 Subject: [PATCH 188/218] if app is external services, do not post process --- 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 7ca830fc..20beb654 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -78,7 +78,6 @@ if grep -qs "^$app_name," failed.txt ; then fi fi - [[ ! -e external_services ]] && touch external_services if ! grep -qs "^$app_name," external_services ; then @@ -111,7 +110,12 @@ else echo_array return fi -after_update_actions +if grep -qs "^$app_name,true" external_services ; then + echo_array + return +else + after_update_actions +fi } export -f pre_process From 0faeefa71d9a32ab00bd71dc43250967ecbe9357 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 13 Aug 2022 10:52:31 -0600 Subject: [PATCH 189/218] while sleep to 5 --- functions/update_apps.sh | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 20beb654..c977978f 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -29,7 +29,7 @@ do ((count++)) done if [[ "$proc_count" -ge "$update_limit" ]]; then - sleep 3 + sleep 5 elif [[ $it -lt ${#array[@]} ]]; then # loop=0 # until [[ $loop -ge 2 || $it -ge ${#array[@]} ]]; @@ -40,7 +40,7 @@ do # ((loop++)) # done elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish - sleep 3 + sleep 5 else # All processes must be completed, break out of loop break fi @@ -79,7 +79,6 @@ if grep -qs "^$app_name," failed.txt ; then fi [[ ! -e external_services ]] && touch external_services - if ! grep -qs "^$app_name," external_services ; then if ! grep qs "/external-service" /mnt/"$pool"/ix-applications/releases/"$app_name"/charts/"$(find /mnt/"$pool"/ix-applications/releases/"$app_name"/charts/ -maxdepth 1 -type d -printf '%P\n' | sort -r | head -n 1)"/Chart.yaml ; then echo "$app_name,false" >> external_services @@ -88,9 +87,6 @@ if ! grep -qs "^$app_name," external_services ; then fi fi - - - echo_array+=("\n$app_name") if [[ $stop_before_update == "true" && "$startstatus" != "STOPPED" ]]; then # Check to see if user is using -S or not [[ "$verbose" == "true" ]] && echo_array+=("Stopping prior to update..") From 67c2f39f869c5ee83bf7c1a69de1c4070270a578 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 13 Aug 2022 15:07:06 -0600 Subject: [PATCH 190/218] test deploying file --- functions/update_apps.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index c977978f..ae65f945 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -17,6 +17,15 @@ do if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then ((while_count++)) [[ -z $while_status ]] && continue || echo -e "$while_count\n$while_status" > temp.txt + for i in "${while_status[@]}" + do + app_name=$(echo "$i" | awk -F ',' '{print $1}') + status=$(echo "$i" | awk -F ',' '{print $2}') + if [[ $status == "DEPLOYING" ]]; then + [[ ! -e deploying ]] && touch deploying + grep -qs "$app_name,DEPLOYING" deploying || echo "$app_name,DEPLOYING" >> deploying + fi + done else echo "Middlewared timed out. Consider setting a lower number for async applications" continue @@ -46,6 +55,7 @@ do fi done rm temp.txt +rm deploying echo echo @@ -176,8 +186,8 @@ count=0 if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then while true do - status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') - if [[ $count -lt 1 && $status != "DEPLOYING" ]]; then # If status shows up as Active or Stopped on the first check, verify that. Otherwise it may be a false report.. + status=$(grep "^$app_name," temp.txt | awk -F ',' '{print $2}') + if [[ $count -lt 1 && $status != "DEPLOYING" && "$(grep "^$app_name," deploying | 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..") old_status=$status before_loop=$(head -n 1 temp.txt) From e1e7c529533f1b556b834088d3255519f5022f29 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 13 Aug 2022 15:12:35 -0600 Subject: [PATCH 191/218] change to an 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 ae65f945..2db0b3a1 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -14,9 +14,9 @@ it=0 while_count=0 while true do - if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then + if mapfile -t while_status < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then ((while_count++)) - [[ -z $while_status ]] && continue || echo -e "$while_count\n$while_status" > temp.txt + [[ -z ${while_status[*]} ]] && continue || echo -e "$while_count\n${while_status[*]}" > temp.txt for i in "${while_status[@]}" do app_name=$(echo "$i" | awk -F ',' '{print $1}') From 978bf40d5a03da234e7120b74643afe97c2c5b31 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 13 Aug 2022 15:26:50 -0600 Subject: [PATCH 192/218] new method of deploying check --- functions/update_apps.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 2db0b3a1..563f1913 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -14,16 +14,16 @@ it=0 while_count=0 while true do - if mapfile -t while_status < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then + if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then ((while_count++)) - [[ -z ${while_status[*]} ]] && continue || echo -e "$while_count\n${while_status[*]}" > temp.txt - for i in "${while_status[@]}" + [[ -z $while_status ]] && continue || echo -e "$while_count\n$while_status" > temp.txt + mapfile -t deploying_check < <(grep ",DEPLOYING," temp.txt) + for i in "${deploying_check[@]}" do app_name=$(echo "$i" | awk -F ',' '{print $1}') - status=$(echo "$i" | awk -F ',' '{print $2}') - if [[ $status == "DEPLOYING" ]]; then - [[ ! -e deploying ]] && touch deploying - grep -qs "$app_name,DEPLOYING" deploying || echo "$app_name,DEPLOYING" >> deploying + [[ ! -e deploying ]] && touch deploying + if ! grep -qs "$app_name,DEPLOYING" deploying; then + echo "$app_name,DEPLOYING" >> deploying fi done else From e82fa5f8c250b69537cc06177a7436320a04a07a Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 13 Aug 2022 15:29:14 -0600 Subject: [PATCH 193/218] rm deploying prior to starting --- functions/update_apps.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 563f1913..60deb582 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -12,6 +12,7 @@ pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{pri it=0 while_count=0 +rm deploying while true do if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then From 80374b5ea99b5f9bd89202191aab779868ee5a54 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 13 Aug 2022 15:41:50 -0600 Subject: [PATCH 194/218] sleep back down to 3 --- 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 60deb582..f2ee0ea8 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -39,7 +39,7 @@ do ((count++)) done if [[ "$proc_count" -ge "$update_limit" ]]; then - sleep 5 + sleep 3 elif [[ $it -lt ${#array[@]} ]]; then # loop=0 # until [[ $loop -ge 2 || $it -ge ${#array[@]} ]]; @@ -50,7 +50,7 @@ do # ((loop++)) # done elif [[ $proc_count != 0 ]]; then # Wait for all processes to finish - sleep 5 + sleep 3 else # All processes must be completed, break out of loop break fi From 96be5786c98f5ba54250cdda997da54845eb9683 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 13 Aug 2022 17:03:32 -0600 Subject: [PATCH 195/218] remove stopped, since ext ser is handled earlier --- 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 f2ee0ea8..c4fc546b 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -12,7 +12,7 @@ pool=$(cli -c 'app kubernetes config' | grep -E "dataset\s\|" | awk -F '|' '{pri it=0 while_count=0 -rm deploying +rm deploying 2>/dev/null while true do if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then @@ -55,8 +55,8 @@ do break fi done -rm temp.txt -rm deploying +rm temp.txt 2>/dev/null +rm deploying 2>/dev/null echo echo @@ -219,9 +219,6 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then echo_array+=("Active") break fi - elif [[ "$status" == "STOPPED" ]]; then - echo_array+=("Stopped") - break elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then if [[ $rollback == "true" ]]; then if [[ "$failed" != "true" ]]; then From dff4f7678f2d7e3fc03857699e436d337f976495 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 13 Aug 2022 17:07:27 -0600 Subject: [PATCH 196/218] remove deploying requirement on timeout --- 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 c4fc546b..5f9d35a7 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -219,7 +219,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then echo_array+=("Active") break fi - elif [[ "$SECONDS" -ge "$timeout" && "$status" == "DEPLOYING" ]]; then + elif [[ "$SECONDS" -ge "$timeout" ]]; then if [[ $rollback == "true" ]]; then if [[ "$failed" != "true" ]]; then echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)") From ce2725f289e23ff75ff656b1e7703b327f2eb29f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 13 Aug 2022 17:12:19 -0600 Subject: [PATCH 197/218] only pull in "active" containers --- 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 5f9d35a7..c5b52c20 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -188,12 +188,11 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then while true do status=$(grep "^$app_name," temp.txt | awk -F ',' '{print $2}') - if [[ $count -lt 1 && $status != "DEPLOYING" && "$(grep "^$app_name," deploying | 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.. + if [[ $count -lt 1 && $status == "ACTIVE" && "$(grep "^$app_name," deploying | 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..") - old_status=$status before_loop=$(head -n 1 temp.txt) current_loop=0 - until [[ "$status" != "$old_status" || $current_loop -gt 4 ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. + until [[ "$status" != "ACTIVE" || $current_loop -gt 3 ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. do status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') sleep 1 From deb99d0af40b302a34f45221c1d834438ea5ee62 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 13 Aug 2022 17:32:44 -0600 Subject: [PATCH 198/218] change temp.txt to all_app_status --- 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 c5b52c20..c6981e3a 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -17,8 +17,8 @@ while true do if while_status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' 2>/dev/null) ; then ((while_count++)) - [[ -z $while_status ]] && continue || echo -e "$while_count\n$while_status" > temp.txt - mapfile -t deploying_check < <(grep ",DEPLOYING," temp.txt) + [[ -z $while_status ]] && continue || echo -e "$while_count\n$while_status" > all_app_status + mapfile -t deploying_check < <(grep ",DEPLOYING," all_app_status) for i in "${deploying_check[@]}" do app_name=$(echo "$i" | awk -F ',' '{print $1}') @@ -55,7 +55,7 @@ do break fi done -rm temp.txt 2>/dev/null +rm all_app_status 2>/dev/null rm deploying 2>/dev/null echo echo @@ -131,18 +131,18 @@ update_app(){ current_loop=0 while true do - update_avail=$(grep "^$app_name," temp.txt | awk -F ',' '{print $3}') + update_avail=$(grep "^$app_name," all_app_status | awk -F ',' '{print $3}') if [[ $update_avail == "true" ]]; then if ! cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null ; then echo "Fail Trigger - Debugging" - before_loop=$(head -n 1 temp.txt) + before_loop=$(head -n 1 all_app_status) current_loop=0 - until [[ "$(grep "^$app_name," temp.txt | awk -F ',' '{print $3}')" != "$update_avail" ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. + until [[ "$(grep "^$app_name," all_app_status | awk -F ',' '{print $3}')" != "$update_avail" ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. do if [[ $current_loop -gt 2 ]]; then cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null || return 1 # After waiting, attempt an update once more, if fails, return error code - elif ! echo -e "$(head -n 1 temp.txt)" | grep -qs ^"$before_loop" ; then # The file has been updated, but nothing changed specifically for the app. - before_loop=$(head -n 1 temp.txt) + elif ! echo -e "$(head -n 1 all_app_status)" | grep -qs ^"$before_loop" ; then # The file has been updated, but nothing changed specifically for the app. + before_loop=$(head -n 1 all_app_status) ((current_loop++)) fi sleep 1 @@ -162,14 +162,14 @@ stop_app(){ count=0 while [[ "$status" != "STOPPED" ]] do - status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') + status=$( grep "^$app_name," all_app_status | awk -F ',' '{print $2}') if [[ $count -gt 2 ]]; then # If failed to stop app 3 times, return failure to parent shell return 1 elif ! cli -c 'app chart_release scale release_name='\""$app_name"\"\ 'scale_options={"replica_count": 0}' &> /dev/null ; then echo "Fail Trigger Stop - Debugging" - before_loop=$(head -n 1 temp.txt) + before_loop=$(head -n 1 all_app_status) ((count++)) - until [[ $(head -n 1 temp.txt) != "$before_loop" ]] # Upon failure, wait for status update before continuing + until [[ $(head -n 1 all_app_status) != "$before_loop" ]] # Upon failure, wait for status update before continuing do sleep 1 done @@ -187,17 +187,17 @@ count=0 if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then while true do - status=$(grep "^$app_name," temp.txt | awk -F ',' '{print $2}') + status=$(grep "^$app_name," all_app_status | awk -F ',' '{print $2}') if [[ $count -lt 1 && $status == "ACTIVE" && "$(grep "^$app_name," deploying | 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..") - before_loop=$(head -n 1 temp.txt) + before_loop=$(head -n 1 all_app_status) current_loop=0 until [[ "$status" != "ACTIVE" || $current_loop -gt 3 ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. do - status=$( grep "^$app_name," temp.txt | awk -F ',' '{print $2}') + status=$( grep "^$app_name," all_app_status | awk -F ',' '{print $2}') sleep 1 - if ! echo -e "$(head -n 1 temp.txt)" | grep -qs ^"$before_loop" ; then - before_loop=$(head -n 1 temp.txt) + if ! echo -e "$(head -n 1 all_app_status)" | grep -qs ^"$before_loop" ; then + before_loop=$(head -n 1 all_app_status) ((current_loop++)) fi done From 18cfd761e2244e22b1e3d4e44d01935a37035041 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sat, 13 Aug 2022 17:36:19 -0600 Subject: [PATCH 199/218] higher req loop for active verification --- 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 c6981e3a..dd1c51a1 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -192,7 +192,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then [[ "$verbose" == "true" ]] && echo_array+=("Verifying $status..") before_loop=$(head -n 1 all_app_status) current_loop=0 - until [[ "$status" != "ACTIVE" || $current_loop -gt 3 ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. + until [[ "$status" != "ACTIVE" || $current_loop -gt 4 ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. do status=$( grep "^$app_name," all_app_status | awk -F ',' '{print $2}') sleep 1 From 7375d73ab5e90b15e13594963ad3dada280b86b2 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 14 Aug 2022 17:43:07 -0600 Subject: [PATCH 200/218] suppress error messages --- functions/update_apps.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index dd1c51a1..ea226f48 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -78,20 +78,20 @@ 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}') -if grep -qs "^$app_name," failed.txt ; then - failed_ver=$(grep "^$app_name," failed.txt | awk -F ',' '{print $2}') +if grep -qs "^$app_name," failed 2>/dev/null; then + failed_ver=$(grep "^$app_name," failed | awk -F ',' '{print $2}') if [[ "$failed_ver" == "$new_full_ver" ]] ; then echo -e "\n$app_name" echo -e "Skipping previously failed version:\n$new_full_ver" return 0 else - sed -i /"$app_name",/d failed.txt + sed -i /"$app_name",/d failed fi fi [[ ! -e external_services ]] && touch external_services if ! grep -qs "^$app_name," external_services ; then - if ! grep qs "/external-service" /mnt/"$pool"/ix-applications/releases/"$app_name"/charts/"$(find /mnt/"$pool"/ix-applications/releases/"$app_name"/charts/ -maxdepth 1 -type d -printf '%P\n' | sort -r | head -n 1)"/Chart.yaml ; then + if ! grep qs "/external-service" /mnt/"$pool"/ix-applications/releases/"$app_name"/charts/"$(find /mnt/"$pool"/ix-applications/releases/"$app_name"/charts/ -maxdepth 1 -type d -printf '%P\n' | sort -r | head -n 1)"/Chart.yaml 2>/dev/null; then echo "$app_name,false" >> external_services else echo "$app_name,true" >> external_services @@ -194,7 +194,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then current_loop=0 until [[ "$status" != "ACTIVE" || $current_loop -gt 4 ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. do - status=$( grep "^$app_name," all_app_status | awk -F ',' '{print $2}') + status=$(grep "^$app_name," all_app_status | awk -F ',' '{print $2}') sleep 1 if ! echo -e "$(head -n 1 all_app_status)" | grep -qs ^"$before_loop" ; then before_loop=$(head -n 1 all_app_status) @@ -227,7 +227,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then echo_array+=("Reverting update..") midclt call chart.release.rollback "$app_name" "{\"item_version\": \"$rollback_version\"}" &> /dev/null || { echo_array+=("Error: Failed to rollback $app_name") ; break ; } [[ "$startstatus" == "STOPPED" ]] && failed="true" && after_update_actions #run back after_update_actions function if the app was stopped prior to update - echo "$app_name,$new_full_ver" >> failed.txt + echo "$app_name,$new_full_ver" >> failed break else echo_array+=("Error: Run Time($SECONDS) for $app_name has exceeded Timeout($timeout)") From 9b998c85530f87a5bc5c07bf7202840d07723825 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Sun, 14 Aug 2022 17:47:56 -0600 Subject: [PATCH 201/218] suppress error message --- 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 ea226f48..4ee33c95 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -188,7 +188,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then while true do status=$(grep "^$app_name," all_app_status | awk -F ',' '{print $2}') - if [[ $count -lt 1 && $status == "ACTIVE" && "$(grep "^$app_name," deploying | 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.. + 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..") before_loop=$(head -n 1 all_app_status) current_loop=0 From 2af51cf0495adb5f050c881e36d8dcfd1eeda6ac Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 16 Aug 2022 20:08:03 -0600 Subject: [PATCH 202/218] add cmd to container to help and --cmd --- functions/misc.sh | 1 + heavy_script.sh | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/functions/misc.sh b/functions/misc.sh index 050055d8..87278b4b 100644 --- a/functions/misc.sh +++ b/functions/misc.sh @@ -48,6 +48,7 @@ echo "--mount | Initiates mounting feature, choose between unmounting an 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 "--cmd | Open a shell for one of your applications" echo echo "Update Types" echo "------------" diff --git a/heavy_script.sh b/heavy_script.sh index 3b970e9f..afea3b3a 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -41,6 +41,9 @@ do dns) dns="true" ;; + cmd) + cmd="true" + ;; restore) restore="true" ;; @@ -136,6 +139,7 @@ done #Continue to call functions in specific order [[ "$self_update" == "true" ]] && self_update [[ "$help" == "true" ]] && help +[[ "$cmd" == "true" ]] && cmd_to_container [[ "$deleteBackup" == "true" ]] && deleteBackup && exit [[ "$dns" == "true" ]] && dns && exit [[ "$restore" == "true" ]] && restore && exit From 89bba86722e10cbb720ec0f70bd1d5411969db69 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 16 Aug 2022 20:17:19 -0600 Subject: [PATCH 203/218] Update Readme --- README.md | 45 ++++++++++++++++++++++++++------------------- heavy_script.sh | 2 +- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 7199c34e..154e2093 100644 --- a/README.md +++ b/README.md @@ -14,27 +14,34 @@
-## Arguments +## Update Arguments +| Flag | Example | Parameter | Description | +|--------------- |------------------------ |----------------- |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| -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 | +| --self-update | --self-update | None | Updates HeavyScript prior to running any other commands | -| 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 10 | 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 | +
+
+## Other Utilities +> All of these can ALSO be accessed with the HeavyScript menu, that you can access simply by not providing an argument `bash heavy_script.sh` + +| Flag | Example | Parameter | Description | +|----------------- |----------------- |----------- |---------------------------------------------------------------------------------------------- | +| --mount | --mount | None | Initiates mounting feature, choose between unmounting and mounting PVC data | +| --restore | --restore | None | Opens a menu to restore a heavy_script backup that was taken on your ix-applications dataset | +| --delete-backup | --delete-backup | None | Opens a menu to delete backups on your system | +| --dns | --dns | None | list all of your applications DNS names and their web ports | +| --cmd | --cmd | None | Open a shell for one of your applications |

diff --git a/heavy_script.sh b/heavy_script.sh index afea3b3a..fad37d0c 100644 --- a/heavy_script.sh +++ b/heavy_script.sh @@ -139,7 +139,7 @@ done #Continue to call functions in specific order [[ "$self_update" == "true" ]] && self_update [[ "$help" == "true" ]] && help -[[ "$cmd" == "true" ]] && cmd_to_container +[[ "$cmd" == "true" ]] && cmd_to_container && exit [[ "$deleteBackup" == "true" ]] && deleteBackup && exit [[ "$dns" == "true" ]] && dns && exit [[ "$restore" == "true" ]] && restore && exit From b6e831deb8a5fa8350e7d6024353166b5774b576 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 16 Aug 2022 20:19:46 -0600 Subject: [PATCH 204/218] prep menu --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 154e2093..864b7e92 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,11 @@
+## The Menu + + +
+ ## Update Arguments | Flag | Example | Parameter | Description | |--------------- |------------------------ |----------------- |---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | From a326f41fc34d0399a1151687a5cc630cc92c39ec Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 17 Aug 2022 02:20:50 +0000 Subject: [PATCH 205/218] Picture for README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 864b7e92..e4c29048 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@ ## The Menu +![image](https://user-images.githubusercontent.com/20793231/185020236-7b389499-8081-407d-b653-10dffd70de8c.png) +
From 7a23b178e0a830db73302beeb83874a6da261159 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 16 Aug 2022 20:23:26 -0600 Subject: [PATCH 206/218] update readme --- README.md | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 864b7e92..0ef62f6b 100644 --- a/README.md +++ b/README.md @@ -34,24 +34,8 @@ | -p | -p | None | Prune old/unused docker images | | --self-update | --self-update | None | Updates HeavyScript prior to running any other commands | -
-
-## Other Utilities -> All of these can ALSO be accessed with the HeavyScript menu, that you can access simply by not providing an argument `bash heavy_script.sh` - -| Flag | Example | Parameter | Description | -|----------------- |----------------- |----------- |---------------------------------------------------------------------------------------------- | -| --mount | --mount | None | Initiates mounting feature, choose between unmounting and mounting PVC data | -| --restore | --restore | None | Opens a menu to restore a heavy_script backup that was taken on your ix-applications dataset | -| --delete-backup | --delete-backup | None | Opens a menu to delete backups on your system | -| --dns | --dns | None | list all of your applications DNS names and their web ports | -| --cmd | --cmd | None | Open a shell for one of your applications | - -
-
- -### Examples +### Example #### Typical Cron Job ``` bash heavy_script.sh --self-update -b 10 -i portainer -i arch -i sonarr -i radarr -t 600 -rsp -u 5 @@ -75,6 +59,22 @@ bash heavy_script.sh --self-update -b 10 -i portainer -i arch -i sonarr -i radar > `--self-update` Will update the script prior to running anything else. +
+ +## Other Utilities +> All of these can ALSO be accessed with the HeavyScript menu, that you can access simply by not providing an argument `bash heavy_script.sh` + +| Flag | Example | Parameter | Description | +|----------------- |----------------- |----------- |---------------------------------------------------------------------------------------------- | +| --mount | --mount | None | Initiates mounting feature, choose between unmounting and mounting PVC data | +| --restore | --restore | None | Opens a menu to restore a heavy_script backup that was taken on your ix-applications dataset | +| --delete-backup | --delete-backup | None | Opens a menu to delete backups on your system | +| --dns | --dns | None | list all of your applications DNS names and their web ports | +| --cmd | --cmd | None | Open a shell for one of your applications | + +
+ +### Examples #### Mounting PVC Data ``` @@ -177,7 +177,7 @@ bash heavyscript.sh --self-update -b 10 -supr | 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` | `bash /PATH/TO/HEAVY_SCRIPT_DIRECTORY/heavy_script.sh --self-update -b 10 -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 10 -rsup` | +| `Command` | `bash /PATH/TO/HEAVY_SCRIPT_DIRECTORY/heavy_script.sh --self-update -b 10 -rsp -u 10` | 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 10 -rsp -u 10` | | `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. | From 3feb8d97ce55eeb9f22bf37039d3f6ed91c12395 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 16 Aug 2022 20:24:15 -0600 Subject: [PATCH 207/218] menu --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index eda5b691..3b2b8060 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ ## The Menu ![image](https://user-images.githubusercontent.com/20793231/185020236-7b389499-8081-407d-b653-10dffd70de8c.png) - +> Access this with `bash heavy_script.sh`
From 00cc643fb50dfeacd9249707bf121c1f75af4010 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 16 Aug 2022 20:25:47 -0600 Subject: [PATCH 208/218] spacing in readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3b2b8060..baad07ea 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ ![image](https://user-images.githubusercontent.com/20793231/185020236-7b389499-8081-407d-b653-10dffd70de8c.png) > Access this with `bash heavy_script.sh` +

## Update Arguments @@ -60,7 +61,7 @@ bash heavy_script.sh --self-update -b 10 -i portainer -i arch -i sonarr -i radar > `--self-update` Will update the script prior to running anything else. - +

## Other Utilities @@ -74,7 +75,6 @@ bash heavy_script.sh --self-update -b 10 -i portainer -i arch -i sonarr -i radar | --dns | --dns | None | list all of your applications DNS names and their web ports | | --cmd | --cmd | None | Open a shell for one of your applications | -
### Examples #### Mounting PVC Data From 83785c184b1fd92dd4b4824ec72cdef4d4ae3b4f Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 16 Aug 2022 20:27:11 -0600 Subject: [PATCH 209/218] rm personal cron, add --cmd --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index baad07ea..c084ee68 100644 --- a/README.md +++ b/README.md @@ -101,10 +101,10 @@ bash /mnt/tank/scripts/heavy_script/heavy_script.sh --delete-backup bash /mnt/tank/scripts/heavy_script/heavy_script.sh --dns ``` -#### My personal Cron Job +#### Open a Containers Shell ``` -bash /mnt/speed/scripts/heavy_script/heavy_script.sh --self-update -b 10 -rsp -u 10 +bash /mnt/speed/scripts/heavy_script/heavy_script.sh --cmd ```
From 1577082435de18d193024ec1a49428226497cb00 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Tue, 16 Aug 2022 20:36:13 -0600 Subject: [PATCH 210/218] exit menu and backup if no valid selection --- functions/menu.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/menu.sh b/functions/menu.sh index 79993400..5b86ca5f 100644 --- a/functions/menu.sh +++ b/functions/menu.sh @@ -14,7 +14,7 @@ echo "8) Update Applications" echo "9) Command to Container" echo echo "0) Exit" -read -rt 120 -p "Please select an option by number: " selection +read -rt 120 -p "Please select an option by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } case $selection in 0) @@ -30,7 +30,7 @@ case $selection in mount ;; 4) - read -rt 120 -p "What is the maximun number of backups you would like?: " number_of_backups || echo "Failed to make a selection" + 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) From 595957f1c408c1e090a475694792cc4e777b49d9 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 18 Aug 2022 00:09:10 -0600 Subject: [PATCH 211/218] new test --- functions/cmd_to_container.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 35f045b6..25c405e2 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -2,7 +2,7 @@ cmd_to_container(){ -app_name=$(k3s kubectl get pods -A | awk '{print $1}' | sort -u | grep -v "system" | sed '1d' | sed 's/^[^-]*-//' | nl -s ") " | column -t) +app_name=$(k3s crictl pods -s ready --namespace ix | sed -E 's/[[:space:]]([0-9]*|About)[a-z0-9 ]{5,12}ago[[:space:]]//' | sed '1d' | awk '{print $4}' | sort -u | nl -s ") " | column -t) while true do clear -x @@ -23,8 +23,9 @@ do fi done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') +search=$(k3s crictl pods -s ready --namespace ix) +mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $1}') search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0-9 ]{5,12}ago[[:space:]]//') -mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') for pod in "${pod_id[@]}" do if [[ $(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r " | wc -l) -gt 1 ]]; then From d58b25c35582b0665c66ef30a80679e85457e34b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 18 Aug 2022 00:13:05 -0600 Subject: [PATCH 212/218] cut out ix --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 25c405e2..c1021a5c 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -22,7 +22,7 @@ do break fi done -app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') +app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}' | cut -c4-) search=$(k3s crictl pods -s ready --namespace ix) mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $1}') search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0-9 ]{5,12}ago[[:space:]]//') From 0e14b8abbb4b5c7808846392297d8046c52f0d3b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 18 Aug 2022 00:14:12 -0600 Subject: [PATCH 213/218] add cut to app list instead --- functions/cmd_to_container.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index c1021a5c..88b5cfaf 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -2,7 +2,7 @@ cmd_to_container(){ -app_name=$(k3s crictl pods -s ready --namespace ix | sed -E 's/[[:space:]]([0-9]*|About)[a-z0-9 ]{5,12}ago[[:space:]]//' | sed '1d' | awk '{print $4}' | sort -u | nl -s ") " | column -t) +app_name=$(k3s crictl pods -s ready --namespace ix | sed -E 's/[[:space:]]([0-9]*|About)[a-z0-9 ]{5,12}ago[[:space:]]//' | sed '1d' | awk '{print $4}' | cut -c4- | sort -u | nl -s ") " | column -t) while true do clear -x @@ -22,7 +22,7 @@ do break fi done -app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}' | cut -c4-) +app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}' ) search=$(k3s crictl pods -s ready --namespace ix) mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $1}') search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0-9 ]{5,12}ago[[:space:]]//') From 3fe9c91f28a0e3f4528fb17a17e48914f15e7c2e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 18 Aug 2022 00:17:17 -0600 Subject: [PATCH 214/218] ix-chart apps are now working --- functions/cmd_to_container.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 88b5cfaf..79361515 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -22,7 +22,7 @@ do break fi done -app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}' ) +app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') search=$(k3s crictl pods -s ready --namespace ix) mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $1}') search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0-9 ]{5,12}ago[[:space:]]//') From 423800850d32744d0e0ee706f61a35398f9be14b Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 18 Aug 2022 00:36:54 -0600 Subject: [PATCH 215/218] remove ugly spacing --- 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 4ee33c95..0f26acce 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -59,7 +59,6 @@ rm all_app_status 2>/dev/null rm deploying 2>/dev/null echo echo - } export -f commander @@ -158,6 +157,7 @@ done } export -f update_app + stop_app(){ count=0 while [[ "$status" != "STOPPED" ]] From 5c7737f2291684947bf0f82b87cf83e2f4eb8e06 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 18 Aug 2022 00:40:40 -0600 Subject: [PATCH 216/218] take out un-needed examples for readme --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index c084ee68..ce8d669c 100644 --- a/README.md +++ b/README.md @@ -67,13 +67,13 @@ bash heavy_script.sh --self-update -b 10 -i portainer -i arch -i sonarr -i radar ## Other Utilities > All of these can ALSO be accessed with the HeavyScript menu, that you can access simply by not providing an argument `bash heavy_script.sh` -| Flag | Example | Parameter | Description | -|----------------- |----------------- |----------- |---------------------------------------------------------------------------------------------- | -| --mount | --mount | None | Initiates mounting feature, choose between unmounting and mounting PVC data | -| --restore | --restore | None | Opens a menu to restore a heavy_script backup that was taken on your ix-applications dataset | -| --delete-backup | --delete-backup | None | Opens a menu to delete backups on your system | -| --dns | --dns | None | list all of your applications DNS names and their web ports | -| --cmd | --cmd | None | Open a shell for one of your applications | +| Flag | Description | +|-----------------|----------------------------------------------------------------------------------------------| +| --mount | Initiates mounting feature, choose between unmounting and mounting PVC data | +| --restore | Opens a menu to restore a heavy_script backup that was taken on your ix-applications dataset | +| --delete-backup | Opens a menu to delete backups on your system | +| --dns | list all of your applications DNS names and their web ports | +| --cmd | Open a shell for one of your applications | ### Examples From beeae110568fcb81f9aae8545be45090c4bcb312 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 18 Aug 2022 14:41:51 -0600 Subject: [PATCH 217/218] remove search variable --- functions/cmd_to_container.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 79361515..dfbc5215 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -23,8 +23,7 @@ do fi done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') -search=$(k3s crictl pods -s ready --namespace ix) -mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $1}') +mapfile -t pod_id < <(k3s crictl pods -s ready --namespace ix | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $1}') search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0-9 ]{5,12}ago[[:space:]]//') for pod in "${pod_id[@]}" do From 1db4c18d88bb92994c2becfe28cd5e3eeae44b0e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Thu, 18 Aug 2022 20:56:40 -0600 Subject: [PATCH 218/218] prepare for PR --- functions/self_update.sh | 2 +- functions/update_apps.sh | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/functions/self_update.sh b/functions/self_update.sh index b7b3e884..26b2fd56 100644 --- a/functions/self_update.sh +++ b/functions/self_update.sh @@ -2,7 +2,7 @@ args=("$@") self_update() { -branch="ignore-file" +branch="main" git fetch &> /dev/null echo "🅂 🄴 🄻 🄵" echo "🅄 🄿 🄳 🄰 🅃 🄴" diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 0f26acce..a32dc4a9 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -133,7 +133,6 @@ do update_avail=$(grep "^$app_name," all_app_status | awk -F ',' '{print $3}') if [[ $update_avail == "true" ]]; then if ! cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null ; then - echo "Fail Trigger - Debugging" before_loop=$(head -n 1 all_app_status) current_loop=0 until [[ "$(grep "^$app_name," all_app_status | awk -F ',' '{print $3}')" != "$update_avail" ]] # Wait for a specific change to app status, or 3 refreshes of the file to go by. @@ -166,7 +165,6 @@ do if [[ $count -gt 2 ]]; then # If failed to stop app 3 times, return failure to parent shell return 1 elif ! cli -c 'app chart_release scale release_name='\""$app_name"\"\ 'scale_options={"replica_count": 0}' &> /dev/null ; then - echo "Fail Trigger Stop - Debugging" before_loop=$(head -n 1 all_app_status) ((count++)) until [[ $(head -n 1 all_app_status) != "$before_loop" ]] # Upon failure, wait for status update before continuing