Guest User

magnet creator & publisher

a guest
Sep 27th, 2013
478
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.50 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # publish and announce given arc on the torrent web
  4. # Intended to be run via ssh directly on hardware router (on DD-WRT + OPTWARE)
  5.  
  6. BASE="/mnt/bigstore/wwshared/veloprobeg_2011"
  7. HOST="localhost"
  8. TMP="/mnt/tmp"
  9. NAME="$1"
  10. MEDIA="$2"
  11. ADDITION="$MEDIA"
  12.  
  13. cd $BASE
  14. echo $MEDIA
  15. if [ "z${MEDIA}" = "z" ] ; then
  16.     echo "Using default extension: photo"
  17.     MEDIA='photo'
  18.     ADDITION=''
  19. fi
  20.  
  21. TORR="$TMP/tor.torrent"
  22. ARC="$NAME/$NAME-$MEDIA.tar"
  23. TARDIR="$BASE/$NAME/"
  24.  
  25. # if there is no name-photo.tar - do the torrent from all tars in folder
  26. if [ ! -e "$ARC" ] ; then
  27.     echo "Adding several files"
  28.     tmdir="$TMP/$NAME"
  29.     [ -d "$tmdir" ] && rm -rf "$tmdir"
  30.     mkdir -p "$tmdir"
  31.     echo "in dir $tmdir"
  32.     olddir=`pwd`
  33.     cd "$NAME"
  34.     curdir=`pwd`
  35.     for a in *.tar ; do
  36.     echo "Adding file $a..."
  37.     ln -s "$curdir/$a" "$tmdir/$a"
  38.     done
  39.     cd "$olddir"
  40.     ARC="$tmdir"
  41.     TARDIR="$BASE"
  42. fi
  43.  
  44. [ -f "$TORR" ] && rm -f "$TORR"
  45. echo "Making a torrent..."
  46. #transmissioncli -n "$ARC" "$TORR"
  47. transmission-create -o "$TORR" "$ARC"
  48. HASH=`transmission-show "$TORR" | grep Hash | awk '{print $2;}'`
  49. echo "Announce the torrent..."
  50. transmission-remote "$HOST" -w "$TARDIR/" -a "$TORR"
  51. echo "All is done."
  52. [ -d "$ARC" ] && rm -rf "$ARC"
  53. MAGNET="magnet:?xt=urn:btih:$HASH"
  54. LABEL="$NAME"
  55. if [ "z$ADDITION" != "z" ] ; then
  56.     LABEL="$NAME-$ADDITION"
  57. fi
  58. echo "$MAGNET   $LABEL" >> magnet-torrents.txt
  59. echo "<a href=\"$MAGNET\">$LABEL</a><br>" >> magnet-torrents.html
  60. echo "$MAGNET"
Advertisement
Add Comment
Please, Sign In to add comment