#!/bin/bash set -e ZUUL_API=${ZUUL_API:-"https://gateway-cloud-softwarefactory.apps.ocp.cloud.ci.centos.org/zuul/api"} ZUUL_BUILD_UUID=${ZUUL_BUILD_UUID:-"b28fb09d0f104ff39ec986abac388f89"} ZUUL_API_URL=${ZUUL_API}/build/${ZUUL_BUILD_UUID} (( ${BASH_VERSION%%.*} >= 4 )) || { echo >&2 "bash >=4 required to download."; exit 1; } command -v python3 >/dev/null 2>&1 || { echo >&2 "Python3 is required to download."; exit 1; } command -v curl >/dev/null 2>&1 || { echo >&2 "curl is required to download."; exit 1; } function log { echo "$(date -Iseconds) | $@" } function get_urls { /usr/bin/env python3 - < /dev/null base_url="${files[0]}" log "Getting logs from ${base_url}" for (( i=1; i<$len; i++ )); do file="${files[i]}" printf -v _out " %-80s [ %04d/%04d ]" "${file}" "${i}" $(( len -1 )) log "$_out" save_file $base_url $file done popd >/dev/null log "Download to ${DOWNLOAD_DIR} complete!"