Advertisement
Guest User

Untitled

a guest
Apr 19th, 2015
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. DEST_DIR="/some/other/dir"
  4.  
  5. function linker() { # create simlink to downloaded files, rather than copy to final directory
  6. if [ ! -d "$DEST_DIR/$1" ]; then mkdir "$DEST_DIR/$1"; fi
  7. cd "$1"
  8. for F in *; do
  9. if [ -d "$F" ]; then linker "$1/$F"; fi
  10. ln -s "$TR_TORRENT_DIR/$1/$F" "$DEST_DIR/$1"
  11. done
  12. }
  13.  
  14. cd $TR_TORRENT_DIR
  15. if [ -d "$TR_TORRENT_NAME" ]
  16. then
  17. if ls "$TR_TORRENT_NAME"/*.rar > /dev/null 2>&1
  18. then
  19. find "$TR_TORRENT_NAME" -iname "*.rar" | while read file
  20. do
  21. unrar x -inul "$file"
  22. done
  23. transmission-remote -n name:password -t$TR_TORRENT_ID --remove-and-delete &
  24. echo "Unrarred $TR_TORRENT_NAME" >> /var/log/posttorrent.log
  25. else # for multifile torrents that aren't rar'd
  26. # cp -r "$TR_TORRENT_NAME" "$DEST_DIR"
  27. linker "$TR_TORRENT_NAME"
  28. fi
  29. else # for single file torrents
  30. # cp "$TR_TORRENT_NAME" "$DEST_DIR"
  31. ln -s "$TR_TORRENT_NAME" "$DEST_DIR"
  32. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement