From 29d4df476c03375b604b0c9db5f2d032513f2d1f Mon Sep 17 00:00:00 2001 From: Micah Abbott Date: Tue, 14 Feb 2023 13:54:44 -0500 Subject: [PATCH] checks: update assignment of platform URLs var This updates the script to be more ShellCheck compliant around the assignment of the UPDATE_PLATFORM_URLS variable and the check to see if the varible is empty. The existing functionality remains unchanged. Thanks to @alcir for the suggested changes! Closes: #93 --- .../greenboot/check/wanted.d/01_update_platforms_check.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/usr/lib/greenboot/check/wanted.d/01_update_platforms_check.sh b/usr/lib/greenboot/check/wanted.d/01_update_platforms_check.sh index 5ebbfcd..35ea691 100644 --- a/usr/lib/greenboot/check/wanted.d/01_update_platforms_check.sh +++ b/usr/lib/greenboot/check/wanted.d/01_update_platforms_check.sh @@ -5,15 +5,15 @@ REPOS_DIRECTORY=/etc/ostree/remotes.d URLS_WITH_PROBLEMS=() get_update_platform_urls() { - UPDATE_PLATFORM_URLS=$(grep -P -ho 'http[s]?.*' $REPOS_DIRECTORY/*) - if [[ -z $UPDATE_PLATFORM_URLS ]]; then + mapfile -t UPDATE_PLATFORM_URLS < <(grep -P -ho 'http[s]?.*' "${REPOS_DIRECTORY}"/*) + if [[ ${#UPDATE_PLATFORM_URLS[@]} -eq 0 ]]; then echo "No update platforms found, this can be a mistake" exit 1 fi } assert_update_platforms_are_responding() { - for UPDATE_PLATFORM_URL in ${UPDATE_PLATFORM_URLS[*]}; do + for UPDATE_PLATFORM_URL in "${UPDATE_PLATFORM_URLS[@]}"; do HTTP_STATUS=$(curl -o /dev/null -Isw '%{http_code}\n' "$UPDATE_PLATFORM_URL" || echo "Unreachable") if ! [[ $HTTP_STATUS == 2* ]] && ! [[ $HTTP_STATUS == 3* ]]; then URLS_WITH_PROBLEMS+=( "$UPDATE_PLATFORM_URL" )