Skip to content

Commit

Permalink
checks: update assignment of platform URLs var
Browse files Browse the repository at this point in the history
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
  • Loading branch information
miabbott committed Feb 15, 2023
1 parent a81099e commit 29d4df4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions usr/lib/greenboot/check/wanted.d/01_update_platforms_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" )
Expand Down

0 comments on commit 29d4df4

Please sign in to comment.