Page 1 of 1

Copy + Delete

Posted: November 18th, 2010, 2:40 pm
by Infi
I'm trying to work around what appears to be a limitation of my Synology diskstation, but I'm not having much luck at the moment.

I posted my original problem here.

Instead of trying to create a script to adjust the permissions, it's probably easier to download the files to a different location and then copy them into their destination folder.  That way they'll inherit all the permissions I want them to.

I've had a bit of a browse around here and various other places, but I'm still not sure how to get the script to run (it keeps failing at the moment).

I've tried doing a move command as a test to see if I've got the commands right, but I'm obviously doing something wrong 'cos it isn't working.  I'm sure I read something in the past about the file extension, but I've seen references to both .py and .sh while hunting for an answer.  What I've got so far:

filename=copy.py

Code: Select all

#!/bin/bash
mv $1 /volume1/Recordings/Shared
Which just results in "Cannot run script /volume1/SABnzbd/Scripts/copy.py"

Now I'm aware that (with Windows at least) a move command will retain its file permissions, which obviously won't help in the long run as I'll still be stuck with the wrong permissions, and I understand that I can just replace mv with cp to get the files in the right location, but I'm not sure how to delete the source files after I've copied them to their destination.

Anyway, I'm hoping someone can point me in the right direction.

Cheers

Re: Copy + Delete

Posted: November 18th, 2010, 6:02 pm
by rascalli
HAve a look if the user running SABNZBD+ has permission to execute the script

Re: Copy + Delete

Posted: November 18th, 2010, 8:19 pm
by premiso
Given that you have the #!/bin/bash it should be .sh extension.

As far as the problem, well first up, you need to specify the ending /:

Code: Select all

#!/bin/bash
mv $1 /volume1/Recordings/Share/
If you do not do this, it will attempt to write to Share, so Share would be a file or throw an error stating it is a directory.

To change the permissions simply add a chmod after:

Code: Select all

#!/bin/bash
mv $1 /volume1/Recordings/Share
chmod 0644 /volume1/Recordings/Share/$1
Just set 0644 to what you need it to be. Hopefully this gets you going.

EDIT:
Finally, you need to make sure that your script.sh has been chmod'ed to be executable (chmod +x yourscript.sh)  or else it cannot be executed.

Re: Copy + Delete

Posted: November 19th, 2010, 11:31 am
by Infi
Thanks for the replies.

I must be doing something wrong somewhere, because if I assign the script to a newzbin category, it utterly fails to run.  If however I assign it as the main script under Switches, I just get the "Cannot run script" error.

I've logged in via telnet and run chmod +x /volume1/SABnzbd/Scripts/copy.sh

The script itself is just:

Code: Select all

#!/bin/bash
mv $1 /volume1/Recordings/Shared/
I've set SAB to download to the default 'public' share which still has Linux permissions, and everyone has access.  I've even gone in and done a chmod -R 777 just to make sure everyone has permission.  SAB is still setting its own permission even there though as I can't (without logging into the  NAS web interface) delete the files i'm test-downloading.

I've had a quick look through the logs, and I can see an error number there which I'm hoping means someone can tell me what I'm doing wrong.

Code: Select all

16:03:22,037::INFO::[postproc:243] Starting PostProcessing on (Some)_File__(1991) => Repair:True, Unpack:True, Delete:True, Script:copy.sh
2010-11-19 16:03:22,040::INFO::[postproc:134] Saving postproc queue
2010-11-19 16:03:22,039::INFO::[postproc:247] Par2 check starting on (Some)_File__(1991)
2010-11-19 16:03:22,051::INFO::[postproc:254] Running repair on set Some File,   (1991)
2010-11-19 16:03:22,071::INFO::[newsunpack:664] Quick-check for Some File,   (1991) is OK, skipping repair
2010-11-19 16:03:22,075::INFO::[newsunpack:721] Deleting /volume1/SABnzbd/Downloads/(Some)_File__(1991)/Some File,   (1991).par2
2010-11-19 16:03:22,077::INFO::[newsunpack:735] Deleting /volume1/SABnzbd/Downloads/(Some)_File__(1991)/Some File,   (1991).vol00+1.par2
2010-11-19 16:03:22,091::INFO::[postproc:271] Par2 check finished on (Some)_File__(1991)
2010-11-19 16:03:22,095::INFO::[misc:837] Creating directories: /volume1/public/(Some)_File__(1991)
2010-11-19 16:03:22,099::INFO::[postproc:315] Running unpack_magic on (Some)_File__(1991)
2010-11-19 16:03:22,131::INFO::[downloader:724] Thread [email protected]:443: forcing disconnect
2010-11-19 16:03:22,146::INFO::[newsunpack:185] Unrar starting on /volume1/SABnzbd/Downloads/(Some)_File__(1991)
2010-11-19 16:03:22,149::INFO::[newsunpack:384] Extracting rarfile /volume1/SABnzbd/Downloads/(Some)_File__(1991)/Some File,   (1991).part1.rar (belonging to Some File,   (1991)) to /volume1/public/_UNPACK_(Some)_File__(1991)
2010-11-19 16:03:32,796::INFO::[newsunpack:564] Skipping unrar file check due to unreliable file names or old unrar
2010-11-19 16:03:32,799::INFO::[newsunpack:568] Unpacked 1 files/folders in 10 seconds
2010-11-19 16:03:32,801::INFO::[newsunpack:407] Deleting /volume1/SABnzbd/Downloads/(Some)_File__(1991)/Some File,   (1991).part1.rar
2010-11-19 16:03:32,807::INFO::[newsunpack:407] Deleting /volume1/SABnzbd/Downloads/(Some)_File__(1991)/Some File,   (1991).part2.rar
2010-11-19 16:03:32,812::INFO::[newsunpack:407] Deleting /volume1/SABnzbd/Downloads/(Some)_File__(1991)/Some File,   (1991).part3.rar
2010-11-19 16:03:32,818::INFO::[newsunpack:407] Deleting /volume1/SABnzbd/Downloads/(Some)_File__(1991)/Some File,   (1991).part4.rar
2010-11-19 16:03:32,840::INFO::[newsunpack:189] Unrar finished on /volume1/SABnzbd/Downloads/(Some)_File__(1991)
2010-11-19 16:03:32,844::INFO::[postproc:317] unpack_magic finished on (Some)_File__(1991)
2010-11-19 16:03:32,865::INFO::[newsunpack:127] Running external script /volume1/SABnzbd/Scripts/copy.sh(/volume1/public/(Some)_File__(1991), (Some)_File__(1991).nzb, (Some)_File__(1991), , None, alt.binaries.multimedia.cartoons.looneytunes, 0)
2010-11-19 16:03:32,985::INFO::[newsunpack:134] Failed script /volume1/SABnzbd/Scripts/copy.sh, Traceback: 
Traceback (most recent call last):
  File "/volume1/@appstore/sab2/SABnzbd-0.5.6/sabnzbd/newsunpack.py", line 132, in external_processing
    startupinfo=stup, env=env, creationflags=creationflags)
  File "/var/packages/sab2/target/utils/lib/python2.5/subprocess.py", line 594, in __init__
    errread, errwrite)
  File "/var/packages/sab2/target/utils/lib/python2.5/subprocess.py", line 1097, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
2010-11-19 16:03:33,071::INFO::[postproc:470] Cleaning up (Some)_File__(1991)
2010-11-19 16:03:33,081::INFO::[__init__:702]