Page 1 of 1
Help Request: Run Script From Synology NAS
Posted: 18 Aug 2014, 21:20
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)
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
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.
Any help will be appreciated. Thanks so much!
Re: Help Request: Run Script From Synology NAS
Posted: 19 Aug 2014, 07:56
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
Re: Help Request: Run Script From Synology NAS
Posted: 19 Aug 2014, 12:02
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
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

.
Re: Help Request: Run Script From Synology NAS
Posted: 19 Aug 2014, 22:53
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!
Re: Help Request: Run Script From Synology NAS
Posted: 20 Aug 2014, 03:22
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.
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.
Re: Help Request: Run Script From Synology NAS
Posted: 20 Aug 2014, 13:10
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?
Re: Help Request: Run Script From Synology NAS
Posted: 21 Aug 2014, 19:45
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!
Re: Help Request: Run Script From Synology NAS
Posted: 21 Aug 2014, 20:20
by christiankyte
Got it to work!
Re: Help Request: Run Script From Synology NAS
Posted: 12 May 2015, 02:09
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.
Re: Help Request: Run Script From Synology NAS
Posted: 30 Jun 2015, 14:34
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.
Re: Help Request: Run Script From Synology NAS
Posted: 30 Jun 2015, 14:47
by rednoah
This video should help with setting up Java on Embedded Linux:
https://www.youtube.com/watch?v=8N6hYNj_QzY