#!/bin/sh

set -euC

if ! [ -d tarball_archive ]; then
	echo "Directory tarball_archive does not exist in the current directory" >&2
	exit 1
fi

base_url="https://wpd.home.xs4all.nl/symon/philes"

wget -NP tarball_archive/ "$base_url"/{mon-2.{0,1,2,3,4},symon-2.{5,51,52,53,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88}}.tar.gz

if [ -f tarball_hashes.sha256 ]; then
	if sha256 -qc tarball_hashes.sha256; then
		echo "Checks OK according to tarball_hashes.sha256" >&2
	else
		echo "Errors while verifying checksums according to tarball_hashes.sha256" >&2
		exit 1
	fi
fi