[Plugin] CA User Scripts


Recommended Posts

2 hours ago, ProphetSe7en said:

1) how can I get the script to show the same info it would if I ran the commands from the script directly into terminal?

 

It should.  But by design this is not run through a "terminal" or anything like that.  The output is technically html.  (Pretty sure I remember posting a user script that played PacMan in JavaScript at somepoint

2 hours ago, ProphetSe7en said:

2) How do I get the log button avaliable for the script like I have on other scripts?

Everything echo'd from your script is what constitutes the log

Link to comment

Is "At stopping of array" in User Scripts occur before, during, or after the array is stopping?  Same question with ""at start of array".

I would like to setup my unraid to switch on/off my JBOD (via APC control) that are all the UNRAID disks before/after UNRAID starts, but not sure it will work in the correct order to function properly.

Link to comment
On 2/10/2022 at 2:05 PM, Squid said:

Instead of 2-31 and 0-4,6 use 2,3,4,5 .... and 0,1,2,3,4,6

 

Hi again,

so, it took me a while, but unfortunately it does not work..

is that cron setting general to complicated, to long, or can there be something wrong on my system?

 

can I provide any additional information for analysis?

 

thanks in advance!

Link to comment

ok what now?

does that mean, i cannot use this?

neither

0 1 2-31 * 0-4,6

nor

0 1 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31 * 0,1,2,3,4,6

is working

but i really would like to exclude fridays (backups of some vms from a different host roll in) and the first day of the month (monthly parity check) with this setting.

 

any other suggestions?

Link to comment
  • 2 weeks later...

Is it possible to source in other files (with functions and/or presetted variables) into the main "script".

I'm tinkering with a script and would like a lot of functions to be in a different file to reduce the size of the actual script and keep the main-script clean and tidy. I noticed scripts that are running have their script copied to /tmp/user.scripts/tmpScripts. Will that affect sourcing in files difficult?

Link to comment

Users scripts not persistent on reboot. How to I get the script to run afte reboot? It works fine when I first apply the script but it will not run unless manually triggered after reboot. I have set to custom */1 * * * *. I also tried * * * * *

 

edit: It looks like user-scripts doesn't execute until the array is started. Anyway to do this regardless of array state?

Edited by xxnumbxx
Link to comment
1 hour ago, xxnumbxx said:

edit: It looks like user-scripts doesn't execute until the array is started. Anyway to do this regardless of array state?

No.  Not because it's not an easy thing to do, but mainly because I don't want to deal with the inevitable support requests caused by that.

 

Edit the "go" file (/config/go on the flash drive) to accomplish this

Link to comment
On 3/6/2022 at 4:55 PM, Squid said:

No.  Not because it's not an easy thing to do, but mainly because I don't want to deal with the inevitable support requests caused by that.

 

Edit the "go" file (/config/go on the flash drive) to accomplish this

Fair enough. Thank you.

Link to comment

I'm not sure this is the right place to post my question because I can't create a new topic under the application support/plugins section.
I've created 2 user scripts, say script A and B, under CA User Scripts plugin. Script B is supposed to be called by several scripts with passing arguments. In this case, Script A will call script B and also pass 4 arguments to B. I know how to do it under native Debian bash script, but I don't know how to acheive this under CA User Scripts plugin.
Would appreciate any guidance.

 

update: I found the solution, to call other script defined in CA User Script, e.g. to call script named "subscriptB":

sh /boot/config/plugins/user.scripts/scripts/subscriptB/script arg1 arg2 arg3 .....

Edited by bthoven
to add solution
Link to comment
19 hours ago, bthoven said:

update: I found the solution, to call other script defined in CA User Script, e.g. to call script named "subscriptB":

sh /boot/config/plugins/user.scripts/scripts/subscriptB/script arg1 arg2 arg3 .....

Yeah, nothing on the flash drive is directly executable, so the sh (or /bin/bash) is required

Link to comment

I'm using the CA User Scripts plugin with some scripts that are scheduled to run in the background. Works great for my backup script.

 

There's a "Show log" button for the script, but it only shows the last 41 lines or so from the log. I know I can go into the full log at /tmp/user.scripts/tmpScripts/scriptname/log.txt, but is there a way to lengthen the number of lines that the "Show log" button shows?

Link to comment

Only just started to really use this plugin and dropped adding scripts to crontab.  Kicking myself for not migrating to this earlier.

 

Quick question.  I have a need to add an entry to the hosts file of about 3 dockers after they start up (a server i am trying to reach has had it's domain name snatched so a hosts file entry is the only way to get to it).

 

Is there a way I can trigger CAUS to to run a script upon docker start?  Or maybe 5/10 mins after array start?

While I am at it, any tips on writing a script that can be run from the console to had hosts entries in docker containers?  Or is there a simpler way to do it?

Link to comment
1 hour ago, dalben said:

 

Is there a way I can trigger CAUS to to run a script upon docker start? 

Reverse your logic and it's pretty easy.

 

echo "_waiting 5 minutes"
                        sleep 300

echo "_starting Container X"
                       /usr/bin/docker start (container X)

echo "_starting Container Y"
                       /usr/bin/docker start (container Y)

echo "_starting Container Z"
                       /usr/bin/docker start (container Z)

echo "_modifying hosts"

                     ?command to add hosts entry?

 

Disable auto start for the containers, set the script to start at array start, it waits 5 minutes, starts the container(s), then does your hosts thing.

 

1 hour ago, dalben said:

While I am at it, any tips on writing a script that can be run from the console to had hosts entries in docker containers?

 

Sorry, no help there. Why does it have to be limited to those containers, and why only after start? Couldn't you just do the magic in your router, or in Unraid itself?

  • Thanks 1
Link to comment
7 hours ago, JonathanM said:

Reverse your logic and it's pretty easy.

Thanks, that makes sense.

 

7 hours ago, JonathanM said:

 Couldn't you just do the magic in your router, or in Unraid itself?

Didn't think of that, but yes, I'll try the Unraid way first.  Makes life a lot easier

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.