From 8f3f7a3bd9e5fe261caf1e1388d21ac18a1c4fe1 Mon Sep 17 00:00:00 2001 From: Chandrakant Kumar Date: Oct 26 2017 05:48:32 +0000 Subject: Add script to automate torrent generation Signed-off-by: Chandrakant Kumar --- diff --git a/scripts/create-torrent.sh b/scripts/create-torrent.sh new file mode 100644 index 0000000..3d6712f --- /dev/null +++ b/scripts/create-torrent.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +# Get torrent.fedoraproject.org username +read -p 'torrent.fedoraproject.org username: ' USERNAME + +ORG = "Fedora" +BASE_DIR = "/srv/torrent/new" +TORRENT_DIR = "$BASE_DIR/$ORG" +ARCHIVE_NAME = "archived.gzip" +HOSTNAME = 'torrent.fedoraproject.org' + +# Archive and upload the files + +tar cvzf $ARCHIVE_NAME $@ +sha1sum $ARCHIVE_NAME > $ARCHIVE_NAME.sha1 +scp $ARCHIVE_NAME $ARCHIVE_NAME.sha1 $USERNAME@$HOSTNAME:$TORRENT_DIR + +ssh $USERNAME@$HOSTNAME << EOF + + if [ ! -d $TORRENT_DIR ]; then + mkdir -p $TORRENT_DIR + fi + + cd $TORRENT_DIR && tar -xvzf $ARCHIVE_NAME && rm $ARCHIVE_NAME + + rsync -avhHP rsync://download-ib01.fedoraproject.org/fedora-stage/24_RC-1.2///iso/ /srv/torrent/new/fedora/ + + for iso in $(ls iso); + do + dest=$(echo $iso|sed -e 's|-1.2.iso||g' ); + mkdir $dest; + mv $iso $dest; + done + + for checksum in $(ls CHECKSUM) + do + for file in $(grep "SHA256 (" $checksum |sed -e 's|SHA256 (||g' -e 's|-1.2.||g' -e 's|-2..||g' ) + do + cp $checksum $file + done + done + + sha256sum -c SHA256SUMS 2>&1 | grep OK + + if [ ! $? -eq "0" ]; + echo "sha1sum verification failed" + exit + fi + + /srv/torrent/new/maketorrent . + wget https://pagure.io/releng/raw/master/f/scripts/fedora-torrent-ini.py + chmod u+x fedora-torrent-ini.py + ./fedora-torrent-ini.py > $ORG.ini + if [ ! -d /srv/torrent/www/torrents/$ORG ]; then + mkdir -p /srv/torrent/www/torrents/$ORG + fi + cp *.torrent /srv/torrent/www/torrents/$ORG/ + cd /srv/torrent/torrent-generator/ && mv $TORRENT_DIR/$ORG.ini . + mv $TORRENT_DIR /srv/torrent/btholding/ +EOF