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
|
#!/bin/bash
HTTPBASE="https://cdimage.debian.org/cdimage"
MKTORRENT=mktorrent
BASEDIR="$1"/
shift
for FILE in $@; do
ISODIR=`dirname $FILE`
BTDIR=`echo $ISODIR | sed 's/iso-/bt-/;s/usb-/bt-/'`
if [ ! -d $BTDIR ] ; then
mkdir -p $BTDIR
fi
# Add multiple http seeds: the release path *and* the archive path
# for both the free images and the non-free images - hopefully
# clients will use whichever is available!
case ${FILE} in
*live*)
VER=$(echo ${FILE} | sed 's,^.*/debian-\(live-\)*,,;s,-.*$,,')"-live"
FREE=1
;;
*)
VER=$(echo ${FILE} | sed 's,^.*/debian-*,,;s,-.*$,,')
FREE=1
;;
esac
# Remove some of the leading path here for the HTTP seeds
BASEFILE=${FILE##$BASEDIR}
HTTP1="${HTTPBASE}/release/${VER}/${BASEFILE}"
HTTP2="${HTTPBASE}/archive/${VER}/${BASEFILE}"
$MKTORRENT -a http://bttracker.debian.org:6969/announce \
-c 'Debian CD from cdimage.debian.org' \
-w ${HTTP1} \
-w ${HTTP2} \
-o ${FILE}.torrent \
$FILE > /dev/null
mv $FILE.torrent $BTDIR
done
|