vletroye / Mods

Mods can be used to Create or Open/Edit and Generate packages for Synology
Microsoft Public License
86 stars 10 forks source link

Q/REQ: Trigger scheduled task manually or run an SSH command #19

Closed quadcom closed 3 years ago

quadcom commented 3 years ago

Hey there, awesome work!

I'm trying to figure out how I would go about triggering a scheduled task or running the script that the task calls?

I use Filebot and instead of scheduling its run, I want to run it manually on demand. The problem is I have to go into the scheduled tasks area each time to run it. I am looking for a way to have a shortcut, either on the desktop or taskbar that I can hit to fire the script.

Can this be done with your app builder?

quadcom commented 3 years ago

Trying to get init 3rdparty installed via the CPHub community and I get an error. The current version available is 1.9-003.

Failed to install "init 3rdparty"

Please install and run at least one PHP version via the package center before installing this package.

I've installed PHP7.4 and 7.3. Both are running according to Package Center. Not sure what else to do from here.

Any ideas?

vletroye commented 3 years ago

You should do a package with MODS to run a bash command. The same command as scheduled via the Task Scheduler. I am also using filebot, so it should be something like: /usr/local/filebot-node/task 1

Regarding "init 3rdparty", are you using nginx or apache as default web server ?

vletroye commented 3 years ago

I did create a sample "MODS Filebot Runner" that you can download from here

It's executing /usr/local/filebot-node/task 1 without dependency on "init 3rdparty" and apache. Instead, it's depending on nginx and the trick explained here to redirect all calls via a kind of "proxy cgi".

NB.: as filebot takes quite some time to start, wait long enough to see the output ;) I didn't succeed to force a flush line by line of the stdout buffer And you will have to cleanup on the various installation scripts, etc...

image

quadcom commented 3 years ago

Thanks very much, vletroye, now being a total noob I need to wrap my head around this.

As far as Apache or NGINX, aside from the Synology UI I'm not running any webserver at all meaning, I don't have any websites being hosted on the box. Not sure if this is what you mean. If it were possible to modify the server driving the Synology UI to use NGINX I had no idea that was even possible.

As it stands I couldn't get init 3rdparty installed due to this dependency that I couldn't solve. Could it be that I need to install Apache/NGINX packages with PHP even though I host no sites? Are there security concerns by doing that?

vletroye commented 3 years ago

The "init 3rdparty" will only work if you installed the "Web Station".

But the new package that I created for you "MODS Filebot Runner" does not require the "Web Station" (and hence, not need for init 3rd Party). Alos, nginx is installed by default within DSM nowadays...

Be sure to use this SPK

quadcom commented 3 years ago

Hey vletroye, I seem to be stuck. So I DL'd the spk and did a manual install on the DS. Everything installed after I got PHP installed but I couldn't figure out what to do after that.

There wasn't anything new in the app drawer and I couldn't see anything in the SPK that I could edit to set which script is run nor could I determine how the shortcut is placed on the desktop.

My apologies for being the noob here. I know enough to break things pretty good.

vletroye commented 3 years ago

Hi

First, double check that FileBot Runner is well installed within the Package Center

image

Regarding the configuration of the task to be run, you must edit the file mods.sh in the SPK (with MODS) before installing it! You can also edit that file after installation via a SSH console. I recommend the text editor 'Nano' instead of vi if you are not comfortable with linux ?! Nano is a package that can be installed via the Community

image

To edit the file mods.sh via SSH, type:

nano /var/packages/MODS_Filebot_Runner/target/ui/mods.sh

You can also test that it works fine, still via SSH, typing:

sh /var/packages/MODS_Filebot_Runner/target/ui/mods.sh

Once the package properly installed, you should have this new icon in the main DSM menu:

image

If you don't see it, refresh the page with CTRL-F5 in your browser (re-login into DSM). If you still don't see the icon, clear the cache of your browser and than CTRL-F5 again.

Kind regards,

V.

quadcom commented 3 years ago

Hmmm, real head-scratcher here. I installed Mods on my laptop and DL'd the Filebot Runner Package. I opened the folder that the Filebot Runner was in and manually edited the mods.sh file in Notepad++ to run the correct SSH script. I then ran the package/build and manually installed the SPK from that folder into the DSM. It installed without any errors and it says it's running but again, there's no icon in the app drawer.

I've logged out and back in. I've cleared the cache in Chrome but still no sign of it anywhere.

image

I checked the SH file with nano and it is configured correctly. image

I just can't see the icon in the drawer??

vletroye commented 3 years ago

You are not the first user reporting issues with the icons. But I never understood the reason for such issues... It could be that a previous version of the package failed to install and DSM keeps some memory of it ?!

Could you uninstall the package and then try this new version: https://www.beatificabytes.be/sspks/packages/MODS_Filebot_Runner_2.spk

I did change the name of the package so it won't be impacted by any previous versions. NB.: it is published (and so signed) on my Package Server : https://www.beatificabytes.be/sspks/

PS.: By the way, which build version of DSM do you have ?

quadcom commented 3 years ago

Hmmm, plot thickens. I DL'd the new SPK v2 you made, removed the installed one and installed the new.

All installed fine and it is running. I haven't checked the mods.sh yet.

Still no icon in the drawer??

My DSM version: image

vletroye commented 3 years ago

Ok, very same version as mine... That's not the pblm.

Do you have an adblocker? I saw once that it was the root cause for one user. Did you try with another browser: Edge or Internet Explorer ?

If you install another package, do you see the icon ?

quadcom commented 3 years ago

Figure it out!

Permissions!

By default no-one has permission to access the application. Giving everyone access allowed the icon to be shown in the drawer.

image

quadcom commented 3 years ago

LOL, one problem down, new problem arises. I edited the sh file with nano and confirmed the script path is correct.

image

Got a new error message

image

vletroye commented 3 years ago

This is because the php page does not run. Open the page in a new window. image

Then look at the error with the Chrome Debugger. I guess that the redirection created for nginx is not working for you...

quadcom commented 3 years ago

mods.php returning a 404

image

vletroye commented 3 years ago

Can you run this:
cd /var/packages/MODS_Filebot_Runner/target/ui/ php mods.php

vletroye commented 3 years ago

In order to run php pages stored in such folder, I create a config for nginx: dsm.cgi.conf This config is linked into the folder /usr/syno/share/nginx/conf.d/

Try: ls -l /usr/syno/share/nginx/conf.d/ Do you see something like: dsm.MOD_Filebot_Run.conf -> /volume1/@appstore/MOD_Filebot_Run/ui/dsm.cgi.conf

If you do, it means that nginx didn't take that file into account...

Try to restart nginx: sudo synoservice --restart nginx

quadcom commented 3 years ago

image

Yours - dsm.MOD_Filebot_Run.conf -> /volume1/@appstore/MOD_Filebot_Run/ui/dsm.cgi.conf Mine - dsm.MODS_Filebot_Runner_2.conf -> /volume1/@appstore/MODS_Filebot_Runner_2/ui/dsm.cgi.conf

Slight differences there. Could this be the problem??

Restarted NGINX and still no go.

I ran HTOP in another putty and watched NGINX restart. I then hard reloaded DSM UI and opened the FB shortcut in a new window. Same response as before. mods.php returns a 404.

image

PS. I should add that WebConsole works fine. Link opens right in the DSM UI

EDT: I just noticed it's trying to open

/webman/3rdparty/MODS_Filebot_Runner/mods.php

not

/webman/3rdparty/MODS_Filebot_Runner_2/mods.php

quadcom commented 3 years ago

I think if I remove v2 and install the original one, configure the SH file and ensure the app permissions are correct it should be fine.

I'll let you know.

EDIT: SUCCESS!!!!!

vletroye commented 3 years ago

Ok, great !!! And sorry, I probably did a mistake somewhere in my version 2...