Automagically fetching FreeBSD
While building a custom mfsbsd image I had to fetch the distfiles and verify their hash, to do this simpler and faster I threw together this shellscript, which I’m going leave here for later. The script will automatically download a manifest via http or ftp, then it will continue by downloading all files defined in the manifest check their checksum.
#!/bin/sh
set -e
url=${1:-"http://ftp.uninett.no/FreeBSD/releases/amd64/amd64/10.1-RC1/"}
fetch ${url}/MANIFEST
cat MANIFEST | while read file x; do
fetch ${url}/${file}
done
cat MANIFEST | while read file sum x; do
echo -n "${file}: "
if [ "$(sha256 -q ${file})" = "${sum}" ]; then
echo "OK"
else
echo "FAIL"
fi
done