]> gitweb.fluxo.info Git - scripts.git/commitdiff
Adding debian-dl script
authorSilvio Rhatto <rhatto@riseup.net>
Wed, 12 Feb 2014 13:57:42 +0000 (11:57 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Wed, 12 Feb 2014 13:57:42 +0000 (11:57 -0200)
debian-dl [new file with mode: 0755]

diff --git a/debian-dl b/debian-dl
new file mode 100755 (executable)
index 0000000..2566b4f
--- /dev/null
+++ b/debian-dl
@@ -0,0 +1,36 @@
+#!/bin/bash
+#
+# Simple Debian image downloader.
+#
+
+# Parameters
+HASHES="MD5SUMS SHA1SUMS SHA256SUMS SHA512SUMS"
+
+# Arguments
+BASENAME="`basename $0`"
+URL="$1"
+BASE="`dirname $URL`"
+RATE="$2"
+
+# 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
+
+# Teardown
+echo "Please check `basename $URL` integrity!"