Externalize cache file

This commit is contained in:
Greg Hellings
2024-04-15 23:11:35 -05:00
parent b9f10c9c86
commit 2f3a082104
2 changed files with 21 additions and 16 deletions
Executable
+20
View File
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
set -eo pipefail
files=()
for vars in $(find distros/ -name '*.pkrvars.hcl'); do
file=$(echo var.iso.url | packer console -var-file=${vars} -config-type=hcl2 sources/)
base="$(basename "${file}")"
if [ -e "cache/${base}" ]; then
echo "Found cache/${base} already"
else
files+=("-O" "${file}")
fi
done
mkdir -p cache
pushd cache
echo "Downloading ${files[@]}"
curl --parallel -L "${files[@]}"
popd