blob: 6a3fe776e812bee36f138cbe901b02dd1b849242 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#!/bin/bash
#
# Simple Debian image downloader.
#
# Parameters
HASHES="MD5SUMS SHA1SUMS SHA256SUMS SHA512SUMS"
# Arguments
BASENAME="`basename $0`"
URL="$1"
BASE="`dirname $URL`"
RATE="$2"
FILENAME="`basename $URL`"
# Syntax
if [ -z "$1" ]; then
echo "usage: $BASENAME <image-url>"
exit 1
fi
# Fetch hashes
for hash in $HASHES; do
wget -c $BASE/$hash
wget -c $BASE/$hash.sig
done
# Set rate limit
if [ ! -z "$RATE" ]; then
LIMIT="--limit-rate=$RATE"
fi
# Get the image
wget -c $LIMIT $URL
# Check hashes
for hash in $HASHES; do
echo "Checking $FILENAME against $hash file..."
check="`echo $hash | tr '[:upper:]' '[:lower:]' | sed -e 's/s$//'`"
grep -e "$FILENAME$" $hash | $check -c
done
# Check hash integrity
for hash in $HASHES; do
echo "Checking $hash.sig..."
gpg --verify $hash.sig
done
|