echo array to function to control output better
This commit is contained in:
parent
bb50772fc2
commit
edf40ced53
@ -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
|
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_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_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
|
old_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $4}') #Upgraded From
|
||||||
new_full_ver=$(echo "${array[$it]}" | awk -F ',' '{print $5}') #Upraded To
|
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}')
|
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
|
||||||
fi
|
fi
|
||||||
echo_array+=("\n$app_name")
|
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
|
||||||
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..")
|
[[ "$verbose" == "true" ]] && echo_array+=("Stopping prior to update..")
|
||||||
if stop_app ; then
|
if stop_app ; then
|
||||||
echo_array+=("Stopped")
|
echo_array+=("Stopped")
|
||||||
else
|
else
|
||||||
echo_array+=("Error: Failed to stop $app_name")
|
echo_array+=("Error: Failed to stop $app_name")
|
||||||
|
echo_array
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo -e "\n$app_name\nMajor Release, update manually"
|
|
||||||
return 0
|
|
||||||
fi
|
fi
|
||||||
[[ "$verbose" == "true" ]] && echo_array+=("Updating..")
|
[[ "$verbose" == "true" ]] && echo_array+=("Updating..")
|
||||||
if update_app ;then
|
if update_app ;then
|
||||||
echo_array+=("Updated\n$old_full_ver\n$new_full_ver")
|
echo_array+=("Updated\n$old_full_ver\n$new_full_ver")
|
||||||
else
|
else
|
||||||
echo_array+=("Failed to update")
|
echo_array+=("Failed to update")
|
||||||
return
|
echo_array
|
||||||
|
return
|
||||||
fi
|
fi
|
||||||
after_update_actions
|
after_update_actions
|
||||||
}
|
}
|
||||||
@ -186,6 +184,7 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then
|
|||||||
echo_array+=("Stopped")
|
echo_array+=("Stopped")
|
||||||
else
|
else
|
||||||
echo_array+=("Error: Failed to stop $app_name")
|
echo_array+=("Error: Failed to stop $app_name")
|
||||||
|
echo_array
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
break
|
break
|
||||||
@ -226,12 +225,17 @@ if [[ $rollback == "true" || "$startstatus" == "STOPPED" ]]; then
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
echo_array
|
||||||
|
}
|
||||||
|
export -f after_update_actions
|
||||||
|
|
||||||
|
|
||||||
|
echo_array(){
|
||||||
#Dump the echo_array, ensures all output is in a neat order.
|
#Dump the echo_array, ensures all output is in a neat order.
|
||||||
for i in "${echo_array[@]}"
|
for i in "${echo_array[@]}"
|
||||||
do
|
do
|
||||||
echo -e "$i"
|
echo -e "$i"
|
||||||
done
|
done
|
||||||
|
|
||||||
}
|
}
|
||||||
export -f after_update_actions
|
export -f echo_array
|
||||||
|
Loading…
Reference in New Issue
Block a user