Skip to content

Commit

Permalink
Merge pull request #4276 from systeminit/feat/toolbox-implementation
Browse files Browse the repository at this point in the history
feat: add automatic option to running the upgrade toolbox
  • Loading branch information
johnrwatson authored Aug 5, 2024
2 parents 80235b0 + 4c26290 commit c5f15ab
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions component/toolbox/scripts/upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ usage() {
echo "upgrade available, if so the user can proceed and upgrade"
echo "them all in parallel"
echo "----------------------------------"
echo "Usage: upgrade [-p profile] [-r region]"
echo "Usage: upgrade [-p profile] [-r region] [-a automatic]"
echo " -p profile AWS profile to use"
echo " -r region AWS region to use"
echo " -a automatic [Y/N] Run through automatically/no-interact"
echo
exit 1
}
Expand All @@ -35,14 +36,17 @@ if [[ "${BASH_SOURCE[0]}" != "${0}" ]]; then
fi

# Parse flags
while getopts ":p:r:" opt; do
while getopts ":p:r:a:" opt; do
case ${opt} in
p)
profile=$OPTARG
;;
r)
region=$OPTARG
;;
a)
automatic=$OPTARG
;;
\?)
echo "Invalid option: -$OPTARG" >&2
usage
Expand Down Expand Up @@ -239,9 +243,8 @@ while read -r line; do
done <<< "$instances"
echo "----------------------------------------"

read -p "Would you like to see if an SI binary upgrade is available to these hosts? (Y/N) [takes ~30 seconds] " selection

sassy_selection_check $selection
[[ "${automatic,,}" == "y" ]] || read -p "Would you like to see if an SI binary upgrade is available to these hosts? (Y/N) [takes ~30 seconds] " selection
[[ "${automatic,,}" == "y" ]] || sassy_selection_check $selection

# Setup somewhere unique to push the results of the check into if they chose to continue
# Reset this results_directory variable between each execution run.
Expand All @@ -265,8 +268,8 @@ await_ssm_results "$results_directory" $((i - 1))
concat_and_output "$results_directory" "$check_results_file"

if jq -e 'all(.[]; .status == "success") and any(.[]; .upgradeable == "true")' "$results_directory/$check_results_file" > /dev/null; then
read -p "Would you like to push the new binaries out to the upgradeable hosts? (Y/N) " selection
sassy_selection_check $selection
[[ "${automatic,,}" == "y" ]] || read -p "Would you like to push the new binaries out to the upgradeable hosts? (Y/N) " selection
[[ "${automatic,,}" == "y" ]] || sassy_selection_check $selection
else
echo "Error: Either none are upgradeable or one or more of the checks failed to determine whether it was possible to upgrade the node."
exit 1
Expand Down

0 comments on commit c5f15ab

Please sign in to comment.