#!/bin/sh
# Simple script jigdo_instab.sh for downloading via jigdo-lite with an instable 
# internet connection:
# Loop $COUNTDOWNCNT times and do the downloading of the DVD images in an inner loop.
# Because of the instable connection do wait 10 minutes after every loop
# This version is for a complete configured jigdo, which means a complete .jigdo-lite.
# Therefore this scripts needs no parameter. You must start it in the directory with
# the jigdo files.
# You can download the jigdo files e. g. with
# wget -r -l1 --no-parent -np -nd http://cdimage.debian.org/debian-cd/5.0.4/amd64/jigdo-dvd


# Speed: About 1/2 MB/s with a 2 MB/s DSL connection and a proxy, so the about
# 22 GB of a complete Debian version are completed in half a day.

# Rolf Freitag 2009, 2010, Version 12


# for debugging/verbosity
set -x

# Loop jigdo-lite. 10 times should be enough to complete the iso images.
typeset -i COUNTDOWNCNT=10

while test $COUNTDOWNCNT -gt 0
  do
  jigdo-lite --noask
  date
  # wait for new connection
  sleep 60
  COUNTDOWNCNT="`expr $COUNTDOWNCNT - 1`"
done

#make clean
rm -f jigdo-file-cache.db

# check the iso images
sha1sum -c SHA1SUMS

# check the SHA1 signature
gpg --verify SHA1SUMS.sign

# copy to single DVD checksums, for checking the burned images
# with e. g. "image_check.sh /dev/sr0 dvd1 sha1; eject"
# See https://sslsites.de/www.true-random.com/homepage/projects/iso.html
cat SHA1SUMS | grep -m 1 -i DVD-1 > dvd1.sha1
cat SHA1SUMS | grep -m 1 -i DVD-2 > dvd2.sha1
cat SHA1SUMS | grep -m 1 -i DVD-3 > dvd3.sha1
cat SHA1SUMS | grep -m 1 -i DVD-4 > dvd4.sha1
cat SHA1SUMS | grep -m 1 -i DVD-5 > dvd5.sha1
cat SHA1SUMS | grep -m 1 -i update > dvd6.sha1

echo -n "Finished at "
date
echo ", waiting now 123456789 seconds to exit."
sleep 123456789

exit 0

