Unrar and cleanup script - UPDATE 2013.05.24

Discussion of Transmission that doesn't fit in the other categories
Post Reply
killemov
Posts: 542
Joined: Sat Jul 31, 2010 5:04 pm

Re: Unrar and cleanup script - UPDATE 2011.10.24

Post by killemov »

meathane wrote:Could anybody explain how to 'install' this script, or get it to run once a download is finished?
You have to tell transmission where the script is located. I have changed the starting post to point you in the right direction.
TTTJOhan
Posts: 5
Joined: Sun Nov 13, 2011 9:08 am

Re: Unrar and cleanup script - UPDATE 2011.10.24

Post by TTTJOhan »

Hello!

I run Ubuntu 11.1 and Transmission 2.33 I just installed unrar and tried the script below but it will not work??? What shall I do. Many many thanks for the help I spent hours trying to activate and test older scripts. There is no file according to "/var/log/unpacks.log" shall I create this file or is the absense of the file a proof that the script is not run? I have activeted transmission to run the script everytime the torrent is finalized this I have understood!


#!/bin/bash
#
# Simple extraction script for torrents with compressed files.

# Directory to store the un-compressed files in.
DEST_DIR="${TR_TORRENT_DIR}/${TR_TORRENT_NAME}/"
# Source directory, should not be changed.
SRC_DIR="${TR_TORRENT_DIR}/${TR_TORRENT_NAME}"
# Log file, file where we tell what files have been processed.
LOG_FILE="/var/log/unpacks.log"
# Get current time
RUN_AT=$(date +"%F %T")
TTTJOhan
Posts: 5
Joined: Sun Nov 13, 2011 9:08 am

Re: Unrar and cleanup script - UPDATE 2011.10.24

Post by TTTJOhan »

Hello again!

Here is the entire script I use i missed the last rows:

#!/bin/bash
#
# Simple extraction script for torrents with compressed files.

# Directory to store the un-compressed files in.
DEST_DIR="${TR_TORRENT_DIR}/${TR_TORRENT_NAME}/"
# Source directory, should not be changed.
SRC_DIR="${TR_TORRENT_DIR}/${TR_TORRENT_NAME}"
# Log file, file where we tell what files have been processed.
LOG_FILE="/var/log/unpacks.log"
# Get current time
RUN_AT=$(date +"%F %T")

find "${SRC_DIR}" -iname "*.rar" -execdir unrar e -inul -o+ -kb '{}' "${DEST_DIR}" \; -printf "${RUN_AT}: Unpacked %f into %H\n" , -iname "*.zip" -execdir unzip -qq -o '{}' -d "${DEST_DIR}" \; -printf "${RUN_AT}: Unpacked %f into %H\n" >> "${LOG_FILE}"
killemov
Posts: 542
Joined: Sat Jul 31, 2010 5:04 pm

Re: Unrar and cleanup script - UPDATE 2011.10.24

Post by killemov »

TTTJOhan wrote:Hello!

I run Ubuntu 11.1 and Transmission 2.33 I just installed unrar and tried the script below but it will not work??? What shall I do. Many many thanks for the help I spent hours trying to activate and test older scripts. There is no file according to "/var/log/unpacks.log" shall I create this file or is the absense of the file a proof that the script is not run? I have activeted transmission to run the script everytime the torrent is finalized this I have understood!
You do realize there is a WORKING script (Debian/Ubuntu) in the first post of this topic, right?
TTTJOhan
Posts: 5
Joined: Sun Nov 13, 2011 9:08 am

Re: Unrar and cleanup script - UPDATE 2011.10.24

Post by TTTJOhan »

Hello Again,

Regarding working script I have tried this but it does not work: I cant find the file and folder according to below.

"To make the script work you have to add/change these lines in a configuration file named "settings.json" (usually /etc/transmission-daemon/settings.json) while transmission-daemon is not running. Oh and make sure unrar is installed. (aptitude install unrar)"
Questions: /etc/transmission-daemon/settings.json the folder and file does not exist on my computer, have the file system changed?
knorrhane
Posts: 1
Joined: Mon Nov 14, 2011 12:10 pm

Re: Unrar and cleanup script - UPDATE 2011.10.24

Post by knorrhane »

Hello!

Great job! However, I'm on Ubuntu 11.10 and I can't get your script to work. I don't get any log either so it's like the script doesn't run at all. What I did was add the script to my home folder and simply pointed transmission to it and that should be it, right? Or did I miss anything?

Thank you!
wonko
Posts: 3
Joined: Mon Nov 14, 2011 6:56 pm

Re: Unrar and cleanup script - UPDATE 2011.10.24

Post by wonko »

I'm having similar issues on CentOS 6 with transmission-daemon 2.33

The log file claims to be running the script, but nothing that the script would be doing is taking place.

What sort of diagnostic information can I collect to help figure this out? This is very frustrating.

Thanks!

-brian
TTTJOhan
Posts: 5
Joined: Sun Nov 13, 2011 9:08 am

Re: Unrar and cleanup script - UPDATE 2011.10.24

Post by TTTJOhan »

Hello!

I have understood that the files that are hidden in order to view them this option needs to be enabled. However I have unrar installed and the settings.json are according to message number 1. The script does not work for files with name.rar does not work for single rar files????

Any other frame work etc that needs to be enabled in order to get the script to work?
TTTJOhan
Posts: 5
Joined: Sun Nov 13, 2011 9:08 am

Re: Unrar and cleanup script - UPDATE 2011.10.24

Post by TTTJOhan »

Now I have read all posts in this thread.

1. I have updated login and password according to login and password in Transmission
2. Changed permission for the script file and its folder to 777
3. Tested to run the script manually then I get "2011-11-16 20:36:01 Error unrarring " in the posttorrent logfile, this is all the text in there. Thus the script is not executed by Transmission!?
4. Transmission is pointing to the right script
5. settings.json are set-up according to the instructions in the first message in this thread.
6. Unrar is installed

I am running Ubuntu 11.1 why does not Transmission execute the script?

HELP! I will give up this very soon.
karlhungus
Posts: 2
Joined: Fri Nov 18, 2011 3:18 pm

Re: Unrar and cleanup script - UPDATE 2011.10.24

Post by karlhungus »

The script is working and it is unpacking my torrents. There is however one issue. The process is not cleaned up after the unpack script finishes unpacking.

Code: Select all

 16:35:40 up x days,  1:22,  x users,  load average: 0.01, 0.03, 0.05

karl       2458     1  1 15:52 ?        00:00:22 /usr/bin/transmission-daemon --config-dir /var/lib/transmission-daemon/info
karl     2637     1  0 15:55 ?        00:00:00 /bin/bash /etc/transmission-daemon/unpack.sh
karl       2822     1  0 15:56 ?        00:00:00 /bin/bash /etc/transmission-daemon/unpack.sh
I'm using ubuntu 11.04 2.6.38-8-generic
transmission-daemon 2.13 (11501)
UNRAR 4.00 beta 3

At first I thought it might have something to do with file permissions. After some checking this was not the case. Did I miss something else ?
could always make a cron that checks for these processes so now and then but don't think that's really a solution on the long run.

Any ideas ?

TIA
killemov
Posts: 542
Joined: Sat Jul 31, 2010 5:04 pm

Re: Unrar and cleanup script - UPDATE 2011.10.24

Post by killemov »

karlhungus wrote:The script is working and it is unpacking my torrents. There is however one issue. The process is not cleaned up after the unpack script finishes unpacking.
I'm using ubuntu 11.04 2.6.38-8-generic
transmission-daemon 2.13 (11501)
UNRAR 4.00 beta 3
Have you tried some patience and waiting for 1 hour? The script has a built-in waiting period for the clean up after unpacking. ( ps -ef | grep sleep )

Since you have got the script working on Ubuntu 11+, could you share some insight with your fellow Ubuntu users?
karlhungus
Posts: 2
Joined: Fri Nov 18, 2011 3:18 pm

Re: Unrar and cleanup script - UPDATE 2011.10.24

Post by karlhungus »

Tried using previous versions of the script. They did not work with Ubuntu 11.04. After your latest update (2011-10-24) Ive tried the script again and it works on Ubuntu 11.04 apart from the fact that it now ends in a defunct state. It DOES unpack the files.

Yes I have tried some patience. waited out the hour

When I unpack a file I get the following in my posttorrent.log:

Code: Select all

2011-11-21 12:08:31 Unrarred test.torrent.unrar.script.file1
ps -ef|grep posttorrent tells me the following:

Code: Select all

trans      11900 11889  0 12:08 ?        00:00:00 [posttorrent.sh] <defunct>
current time

Code: Select all

 16:23:56 up 6 days,  1:10,  2 users,  load average: 0.02, 0.06, 0.13
I will look into this a little further see what I can dig up on my ubuntu install.
killemov
Posts: 542
Joined: Sat Jul 31, 2010 5:04 pm

Re: Unrar and cleanup script - UPDATE 2011.10.24

Post by killemov »

karlhungus wrote:I will look into this a little further see what I can dig up on my ubuntu install.
"sleep" available and executable by the same user that runs the script?
"transmission-remote" available and executable by the same user that runs the script?
boondoklife
Posts: 12
Joined: Tue Oct 25, 2011 4:30 pm

Re: Unrar and cleanup script - UPDATE 2011.10.24

Post by boondoklife »

Was reading through the script and it looks interesting, but could you tell me where $TR_TORRENT_ID and $TR_TORRENT_NAME come from? Are these passed to the script from the daemon as parameters some how?
gunzip
Posts: 272
Joined: Wed May 05, 2010 2:12 am

Re: Unrar and cleanup script - UPDATE 2011.10.24

Post by gunzip »

yes those are special environmental variables passed to the script on completion of a torrent. see the wiki for all the listing:

https://trac.transmissionbt.com/wiki/Scripts

they are valid for any script you might use.
Post Reply