2024-04-15 23:11:35 -05:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
set -eo pipefail
|
|
|
|
|
|
|
|
|
|
files=()
|
|
|
|
|
|
2024-04-16 10:54:57 -05:00
|
|
|
# shellcheck disable=SC2044
|
2024-04-15 23:11:35 -05:00
|
|
|
for vars in $(find distros/ -name '*.pkrvars.hcl'); do
|
2024-04-16 10:54:57 -05:00
|
|
|
file=$(echo var.iso.url | packer console -var-file="${vars}" -config-type=hcl2 sources/)
|
2024-04-15 23:11:35 -05:00
|
|
|
base="$(basename "${file}")"
|
|
|
|
|
if [ -e "cache/${base}" ]; then
|
|
|
|
|
echo "Found cache/${base} already"
|
|
|
|
|
else
|
2024-04-20 15:11:21 +00:00
|
|
|
files+=("--retry" "3" "--retry-all-errors" "-O" "${file}")
|
2024-04-15 23:11:35 -05:00
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
mkdir -p cache
|
|
|
|
|
pushd cache
|
2024-04-16 10:54:57 -05:00
|
|
|
echo "Downloading ${files[*]}"
|
2024-04-15 23:11:35 -05:00
|
|
|
curl --parallel -L "${files[@]}"
|
|
|
|
|
popd
|