[Plugin] CA User Scripts


Recommended Posts

35 minutes ago, Squid said:

The plugin has never executed scripts directly from the flash drive

Ahh, but I call other CA User Scripts from their location on the flash drive.

 

Here is one of my scripts that runs at array start.

#!/bin/bash
echo "/boot/config/plugins/user.scripts/scripts/StartVM/script" | at now

I do it like that because if I call the StartVM script directly at array start, it hangs the array starting process, calling it this way works fine.

 

What path should I use instead of /boot/config/... ?

Link to comment
10 minutes ago, jonathanm said:

What path should I use instead of /boot/config/... ?

You have to either copy them say to /tmp and reference that (and change the permissions appropriately) or change the line to

echo "/bin/bash /boot/config/plugins/user.scripts/scripts/StartVM/script" | at now

 

Calling a script on the flash drive directly will run afoul of the security, because even though the plugin has never executed scripts directly from the flash, it has no control over what the script actually does.

Edited by Squid
Link to comment
6 minutes ago, itimpi said:

If you run your own scripts directly from the flash drive then you have to do something to get them to run correctly.

So appending the /bin/bash like Squid says before the path to the script is sufficient? I'm not running the script directly, I'm running them from another user script using the at now technique.

 

I have a bunch of conditional startup scripts that take care of timing of various VM and container launches, since Unraid doesn't provide a way of managing that sort of thing in the GUI.

 

All this is on my 6.7 box, I haven't played around with it on my test boxes yet, but I want to make sure all my ducks are in a row before I apply 6.8.

 

I'm hoping instead of making me do all the testing and validation work, you guys will just tell me how to make it work and I can be lazy. 😁

Link to comment
2 minutes ago, jonathanm said:

appending

prepending ;) 

 

2 minutes ago, jonathanm said:

is sufficient?

Yes

 

3 minutes ago, jonathanm said:

I'm not running the script directly, I'm running them from another user script using the at now technique.

You actually are running it directly (via the user script)

Link to comment
  • 2 weeks later...

looking for a bit of scripting help...

 

I am trying to fetch a TV Guide (xml file) that is around 40Mb. The server is unreliable.

 

using this:

curl -L --limit-rate 200K "http://provider.url/epg?username=un&password=pw" --speed-time 15 --speed-limit 1000 -o /mnt/user/appdata/tvheadend/data/cronIPTV_EPG.xml


I have run this multiple times my so I know the syntax is OK. but about 3 in 5 fail!!!

 

output:

curl: (28) Operation too slow. Less than 1000 bytes/sec transferred the last 15 seconds

 

How do I wrap this command in a loop so that it will try 10 times if it falls over with the "operation too slow" error?

 

 

 

 

 

Link to comment

Hello,

I usually use user script for various backup tasks.

For the need of my home automation system i have to run a python script which is intended to listen push on a port.

The script can be found here.

I have nerdpack plugin installed. When i launch the script i have the following error.

Quote

Script location: /tmp/user.scripts/tmpScripts/Bridge_Jeedom_InfluxDB.py/script
Note that closing this window will abort the execution of this script
Traceback (most recent call last):
File "/tmp/user.scripts/tmpScripts/Bridge_Jeedom_InfluxDB.py/script", line 5, in
from http.server import BaseHTTPRequestHandler, HTTPServer
ImportError: No module named http.server

How can i install this module ? I thought it was included.

Can I launch python script with user script ?

How can i make the script running in background ? It needs to listen to push events.

Link to comment

I think i solved my problem.

i had to change the first line

from

#!/usr/bin/python

to

#!/usr/bin/python3

I also had to install influxdb in a shell window:

pip3 install influxdb

Now i'm waiting for the first push to come.

If i understand right the script has to be lauched with "&" at the end off the command line in order to run without the window opened.

My bad the "run in background" button is huge but i had not seen it.

So i started the script with run un background. I also sheduled a run at array startup

 

Link to comment
  • 2 weeks later...

I'm trying to run a python script every minute with this plugin but I cannot get it to work.

I created a new entry, set scheduling to custom with `* * * * * *` as expression. The content of the script is

#!/bin/bash
/usr/bin/python3.7 /mnt/user/walzen/nzbget_download_rate.py

Running manually (clicking on "Run Script" or "Run in Background") works perfectly fine but for some reason it doesn't execute automatically. I have other cron jobs (bash scripts) that are working normally.

Link to comment
  • 2 weeks later...

So I was using User Scripts as normal, but after manually running and cancelling a script the page now seems to be broken.

 

This is all that is shown.  "Appdata Backup" was one of my scripts but the description appears to be the html for the entire page.

US.PNG.33190a81512f36455eb0be49057e1636.PNG

 

I tried uninstalling and reinstalling the plugin without any change.  I've also checked with another browser with the same result, so it doesn't appear to be a browser cache issue.  How would I fix this?

Link to comment
1 hour ago, Xe138 said:

So I was using User Scripts as normal, but after manually running and cancelling a script the page now seems to be broken.

 

This is all that is shown.  "Appdata Backup" was one of my scripts but the description appears to be the html for the entire page.

US.PNG.33190a81512f36455eb0be49057e1636.PNG

 

I tried uninstalling and reinstalling the plugin without any change.  I've also checked with another browser with the same result, so it doesn't appear to be a browser cache issue.  How would I fix this?

Not much suggestion on this fine and glorious night other than a reboot.   No idea atm what went went  wrong here.   

 

But, do there happen to be anything luke quotes in the name of the script?

Link to comment

I want to use a script to run a rsync command, but I also want to run this from a screen, so I can check the progress at any time with screen -r. I have several backup scripts for each share that I want to backup.

 

I'm having some issue getting screen to work. This is how the script looks now:

#!/bin/bash

export SCREENDIR=/root/.screen
screen -dmS rsyncdms 

echo "Job '[job name]' started"

rsync [with parameters etc]

/usr/local/emhttp/webGui/scripts/notify -s "Job '[job name]' finished at $(date '+%Y-%m-%d %H:%M')"

So it needs to do 3 things (echo, rsync and notify). When I run the script from the User Scripts page with the Run Script button, it works perfectly. But when I run it in the background and then try to view the status with 'screen -r' in a terminal, I just get a blank terminal with a prompt. I read it's because you need to put something immediately behind the 'screen -dmS rsyncdms' command, but then it still doesn't work.

 

How can I get these 3 things to be executed in order, all within its own screen session? I saw another post where someone made a new user script and within it called the .sh file, but I want to integrate the screen function within the backup script itself, if possible.

Link to comment
13 hours ago, Squid said:

Not much suggestion on this fine and glorious night other than a reboot.   No idea atm what went went  wrong here.   

 

But, do there happen to be anything luke quotes in the name of the script?

I found the problem.  Somehow the description for the script was saved with an html tag in it.

<textarea id="newDescdescAppdataBackup" cols="40" rows="5">Backup of appdata to array

 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.