#!/bin/bash
#-----------------------------------------------------------------------------
mysleep() { echo "- Sleeping 5 ..."; sleep 5; }
#-----------------------------------------------------------------------------

echo "- Refreshing PuTTY mirror ..."

wget -N -O w32/putty.zip 'https://the.earth.li/~sgtatham/putty/latest/w32/putty.zip'
mysleep

wget -N -O w64/putty.zip 'https://the.earth.li/~sgtatham/putty/latest/w64/putty.zip'
mysleep

wget -N -O md5sums       'https://the.earth.li/~sgtatham/putty/latest/md5sums'
mysleep

wget -N -O sha256sums    'https://the.earth.li/~sgtatham/putty/latest/sha256sums'
mysleep

echo "Unzipping w32 ..."
pushd w32 >/dev/null && { unzip -o putty.zip; popd >/dev/null || exit; }
mysleep
echo "Unzipping w64 ..."
pushd w64 >/dev/null && { unzip -o putty.zip; popd >/dev/null || exit; }
echo "- Getting checksums ..."
md5deep -l -r . | grep -Ev '00.*html|get.sh|sums' | tee md5sums
echo ""
sha256deep -l -r . | grep -Ev '00.*html|get.sh|sums' | tee sha256sums
echo ""
echo "Done. Don't forget to:"
echo "vi 00-README.html"
#-----------------------------------------------------------------------------
