#!/bin/sh DEST_DIR="/some/other/dir" function linker() { # create simlink to downloaded files, rather than copy to final directory if [ ! -d "$DEST_DIR/$1" ]; then mkdir "$DEST_DIR/$1"; fi cd "$1" for F in *; do if [ -d "$F" ]; then linker "$1/$F"; fi ln -s "$TR_TORRENT_DIR/$1/$F" "$DEST_DIR/$1" done } cd $TR_TORRENT_DIR if [ -d "$TR_TORRENT_NAME" ] then if ls "$TR_TORRENT_NAME"/*.rar > /dev/null 2>&1 then find "$TR_TORRENT_NAME" -iname "*.rar" | while read file do unrar x -inul "$file" done transmission-remote -n name:password -t$TR_TORRENT_ID --remove-and-delete & echo "Unrarred $TR_TORRENT_NAME" >> /var/log/posttorrent.log else # for multifile torrents that aren't rar'd # cp -r "$TR_TORRENT_NAME" "$DEST_DIR" linker "$TR_TORRENT_NAME" fi else # for single file torrents # cp "$TR_TORRENT_NAME" "$DEST_DIR" ln -s "$TR_TORRENT_NAME" "$DEST_DIR" fi