Unrar and cleanup script - UPDATE 2013.05.24
-
- Posts: 2
- Joined: Wed May 18, 2011 10:18 pm
Re: Unrar and cleanup script - UPDATE 2011.05.09
Hi there,
thanks for the script, although I don't get it working ;)
I'm a linux newb, so please be kind :o)
My settings.json looks like:
...
"script-torrent-done-enabled": true,
"script-torrent-done-filename": "/root/posttorrent.sh",
...
If I check the logfile, I don't get any entries, so Transmission doesn't even start the script after completion of a torrent.
Any idea why?
Thanks in advance,
ScheffK0ch
thanks for the script, although I don't get it working ;)
I'm a linux newb, so please be kind :o)
My settings.json looks like:
...
"script-torrent-done-enabled": true,
"script-torrent-done-filename": "/root/posttorrent.sh",
...
If I check the logfile, I don't get any entries, so Transmission doesn't even start the script after completion of a torrent.
Any idea why?
Thanks in advance,
ScheffK0ch
Re: Unrar and cleanup script - UPDATE 2011.05.09
My first suggestion would be to set the permissions for the script file to full.
chmod 777 /root/posttorrent.sh
The way transmission works with the settings.json may also be confusing. Make sure transmission is not running when you edit the configuration file.
chmod 777 /root/posttorrent.sh
The way transmission works with the settings.json may also be confusing. Make sure transmission is not running when you edit the configuration file.
-
- Posts: 2
- Joined: Wed May 18, 2011 10:18 pm
Re: Unrar and cleanup script - UPDATE 2011.05.09
That did the trick !!!
Thank you killemov :o)
Thank you killemov :o)
Re: Unrar and cleanup script - UPDATE 2011.06.29
I have updated the start post with a new script.
I have implemented better handling of the current style of multi-archive rar files (.partXX.rar). It only unrars .part01.rar files and ignores .part02.rar and up because those files should be handled by unrar.
I have implemented better handling of the current style of multi-archive rar files (.partXX.rar). It only unrars .part01.rar files and ignores .part02.rar and up because those files should be handled by unrar.
Re: Unrar and cleanup script - UPDATE 2011.06.29
im having trouble running this fantastic script
im having a similar problem to another who posted here although in my case it doesn't appear the script is executing at all - i dont even see a log file being created?
Settings.json appears as:
"script-torrent-done-enabled": true,
"script-torrent-done-filename": "/mnt/data/Torrents/extract.sh",
I have changed permission to 777 to 'extract.sh' and the download directory and i have edited the settings file while unmounted, what else am i missing here?
help!
im having a similar problem to another who posted here although in my case it doesn't appear the script is executing at all - i dont even see a log file being created?
Settings.json appears as:
"script-torrent-done-enabled": true,
"script-torrent-done-filename": "/mnt/data/Torrents/extract.sh",
I have changed permission to 777 to 'extract.sh' and the download directory and i have edited the settings file while unmounted, what else am i missing here?
help!
Re: Unrar and cleanup script - UPDATE 2011.06.29
While unmounted? You mean while transmission wasn't running? Stop and start transmission and verify your changes to settings.json are still there.
Oh, and double check the path/filename of the script again.
Is unrar on your system?
Have you properly modified the variables IN the script?
Oh, and double check the path/filename of the script again.
Is unrar on your system?
Have you properly modified the variables IN the script?
Re: Unrar and cleanup script - UPDATE 2011.06.29
Sorry - by unmounted i mean transmission is not running, the settings are definitely being saved to the settings.json
path/filename are correct
unrar is installed and working
can you confirm exactly what needs to be modified in the script as I haven't touched any of it, this is where im probably going wrong.
thanks killemov
update: ive updated the script with username/password info at the beginning - i assume this is what i use to login to the transmission webgui?
the login details are correct as i can login to the transmission-remote from the command line, not sure if im on the right track here though?
still nothing extracts though and no log file being created (/var/log/posttorrent.log), its like the script its not even attempting to run?
path/filename are correct
unrar is installed and working
can you confirm exactly what needs to be modified in the script as I haven't touched any of it, this is where im probably going wrong.
thanks killemov
update: ive updated the script with username/password info at the beginning - i assume this is what i use to login to the transmission webgui?
the login details are correct as i can login to the transmission-remote from the command line, not sure if im on the right track here though?
still nothing extracts though and no log file being created (/var/log/posttorrent.log), its like the script its not even attempting to run?
Re: Unrar and cleanup script - UPDATE 2011.06.29
Please insert after the two lines starting with #:
echo "start" >> /var/log/posttorrent.log
and have transmission finish a torrent again. (I use echo "" > somesmallfile, verify torrent and continue download.)
If there is no line "start" in the logfile then the script wasn't called from transmission OR you are not running the script in a bash environment. In either case I can't help you any further.
echo "start" >> /var/log/posttorrent.log
and have transmission finish a torrent again. (I use echo "" > somesmallfile, verify torrent and continue download.)
If there is no line "start" in the logfile then the script wasn't called from transmission OR you are not running the script in a bash environment. In either case I can't help you any further.
Re: Unrar and cleanup script - UPDATE 2011.06.29
im not sure exactly what you mean by this
Would it be a permission issue? The script file and folder its contained in are all 777 and so is my downloads folder, user mask is set to 000 for downloads, am i missing else here? The path to the script is definitely correct in the settings.json, any other reason you might be aware of why the script would be prevented from running?
really appreciate your assistance with this. thanks again
i have added echo "start" >> /var/log/posttorrent.log to the beginning of script and still no log is being created which implies the script isnt even starting, im using Freenas. Running the simple echo command to a log file from the bash shell works no problem.(I use echo "" > somesmallfile, verify torrent and continue download.)
Would it be a permission issue? The script file and folder its contained in are all 777 and so is my downloads folder, user mask is set to 000 for downloads, am i missing else here? The path to the script is definitely correct in the settings.json, any other reason you might be aware of why the script would be prevented from running?
really appreciate your assistance with this. thanks again
Re: Unrar and cleanup script - UPDATE 2011.06.29
Have you tried starting the script manually? ( bash yourscript.sh )
Re: Unrar and cleanup script - UPDATE 2011.06.29
have run it manually (didnt realise this would work), the script runs as a log file is being created although getting the following:
2011-08-02 20:48:54 Error unrarring
i have a torrent rar'd sitting in my downloads folder at the time.
im not sure why the file isnt unraring, when i run the script manually do i need to specify anything further or just run the script as is?
i dont get this far if i specify the script in the settings.json as it doesnt appear to run at all in these cases
so frustrating
2011-08-02 20:48:54 Error unrarring
i have a torrent rar'd sitting in my downloads folder at the time.
im not sure why the file isnt unraring, when i run the script manually do i need to specify anything further or just run the script as is?
i dont get this far if i specify the script in the settings.json as it doesnt appear to run at all in these cases
so frustrating
Re: Unrar and cleanup script - UPDATE 2011.06.29
Ok, this suggests that the script is at least able to run on your system and that unrar is called. The problem still is that the script isn't called from transmission. If you have (triple!)checked for proper configuration of the settings.json file and the script is in the correct place with the correct name ("cat /mnt/data/Torrents/extract.sh" shows the content of the script), then I'm out of ideas.
Re: Unrar and cleanup script - UPDATE 2011.06.29
Well, I am having some issues with this script. I have been able to get it to work 100% when I execute the script from terminal - "bash posttorrent.sh" will extract the .rar and if the variable torrent id is changed with a 1, it will delete the torrent as well. The log file also shows that it has been called.
Code: Select all
root@dlink-4C13E6:/mnt/HD/HD_a2/.transmission-daemon# ls -l
total 44
drwxr-xr-x 2 nobody allaccount 4096 Aug 18 05:12 blocklists
-rwxrwxrwx 1 nobody allaccount 2171 Aug 19 03:05 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
# Username for transmission remote.
TR_USERNAME="admin"
# Password for transmission remote.
TR_PASSWORD="*edited*"
# 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 $( 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
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
} &
Code: Select all
"script-torrent-done-enabled": true,
"script-torrent-done-filename": "/mnt/HD/HD_a2/.transmission-daemon/posttorrent.sh",
Code: Select all
[04:17:35.656] *edited* Calling script "/mnt/HD/HD_a2/.transmission-daemon/posttorrent.sh" (torrent.c:1909)
Re: Unrar and cleanup script - UPDATE 2011.06.29
@dashy: Hmmm ... you've edited out the keep/sleep functionality, which is not unimportant. What are the actual problems with that segment of the script?
Re: Unrar and cleanup script - UPDATE 2011.09.10
I have updated the start post with a new script.
I encountered a few .part1.rar torrents. Support for these is implemented ( as well as .part0001.rar ) so they are properly handled.
I encountered a few .part1.rar torrents. Support for these is implemented ( as well as .part0001.rar ) so they are properly handled.