From 015f0df2c121a32c0bf3588006668796e4ebf76e Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Mon, 25 Jul 2022 16:56:40 -0600 Subject: [PATCH] array --- functions/update_apps.sh | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/functions/update_apps.sh b/functions/update_apps.sh index 476078f1..93ae1598 100644 --- a/functions/update_apps.sh +++ b/functions/update_apps.sh @@ -44,42 +44,42 @@ diff_chart=$(diff <(echo "$old_chart_ver") <(echo "$new_chart_ver")) #caluclatin old_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}') #Upgraded From new_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}') #Upraded To rollback_version=$(echo "${array[$it]}" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}') -printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo_array+=(echo -e "\n$app_name\nIgnored, skipping") && return #If application is on ignore list, skip +printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && return #If application is on ignore list, skip if [[ "$diff_app" == "$diff_chart" || "$update_all_apps" == "true" ]]; then #continue to update if [[ $stop_before_update == "true" ]]; then # Check to see if user is using -S or not if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop - echo -e "\n$app_name" - [[ "$verbose" == "true" ]] && echo "Updating.." - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "FAILED" + echo_array+=(echo -e "\n$app_name") + [[ "$verbose" == "true" ]] && echo_array+=(echo "Updating..") + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=(echo -e "Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo_array+=(echo "FAILED") return else # if status was not STOPPED, stop the app prior to updating - echo -e "\n$app_name" - [[ "$verbose" == "true" ]] && echo "Stopping prior to update.." - midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && SECONDS=0 || echo -e "FAILED" + echo_array+=(echo -e "\n$app_name") + [[ "$verbose" == "true" ]] && echo_array+=(echo "Stopping prior to update..") + midclt call chart.release.scale "$app_name" '{"replica_count": 0}' &> /dev/null && SECONDS=0 || echo_array+=(echo -e "FAILED") while [[ "$status" != "STOPPED" ]] do status=$(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,status' | grep "^$app_name," | awk -F ',' '{print $2}') if [[ "$status" == "STOPPED" ]]; then - echo "Stopped" - [[ "$verbose" == "true" ]] && echo "Updating.." - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "Failed to update" + echo_array+=(echo "Stopped") + [[ "$verbose" == "true" ]] && echo_array+=(echo "Updating..") + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=(echo -e "Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo "Failed to update" break elif [[ "$SECONDS" -ge "$timeout" ]]; then - echo "Error: Run Time($SECONDS) has exceeded Timeout($timeout)" + echo_array+=(echo "Error: Run Time($SECONDS) has exceeded Timeout($timeout)") break elif [[ "$status" != "STOPPED" ]]; then - [[ "$verbose" == "true" ]] && echo "Waiting $((timeout-SECONDS)) more seconds for $app_name to be STOPPED" + [[ "$verbose" == "true" ]] && echo_array+=(echo "Waiting $((timeout-SECONDS)) more seconds for $app_name to be STOPPED") sleep 10 fi done fi else #user must not be using -S, just update - echo -e "\n$app_name" - [[ "$verbose" == "true" ]] && echo "Updating.." - cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo -e "Updated\n$old_full_ver\n$new_full_ver" && after_update_actions || echo "FAILED" + echo_array+=(echo -e "\n$app_name") + [[ "$verbose" == "true" ]] && echo_array+=(echo "Updating..") + cli -c 'app chart_release upgrade release_name=''"'"$app_name"'"' &> /dev/null && echo_array+=(echo -e "Updated\n$old_full_ver\n$new_full_ver") && after_update_actions || echo "FAILED" fi else - echo -e "\n$app_name\nMajor Release, update manually" + echo_array+=(echo -e "\n$app_name\nMajor Release, update manually") return fi