test
This commit is contained in:
parent
34de2750d8
commit
d7136fe270
@ -1,15 +1,25 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
update_apps(){
|
mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | tr -d " \t\r" | grep -E ",true($|,)" | sort)
|
||||||
# Replace with line below after testing
|
|
||||||
# cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | tr -d " \t\r" | grep -E ",true($|,)" | sort
|
|
||||||
mapfile -t array < <(cli -m csv -c 'app chart_release query name,update_available,human_version,human_latest_version,container_images_update_available,status' | grep -E ",true(,|\b)" | sort)
|
|
||||||
[[ -z $array ]] && echo -e "\nThere are no updates available" && return 0 || echo -e "\n${#array[@]} update(s) available"
|
[[ -z $array ]] && echo -e "\nThere are no updates available" && return 0 || echo -e "\n${#array[@]} update(s) available"
|
||||||
[[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout"
|
[[ -z $timeout ]] && echo -e "\nDefault Timeout: 500" && timeout=500 || echo -e "\nCustom Timeout: $timeout"
|
||||||
[[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips"
|
[[ "$timeout" -le 120 ]] && echo "Warning: Your timeout is set low and may lead to premature rollbacks or skips"
|
||||||
|
|
||||||
|
update_limit=5
|
||||||
|
count=0
|
||||||
for i in "${array[@]}"
|
for i in "${array[@]}"
|
||||||
do
|
do
|
||||||
|
update_apps "$i" &
|
||||||
|
(( count++ ))
|
||||||
|
while [[ "$count" -ge "$update_limit" ]]
|
||||||
|
do
|
||||||
|
wait
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
update_apps(){
|
||||||
app_name=$(echo "$i" | awk -F ',' '{print $1}') #print out first catagory, name.
|
app_name=$(echo "$i" | awk -F ',' '{print $1}') #print out first catagory, name.
|
||||||
old_app_ver=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version
|
old_app_ver=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #previous/current Application MAJOR Version
|
||||||
new_app_ver=$(echo "$i" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version
|
new_app_ver=$(echo "$i" | awk -F ',' '{print $5}' | awk -F '_' '{print $1}' | awk -F '.' '{print $1}') #new Application MAJOR Version
|
||||||
@ -22,14 +32,14 @@ do
|
|||||||
old_full_ver=$(echo "$i" | awk -F ',' '{print $4}') #Upgraded From
|
old_full_ver=$(echo "$i" | awk -F ',' '{print $4}') #Upgraded From
|
||||||
new_full_ver=$(echo "$i" | awk -F ',' '{print $5}') #Upraded To
|
new_full_ver=$(echo "$i" | awk -F ',' '{print $5}') #Upraded To
|
||||||
rollback_version=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}')
|
rollback_version=$(echo "$i" | awk -F ',' '{print $4}' | awk -F '_' '{print $2}')
|
||||||
printf '%s\0' "${ignore[@]}" | grep -iFxqz "${app_name}" && echo -e "\n$app_name\nIgnored, skipping" && continue #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 [[ "$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 [[ $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
|
if [[ "$status" == "STOPPED" ]]; then # if status is already stopped, skip while loop
|
||||||
echo -e "\n$app_name"
|
echo -e "\n$app_name"
|
||||||
[[ "$verbose" == "true" ]] && echo "Updating.."
|
[[ "$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"
|
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"
|
||||||
continue
|
return
|
||||||
else # if status was not STOPPED, stop the app prior to updating
|
else # if status was not STOPPED, stop the app prior to updating
|
||||||
echo -e "\n$app_name"
|
echo -e "\n$app_name"
|
||||||
[[ "$verbose" == "true" ]] && echo "Stopping prior to update.."
|
[[ "$verbose" == "true" ]] && echo "Stopping prior to update.."
|
||||||
@ -48,7 +58,6 @@ do
|
|||||||
elif [[ "$status" != "STOPPED" ]]; then
|
elif [[ "$status" != "STOPPED" ]]; then
|
||||||
[[ "$verbose" == "true" ]] && echo "Waiting $((timeout-SECONDS)) more seconds for $app_name to be STOPPED"
|
[[ "$verbose" == "true" ]] && echo "Waiting $((timeout-SECONDS)) more seconds for $app_name to be STOPPED"
|
||||||
sleep 10
|
sleep 10
|
||||||
continue
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
@ -59,9 +68,8 @@ do
|
|||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo -e "\n$app_name\nMajor Release, update manually"
|
echo -e "\n$app_name\nMajor Release, update manually"
|
||||||
continue
|
return
|
||||||
fi
|
fi
|
||||||
done
|
|
||||||
}
|
}
|
||||||
export -f update_apps
|
export -f update_apps
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user