Page 1 of 1

script-torrent-done-filename not working?

Posted: Fri Aug 19, 2011 4:12 am
by dashy
I have my settings.json file with the following parameters:

Code: Select all

"script-torrent-done-enabled": true,
"script-torrent-done-filename": "/mnt/HD/HD_a2/.transmission-daemon/posttorrent.sh",
Output of posttorrent.sh:

Code: Select all

root@dlink-4C13E6:/mnt/HD/HD_a2/.transmission-daemon# cat posttorrent.sh
#! /bin/bash
# posttorrent.sh by Killemov
{
  # Log file, file where we tell what events have been processed.
  LOG_FILE=/mnt/HD/HD_b2/posttorrent.log
  echo "is this thing on" >> $LOG_FILE
  # Username for transmission remote.
  TR_USERNAME="admin"
  # Password for transmission remote.
  TR_PASSWORD="password"
  # Get current time.
  NOW=$(date +%Y-%m-%d\ %H:%M:%S)
  # Source directory, should not be changed.
  SRC_DIR="${TR_TORRENT_DIR}/${TR_TORRENT_NAME}"
  # Directory to store the un-compressed files in..
  DEST_DIR="${TR_TORRENT_DIR}/${TR_TORRENT_NAME}/"
  # This parameter string could be passed from Transmission in the future.
  TR_TORRENT_PARAMETER="EXTRACT SLEEP1h"

  if [ -e "$SRC_DIR/keep" ]; then
    TR_TORRENT_PARAMETER="$TR_TORRENT_PARAMETER KEEP"
  fi

  if [ -e "$SRC_DIR/exit" ]; then
    TR_TORRENT_PARAMETER="EXIT"
  fi

  # Actual processing starts here.
  if [[ "$TR_TORRENT_PARAMETER" =~ "EXIT" ]]; then
    echo $NOW "Exiting $TR_TORRENT_NAME" >> $LOG_FILE
    exit 0
  fi

  if [[ "$TR_TORRENT_PARAMETER" =~ "EXTRACT" ]]; then
    cd $TR_TORRENT_DIR
    if [ -d "$SRC_DIR" ]; then
      IFS=$'\n'
      unset RAR_FILES i
      for RAR_FILE in $( /ffp/bin/find "$SRC_DIR" -iname "*.rar" ); do
        if [[ $RAR_FILE =~ .*part...rar ]]; then
          if [[ $RAR_FILE =~ .*part01.rar ]]; then
            RAR_FILES[i++]=$RAR_FILE
          fi
        else
          RAR_FILES[i++]=$RAR_FILE
        fi
      done
      unset IFS

      if [ ${#RAR_FILES} -gt 0 ]; then
        for RAR_FILE in "${RAR_FILES[@]}"; do
          /ffp/bin/unrar x -inul "$RAR_FILE" "$DEST_DIR"
          if [ $? -gt 0 ]; then
            echo $NOW "Error unrarring $TR_TORRENT_NAME" >> $LOG_FILE
            exit 0
          fi
        done
        #if [[ ! "$TR_TORRENT_PARAMETER" =~ "KEEP" ]]; then
        #  SLEEP=$(expr match "$TR_TORRENT_PARAMETER" '.*SLEEP\([0-9a-zA-Z]*\)')
        #  if [ ${#SLEEP} -gt 0 ]; then
        #    sleep $SLEEP
        #  fi
        transmission-remote -n $TR_USERNAME:$TR_PASSWORD -t$TR_TORRENT_ID --remove-and-delete
        #fi
        echo $NOW "Unrarred $TR_TORRENT_NAME" >> $LOG_FILE
      fi
    fi
  fi
} &
And when I complete a torrent, the output indicates that the script is called:

Code: Select all

[04:59:20.010] Ugly.Americans.S02E08.720p.HDTV.x264-IMMERSE Complete (torrent.c:1951)
[04:59:20.010] Ugly.Americans.S02E08.720p.HDTV.x264-IMMERSE Calling script "/mnt/HD/HD_a2/.transmission-daemon/posttorrent.sh" (torrent.c:1909)
Running the code as bash posttorrent.sh (and changing some of the variables to constants) results in a successful unrar and delete. Changed "unrar" to "/ffp/bin/unrar" and "find" to /ffp/bin/find to ensure it wasn't losing the path, but it still doesn't work.

Anybody have any idea why this isn't working? Is there any way to see where the script is failing?

To live dangerously, I tried running transmission as root so that permissions weren't an issue.

Re: script-torrent-done-filename not working?

Posted: Fri Aug 19, 2011 5:01 am
by livings124
User banned + thread locked

Transmission is not meant for piracy. Do not use it.