[Plugin] CA User Scripts


Recommended Posts

3 minutes ago, HarryD said:

My issue is that i have a script i need to run scheduled in the background test.sh.

If i run the scripts from the userscripts page with the "run script" button it works with no issue.
However when i click "run in background" the script does not run, i have deleted the plugin and deleted it from the drive also, then reinstalled. I have a second unraid server with an identical script that runs flawlessly and now even the default scripts do not action.

 

below is the server log when i click "run script" and nothing happens

 

Jan 2 04:50:20 Email emhttpd: cmd: /usr/local/emhttp/plugins/user.scripts/backgroundScript.sh /tmp/user.scripts/tmpScripts/test/script

 

any help would be greatly appreciated.

Any punctuation in the description?

Link to comment
3 minutes ago, Squid said:

Any punctuation in the description?

i might miss-understand what you're saying? sorry if my original post was not clear.

When i attempt to run the script in the image below, clicking the "Run in background" button, nothing happens.

 

script is identical to the one i use on another unraid server without issues. however even the default scripts that come with the 'userscripts' plugin do not run in background.

image1.PNG

Link to comment
3 minutes ago, Squid said:

Give me a screenshot then of the entire page

full page screenshot, brings up "script running window" as normal but script does not actually run in background and doesn't bring up the usual "running"

image2.PNG

image3.PNG

image2.PNG

Edited by HarryD
Link to comment

I am trying to run some command and push them the in background but the GUI terminal seems to get stuck and the script doesn't really seem to finish (I do not see the echo in the window and running ps aux | grep avahi-publish show the process does not exist).

Any suggestions?

#!/bin/bash
#description=Generate avahi aliases
#foregroundOnly=true
#name=Avahi aliases (sub-domains)

echo "plex.inas.local"
/usr/bin/avahi-publish -a -R plex.inas.local $(avahi-resolve -4 -n inas.local | cut -f 2) &

 

Edited by sdfyjert
Link to comment
On 1/1/2021 at 1:33 PM, HarryD said:

full page screenshot, brings up "script running window" as normal but script does not actually run in background and doesn't bring up the usual "running"

image2.PNG

image3.PNG

image2.PNG

From what I remember that's normal. Otherwise there would be an error saying. If you close this box it will shut down the script. 

 

Simply click the close button it will continue running in the background. 

 

Link to comment

Trying to run a script that deletes all folders under a certain size (which works perfectly) but I need to exclude 1 folder and I can't get the syntax right.  Help?

 

#!/bin/bash
shopt -s extglob
du /mnt/user/media/Movies/ | awk '$1 <= 300000 { print "rm -rf -v \"" substr($0, length($1)+2) "\" !(".stfolder")"}' | sh
awk: cmd. line:1: $1 <= 300000 { print "rm -rf -v \"" substr($0, length($1)+2) "\" !(".stfolder")"}
awk: cmd. line:1:                                                                     ^ syntax error

 

Link to comment
5 hours ago, Fffrank said:

Trying to run a script that deletes all folders under a certain size (which works perfectly) but I need to exclude 1 folder and I can't get the syntax right.  Help?

 


#!/bin/bash
shopt -s extglob
du /mnt/user/media/Movies/ | awk '$1 <= 300000 { print "rm -rf -v \"" substr($0, length($1)+2) "\" !(".stfolder")"}' | sh

awk: cmd. line:1: $1 <= 300000 { print "rm -rf -v \"" substr($0, length($1)+2) "\" !(".stfolder")"}
awk: cmd. line:1:                                                                     ^ syntax error

 

Solved my own problem and wanted to post the solution.  I added the if statement for exclusion to the awk routine rather than asking asking the rm command to ignore.

 

du /mnt/user/media/Movies/ | awk '{ if ( $1 <= 300000 && $2 != "/mnt/user/media/Movies/.stfolder" ) print "rm -rf -v \"" substr($0, length($1)+2) "\"" }' | sh 

 

Link to comment
  • 2 weeks later...

So, I'm having some issues with a docker... those issues aside, I'm looking for a script to schedule a docker reboot regularly, such as every 2 hours or so. 

 

I have been working to resolve the core issue but thus far, the only resolution I have found is to restart the problem docker. anyone have a script that can accomplish this?

Link to comment

how do you organize the Scripts i tried renaming so the Scripts would resort alphabetical

 

as i got 20 scripts i trying to clean up  but i want to sort them  

like  

group them 

 

(computer1) does that script

(computer1) does this script

(computer 2 does this script)

(computer 3)

 

 

or is there a text file named "order" that shows the order of scripts so i can manually move them around to organize the scripts properly  group them

 

and how do you get it when you Change the user script name.. that it will change the actual File name too.. it doesnt do that.. it keeps the old script name

 

also be nice to sort by

Custom, Daily, Monthly

 

and also sort by 

Custom + File name 

Daily + Filename

Monthy + Filename

 

or have Breaks -------------------

between sets

 

Daily

script 1

script 2

------------------------

Monthly

script 3

script 4

--------------------------------

Daily

script 5

script 6

 

Edited by comet424
Link to comment

also is the dangling images script id is depreciated?

it doesnt work ..  

i tried different wayts

#docker rmi $(docker images --quiet --filter "dangling=true")
#docker rmi $(docker images -q -f dangling=true)
docker rmi $(docker images -f dangling=true -q)
 

if you run the command line  

docker rmi --help

 

there is no -q -f or dangling  as options  

so is that script depreciated 

Link to comment
  • 3 weeks later...

Hi i have a problem with the plugin user script. I used diacritics for some names. And now I can't remove these scripts and I can't set the cron function. Even after reinstallation, these scripts always appear there and cannot be deleted. Is it possible to reset this plugin to factory settings?

Link to comment
14 minutes ago, Acu said:

Hi i have a problem with the plugin user script. I used diacritics for some names. And now I can't remove these scripts and I can't set the cron function. Even after reinstallation, these scripts always appear there and cannot be deleted. Is it possible to reset this plugin to factory settings?

So I've figured it out just to rename the folder on the flash drive.
user.scripts.old
I couldn't delete it, but after renaming all the scripts disappeared.

Link to comment

Does anyone know of a way to setup a button in the GUI to 1-click run a script?

 

Custom Tabs does not seem to support this but something along those lines is what I am looking for.

 

Looking for a way to easily switch between power saving mode (which the server stays in 95% of the time) and performance (only when having it render or do something intensive).

 

Also be nice for some other uses as well such as a sync script I have, or snapshots etc

Link to comment
On 2/10/2021 at 7:51 AM, TexasUnraid said:

Does anyone know of a way to setup a button in the GUI to 1-click run a script?

 

Custom Tabs does not seem to support this but something along those lines is what I am looking for.

 

Looking for a way to easily switch between power saving mode (which the server stays in 95% of the time) and performance (only when having it render or do something intensive).

 

Also be nice for some other uses as well such as a sync script I have, or snapshots etc

 

Don't know if this is a starting point but you'd have to 1) implement your button into the GUI initially for testing, and 2) make it so that it is recreated upon reboot... then you may be able to get some ideas here

 

https://stackoverflow.com/questions/44443164/execute-a-shell-script-from-html

 

 

Link to comment
10 minutes ago, Energen said:

 

Don't know if this is a starting point but you'd have to 1) implement your button into the GUI initially for testing, and 2) make it so that it is recreated upon reboot... then you may be able to get some ideas here

 

https://stackoverflow.com/questions/44443164/execute-a-shell-script-from-html

 

 

 

Thanks, I was looking for something more integrated into unraid. Customtabs would work great if it had the option to run a script / command. Don't really want to do anything custom to the OS unless I have to.

 

I was hoping there was a plug-in that could do this that I had not heard of. Kinda surprised that nothing exsists to be honest, seems like something someone would of wanted in all these years.

Edited by TexasUnraid
Link to comment

Hi, I'm trying to add a script, however I cannot create the folder in config/plugins/user.scripts/scripts.  I get a "Destination Folder Access Denied" error.  Any ideas on how to fix this?

 

Also just a coding question.  I'm trying to write a python script to list directories using pycharm in a docker.   If i run the following commands these are the outputs:

- "pwd" returns "/home/nobody/PychamProjects/test"

(above command works)

 

- "ls -l ../mnt/cache/appdata" returns "No such file or directory"

(what should be the correct path?  typing that command in the unraid terminal gives a directory listing)

Link to comment
1 hour ago, Mogo said:

Hi, I'm trying to add a script, however I cannot create the folder in config/plugins/user.scripts/scripts.  I get a "Destination Folder Access Denied" error.  Any ideas on how to fix this?

 

Also just a coding question.  I'm trying to write a python script to list directories using pycharm in a docker.   If i run the following commands these are the outputs:

- "pwd" returns "/home/nobody/PychamProjects/test"

(above command works)

 

- "ls -l ../mnt/cache/appdata" returns "No such file or directory"

(what should be the correct path?  typing that command in the unraid terminal gives a directory listing)

 

Docker containers are separate from the host OS meaning that a docker container has no knowledge of /mnt/cache/appdata -- it does not exist because it cannot access Unraid's filesystem.

Link to comment
8 hours ago, Mogo said:

Hi, I'm trying to add a script, however I cannot create the folder in config/plugins/user.scripts/scripts.  I get a "Destination Folder Access Denied" error.  Any ideas on how to fix this?

Where are you seeing this?

Link to comment

It was on the windows machine when you browse using file explorer to create a folder on the unraid system.  I figured out what the issue was.  For some reason the smb security settings was set to secure (for the usb flash drive) which prevents write access.  I changed it to public and it allows me to create the folder now.  I guess i have to live with that warning beside the usb flash drive saying to change it.

Edited by Mogo
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.