Auto Extract Script

Status
Not open for further replies.

zipfel

Dabbler
Joined
Dec 16, 2013
Messages
25
Hi there,

I would like to create a script so that when my torrent finishes downloading it auto extracts.

Here is what I have got so far with no luck.

I followed a tutorial from the transmission website here.

I had to edit my settings.json in my transmission jail accordingly as well with the service stopped. Restarted the service and nothing happened. Checked var/logs/ didnt see anything.

so I attempted to just create a bash script on my own and its been many years so i made a simple one and tried to execute it within my jail and this is what i get:

Code:
root@bit_1:/ # unrarr.sh                                                                                         
/bin/unrarr.sh: 6: Syntax error: newline unexpected  


and the contents of my script file

Code:
#!/bin/bash
#
echo "hello world"


I just wanted to do a simple test to see if that would execute but it did not. So I am not sure what to do here. My goal is to have every torrent i download be auto extracted for me.

Here is what I have so far for my own bash script to do this:

Code:
 #!/bin/bash
#
SRC_DIR="${TR_TORRENT_DIR}/${TR_TORRENT_NAME}"
 
 DEST_DIR="${TR_TORRENT_DIR}"
 
 RAR="$(find "$SRC_DIR" -type f -iname "*.rar")"
 
 unrar e RAR
 


I know this isn't a bash forum (pardon the pun) but i was hoping this would extract any newly completed torrents and move them to the main download folder. However, I cannot seem to execute even the most simplest of bash scripts??

Can any one help?
 

Rand

Guru
Joined
Dec 30, 2013
Messages
906
what happens if you run
chmod +x unrarr.sh
./unrarr.sh
in the path where ur script is
 

zipfel

Dabbler
Joined
Dec 16, 2013
Messages
25
@Rand - now it is saying command not found? I attached a screen shot.

I attempted to install bash but I did not use the the recommended way of using "pkg install" (I forget off the top of my head what I used)

I am beginning to think that I will have to delete this jail and start fresh.

@Yatti420 - Most of my downloads come in .rar, r01, ro2 etc. I am sure I could add more functionality to my script eventually, I just want to get anything to work at this point lol. Why? What were you thinkin'??
 

Attachments

  • freenas.script.png
    freenas.script.png
    15.9 KB · Views: 479

Rand

Guru
Joined
Dec 30, 2013
Messages
906
well if u dont have bash then calling /bin/bash is no good.
use the appropriate shell you have in that jail
or call it with <path/to/shell>/unrar.sh
 

zipfel

Dabbler
Joined
Dec 16, 2013
Messages
25
There we go. I was able to get it to execute the script. Thanks Rand.

Code:
root@bit_1:/ # echo $SHELL                                                                                                         
/usr/local/bin/bash                                                                                                                                                  
root@bit_1:/ # /usr/local/bin/bash ./unrar.sh                                                                                     
hello world


Now to test my auto unpack code :)
 

zipfel

Dabbler
Joined
Dec 16, 2013
Messages
25
Danm, didn't work.

I changed the first line in my auto extract script to !#/usr/local/bin/bash as i believe that has to point to where the shell is??

I didn't see anything in the logs so maybe logging isn't enabled for my transmission so I will have to figure that out and see if I can find an error message somewhere.

If anyone could help point a newb in the right direction, I'd much appreciate it.

Thank you,
 

N00b

Explorer
Joined
May 31, 2013
Messages
83
Shouldn't this:
unrar e RAR
Be:
unrar e $RAR
 

zipfel

Dabbler
Joined
Dec 16, 2013
Messages
25
Thanks N00b, I adjusted the code as you said but still nothing happened on completion of my torrent. :(
 

Rand

Guru
Joined
Dec 30, 2013
Messages
906
So your script works only if
${TR_TORRENT_DIR} and ${TR_TORRENT_NAME}
are set in environment when being called -

so add
echo ${TR_TORRENT_DIR}/${TR_TORRENT_NAME} >> /tmp/extract.log

to your script (make sure /tmp exists)
 

Durandal

Explorer
Joined
Nov 18, 2013
Messages
54
zipfel, any progress on getting this to work?
 

digil

Cadet
Joined
Nov 5, 2014
Messages
1
First post to bring this back from the dead, since I'm interested. I used a script shown here on my Buffalo LS-XL a couple years ago. Could this be used successfully with FreeNAS?
 
Status
Not open for further replies.
Top