Help Request: Run Script From Synology NAS

Any questions? Need some help?
Post Reply
christiankyte
Posts: 6
Joined: 18 Aug 2014, 21:00

Help Request: Run Script From Synology NAS

Post by christiankyte »

Hello,

So I have a working CLI "code" that I have tested via ssh and it does what I need. However I want to automate this when a my Synology NAS finished a torrent download via its built in DownloadStation. Here is what I have done thus far:

I have edited the settings.son file for download station and directed it to run the script via completion of download (/usr/syno/etc/packages/DownloadStation/download/settings.json)

Image

Then I made a file in that location and typed out the same thing I tested while using it via SSH

Code: Select all

filebot -script fn:mac --output "/volume1/Movies" --def "seriesFormat=/volume1/TV Shows/{n}/{'S'+s}/{fn}" "movieFormat=/volume1/Movies/{n} {y}/{fn}" --action copy -non-strict "/volume1/Downloads" --log-file /volume1/System/amc.log --conflict skip --def xbmc=192.168.1.203 --def excludeList=amc.txt
Image

So I do not know if I need to append the script with something (like a header) to get it to run or not. I have even tried running the script manually via the synology task scheduler and it does not work. No logs are affected.

Here is showing what happens when I run it via ssh.

Image

Any help will be appreciated. Thanks so much!
User avatar
rednoah
The Source
Posts: 22998
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Help Request: Run Script From Synology NAS

Post by rednoah »

This is the general issue:
I have even tried running the script manually via the synology task scheduler and it does not work.
My thought are:
* Script doesn't specify the shell it should be run with: #!/bin/sh
* Logged in as "admin" it works, but does it work as whatever user DSM runs these scripts?
* Make sure you're redirecting all stdout AND stderr (there never is no output if something doesn't work, most people forget to redirect error output and thus never see any errors)
* You're calling "filebot" and "filebot" is calling "java" so you need to make sure these tools can be found by name, not just in your shell environment, but in the shell environment DSM executes scripts.

PS: it's (almost) always a PATH issue
:idea: Please read the FAQ and How to Request Help.
f3bruary
Posts: 35
Joined: 16 May 2014, 11:33

Re: Help Request: Run Script From Synology NAS

Post by f3bruary »

The issue could also lie with permissions. I think transmission executes the script itself so the 'transmission' user should have the proper read+execute permission for the script and it might need read+write permission for your media folders.

I had trouble running the script via cron and the Synology task scheduler. The solution in my case was to remove all installations of Filebot and add the repository rednoah made for synology, then install that version using the package manager.

PS: You can edit

Code: Select all

/var/packages/transmission/scripts/start-stop-status
and change the following line where it defines the user (USER="transmission") to

Code: Select all

USER="admin"
That way it will run as admin and some permissions issues will be solved too. You probably need to do

Code: Select all

chown -R apps:users /var/packages/transmission
and

Code: Select all

chown -R admin:users /volume1/@appstore/transmission
too otherwise admin doesn't have the proper permission to run transmission ;).
christiankyte
Posts: 6
Joined: 18 Aug 2014, 21:00

Re: Help Request: Run Script From Synology NAS

Post by christiankyte »

So I tried adding the #!/bin/sh and no luck yet.

I can still run it via ssh despite what account I use to log in, root / admin / user. What are some commands I can use to redirect the outputs for debug? and what are some exact steps I can use to try. I am a system control engineer so I program robots and automation cell. Linux is not within my scope. Thanks!
User avatar
rednoah
The Source
Posts: 22998
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Help Request: Run Script From Synology NAS

Post by rednoah »

Output?
* Make sure you're redirecting all stdout AND stderr (there never is no output if something doesn't work, most people forget to redirect error output and thus never see any errors)
Output?
You're calling "filebot" and "filebot" is calling "java" so you need to make sure these tools can be found by name, not just in your shell environment, but in the shell environment DSM executes scripts.

Image


PS: When I say It's a PATH issue! you know what that means right? Because it is a PATH issue. Once you get output it'll say "filebot" command not found, or "java" command not found, and you'll start using absolute paths or link to /usr/bin to make it work.
:idea: Please read the FAQ and How to Request Help.
christiankyte
Posts: 6
Joined: 18 Aug 2014, 21:00

Re: Help Request: Run Script From Synology NAS

Post by christiankyte »

Thank you again for the reply. It is truly appreciated.

As far as the

Code: Select all

/volume1/app/scripts/build-data >> /volume1/app/scripts/build-data.log 2>&1 
Is that added above my path to my script file "/volume1/System/FilebotScript.sh" or after it? Am I assuming correct that once I run it manually and it fails out I will be able to access /volume1/app/scripts/build-data.log to see the logs? Is this correct?
christiankyte
Posts: 6
Joined: 18 Aug 2014, 21:00

Re: Help Request: Run Script From Synology NAS

Post by christiankyte »

So I did what you suggested and here is the problem!

Code: Select all

/usr/syno/bin/filebot: line 35: java: not found
How can I find where java is located?

Also where does FileBot keep its settings.son file?

Thanks!
christiankyte
Posts: 6
Joined: 18 Aug 2014, 21:00

Re: Help Request: Run Script From Synology NAS

Post by christiankyte »

Got it to work!
garyleecn
Donor
Posts: 114
Joined: 19 Nov 2014, 03:48

Re: Help Request: Run Script From Synology NAS

Post by garyleecn »

christiankyte wrote:Got it to work!
how did you managed to get it to work??


I'm basically having the same problem, having running ssh scripts, but can't let it run itself.
Brailyn
Posts: 7
Joined: 17 Jun 2015, 02:17

Re: Help Request: Run Script From Synology NAS

Post by Brailyn »

how did you managed to get it to work??
Are you getting the same Java error?

Run "java -version" and "which java" and see what they say. Do the same for filebot.

I have a feeling some of the paths for java are messed up as they were for me.
User avatar
rednoah
The Source
Posts: 22998
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Help Request: Run Script From Synology NAS

Post by rednoah »

This video should help with setting up Java on Embedded Linux:
https://www.youtube.com/watch?v=8N6hYNj_QzY
:idea: Please read the FAQ and How to Request Help.
Post Reply