blob: 4e53ff4df24b830c1fd52be125a72738b0932f84 [file] [log] [blame]
#!/bin/bash
# hash_existing_tarballs
# This script creates SHA-256 hash files for existing tarballs that do not
# already have one whose basename is all numbers. If $UPDDIR is set in the
# environment, it is used as the directory to look for tarballs and save
# hash files. The default is /var/www/automc.spamassassin.org/updates,
# which is where the scripts on sa-vm1.apache.org put them as of
# 2018-03-30
# shasum is part of the Perl core, specifically Digest::SHA
# so let's make sure we prioritize safe places for it...
PATH=/usr/local/bin:/usr/bin:$PATH
shopt -s extglob
cd ${UPDDIR:=/var/www/automc.spamassassin.org/updates} || {
echo "Cannot cd into $UPDDIR, rc=$?. Exiting without hashing anything!" >&2
exit 127
}
for UPF in +([0-9]).tar.gz
do
[[ -s $UPF.sha256 ]] && continue
echo "Hashing $UPF with SHA256" >&2
shasum -a 256 $UPF > $UPF.sha256
[[ -s $UPF.sha512 ]] && continue
echo "Hashing $UPF with SHA512" >&2
shasum -a 512 $UPF > $UPF.sha512
done