[Plugin] CA User Scripts


Recommended Posts

  • 2 weeks later...
On 4/6/2022 at 8:03 PM, Squid said:

It goes up and down a fair amount.  TBH I'm sick of doing plugin updates simply to fix a link

 

Just came here to report that dead corntab link. Seems that I'm not the first one ...

 

May I suggest to use a more generic link, like Wikipedia, instead of a private one. They are hopefully longer valid.

 

  • Upvote 1
Link to comment
  • 2 weeks later...

How do I run any CA Userscript Script from within a Terminal Session?
 

I know copies of scripts are held and ran from " /tmp/user.scripts/tmpScripts"....but when I go there via Terminal...I don't see ALL of my scripts listed (only a subset). It appears the only scripts listed here are ones which have been previously executed through Userscripts GUI.

I know scripts are also located in "/boot/config/plugins/user.scripts/scripts" but those are all buttoned up with permissions restricting run (probably for good reason too since its the flash drive).

Link to comment
39 minutes ago, Stupifier said:

How do I run any CA Userscript Script from within a Terminal Session?

Copy them from

39 minutes ago, Stupifier said:

/boot/config/plugins/user.scripts/scripts

to somewhere they can be made executable. The plugin copies them to

40 minutes ago, Stupifier said:

/tmp/user.scripts/tmpScripts

 

Link to comment
  • 3 weeks later...

Hey was just wondering is there anyway to increase the amount of line shown in the "show log" window? or is this a limitation of unraids popup windows.

 

i know its not hard to download the log and view its just when you do it 20 times gets a lil tedious, just one of the QOL things i was wondering

 

edit: i guess i could just look into getting log viewers setup if the above isnt possible where do the logs get stored?

 

thanks!

Edited by phyzical
Link to comment

Not sure if this is a bug or if I'm doing something wrong but... Has anyone noticed that if you set a script to run when the array is stopped then the script is not run when you shut down your server?. 

 

A bit of background. 

 

I'm running Unraid inside Proxmox and a bunch of other VMs use Unraid shares as storage so I want to orchestrate things so that when the array comes up the VMs are started with the storage mounted and if the array is stopped  then the VMs are shut down. It works great when I manually stop the array but if I instead want to shutdown Unraid then the script is not triggered even though one of the stages of shutting down is stopping the array. 

 

I've seen this with v6.9 and with the newest 6.10. The version of the User Scripts plugin is 2021.11.28. 

Link to comment
1 minute ago, Laucien said:

Not sure if this is a bug or if I'm doing something wrong but... Has anyone noticed that if you set a script to run when the array is stopped then the script is not run when you shut down your server?. 

It might be worth mentioning that you can have a ‘stop’ file that is similar to the ‘go’ file that is run near the end of the shutdown process.   Not very well documented.

  • Upvote 1
Link to comment
Just now, itimpi said:

It might be worth mentioning that you can have a ‘stop’ file that is similar to the ‘go’ file that is run near the end of the shutdown process.   Not very well documented.

 

Ah, interesting!. That could be a workaround for this. 

 

Just put it in the same location as the go file?. I'm guessing same owner and permissions as well. 

Link to comment
Just now, Laucien said:

 

Ah, interesting!. That could be a workaround for this. 

 

Just put it in the same location as the go file?. I'm guessing same owner and permissions as well. 

Yes.  
 

i have always wondered why a dummy file that does nothing is not included as standard.  

  • Upvote 1
Link to comment
13 hours ago, Laucien said:

Not sure if this is a bug or if I'm doing something wrong but... Has anyone noticed that if you set a script to run when the array is stopped then the script is not run when you shut down your server?. 

 

A bit of background. 

 

I'm running Unraid inside Proxmox and a bunch of other VMs use Unraid shares as storage so I want to orchestrate things so that when the array comes up the VMs are started with the storage mounted and if the array is stopped  then the VMs are shut down. It works great when I manually stop the array but if I instead want to shutdown Unraid then the script is not triggered even though one of the stages of shutting down is stopping the array. 

 

I've seen this with v6.9 and with the newest 6.10. The version of the User Scripts plugin is 2021.11.28. 

This actually appears to be a bug in the OS.

Link to comment

Trying to get a script working. It seems to be ignoring stuff that works if I do it manually. I thought at first it was ignoring back ticks, but it's not that. Take this section:

 

SOURCE=https://<my database url including auth>
echo `date` # works fine
SRC_DBS=`curl -s -X GET $SOURCE/_all_dbs | sed 's/\[//;s/\]//;s/"_[a-z]*"//g;s/[,\"]/ /g'` # works elsewhere
echo "$SRC_DBS" # nada :(

 

EDIT: Sussed the cause, at least. It doesn't like the SSL cert. It is valid, so I guess it must be that the local CAs need updating? Adding `-k` to the curl statement sorts it, for now...

Edited by banterer
Link to comment

Hi,

 

I'm trying to create a script that gets executed every 5 seconds, to control PWM fan speed.

Because Cron doesn't give enough granularity, I had to resort to the watch command.

 

I have created a "parent" script that invokes the watch command with the main script as argument, like this:

#!/bin/bash
INTERVAL=5
watch --interval $INTERVAL bash /boot/config/plugins/user.scripts/scripts/hdd_fans_control/script


If I execute the parent script manually from the command line, like this:

bash /boot/config/plugins/user.scripts/scripts/parent/script

 

everything works as expected.

 

While if I execute the parent script via the "Run Script" or "Run in background" buttons from the User Scripts page, the script doesn't work.

With "Run Script" I just get an empty output and nothing happens, while if I use "Run in background" (which is how I intend to run the script eventually) I get this output:

Script Starting May 29, 2022  11:09.54
Full logs for this script are available at /tmp/user.scripts/tmpScripts/parent/log.txt
Error opening terminal: unknown.
Script Finished May 29, 2022  11:09.54
Full logs for this script are available at /tmp/user.scripts/tmpScripts/parent/log.txt

 

@Squid do you know how to fix it? What am I doing wrong?

 

Thanks

Andrea

Link to comment

@Squid thank you for a great plugin, which I personally use every day and that enables myself and the community to run our servers in such customised ways!

 

Out of curiosity, which version of cron is currently used by the plugin? when using crontab.guru it warns that some expressions are not standard and may not run. Do you have experiences with using expressions such as 'run every 3rd month, Jan-Dec'?

Link to comment

I'm having a weird issue.  I have strips installs, did it a while back and put some scripts in place.  Just went in to settings cause I wanted to check one of them and there is no icon for me to click, it's like it's not installed on my system.  If I click on it from the plugins page just goes to /Settings/Userscripts, but it's a blank page.  Thoughts?  Are my scripts even still running or are they gone?

 

Screenshot 2022-06-07 200235.png

Screenshot 2022-06-07 200124.png

Screenshot 2022-06-07 200046.png

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.