[Plugin] CA User Scripts


Recommended Posts

On 11/5/2020 at 2:29 PM, Cessquill said:

In the top left of the page there's a "What Is Cron" line.  Hover over this for a popup of the interpretation that this follows.  Took me a couple of goes to get mine working since there's a few different ways to express the same thing, and not all Cron systems accept the same structure.

 

crontab.guru is an online page that I use. Let's me put stuff in and shows you the result. Also has a huge page of examples of almost every type.

Link to comment
1 hour ago, jmbailey2000 said:

 

crontab.guru is an online page that I use. Let's me put stuff in and shows you the result. Also has a huge page of examples of almost every type.

Yes, I've used a couple of different ones, but like I say - the reference on the plugin page is useful as it shows the format that it specifically accepts.

Link to comment
  • 2 weeks later...
48 minutes ago, MajorTomG said:

I'm new to this and I'm hoping I can use this plugin to call the radarr V3 API. Specifically the /command endpoint ImportListSyncCommand. Is this possible? Where would I start?

See a few posts above for another example of running a command inside a docker.

Link to comment

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

  1. 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.
  2. 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

I'm trying to host a discord bot I made in python using the discordpy library, and I wanted to have the script ran every hour. however I'm not to experienced with bash so i'm a little stuck on running the script.

 

this is the code I tried and I have installed the nerdpack plugin and enabled python3 in the settings. I have also rebooted my server after installing/enabling

 #!/bin/bash
cd /mnt/user/scripts/Predicting_Alpha_Bot
python bot.py

 

When I run the script using the user script plugin it shows an error saying unknown command 'python'. I'm not sure if I have to specify the python path or anything so any help would be greatly appreciated!

Link to comment

[BUG] German Umlauts [äöüÄÖÜß] disappear during save

 

I do have some scripts that do require German Umlauts (see above). I can put them into the big edit field but they disappear after saving the user script.

 

 

For example: Within a user script I do call a python script to export data. I enter something like that (shortened):

python3 [path]/ExportData.py -l Hörbücher

 

After saving and reopening the script this is what became stored:

python3 [path]/ExportData.py -l Hrbcher

 

Thanks.

 

Link to comment

Yeah, it's not a bug, but by design.  Trouble is that there were so many users copying / pasting scripts from the forums here and doing that introduces other unwanted characters into the script, that all non pure ASCII characters were removed.  I'll revisit next week.

Link to comment

I have a python script that is being ran by the user script plug in however i'm using a package that is not native to python so I was wondering how I would install it on my server so that it can be used by my script. I tried pip installing it through the command line but got some errors so im wondering if there is another way. 

 

I have the error message in this file if needed. install error message.txt

 

 

Edited by zaymus
added file
Link to comment
On 12/9/2020 at 2:48 PM, Squid said:

Yeah, it's not a bug, but by design.  Trouble is that there were so many users copying / pasting scripts from the forums here and doing that introduces other unwanted characters into the script, that all non pure ASCII characters were removed.  I'll revisit next week.

Thanks in advance.

 

IMHO: Don't modify user content in an entryfield automatically. It becomes a can of worms to decide and filter what's unwanted and what's intended. If you need to, check for unwanted characters and simply popup a small dialog "Non-ASCII characters detected. Are you sure?" and let the user decide.

 

Link to comment
On 12/9/2020 at 11:36 AM, zaymus said:

I have a python script that is being ran by the user script plug in however i'm using a package that is not native to python so I was wondering how I would install it on my server so that it can be used by my script. I tried pip installing it through the command line but got some errors so im wondering if there is another way. 

 

I have the error message in this file if needed. install error message.txt

 

My suggestion is to build a docker image (using one of the official python base images), include your python script (run it from the entrypoint) and all of its dependencies. Then run the container from your user script. 

Link to comment

Hi all,

 

Sorry for the dumb question but:

 

I want to execute a script created with the "CA User Scripts" plugin not from the Unraid GUI but from the terminal (or from another script for that matter). What is the simplest way to do so?

 

I indeed noticed that the "/tmp/user.scripts/tmpScripts" directory only contains scripts which were previously run from the Unraid GUI, and that in the "/boot/config/plugins/user.scripts/scripts" directory, the scripts permissions are set to 600 which make them not executable.

 

Many thanks,

Best

OP

Link to comment
14 minutes ago, Opawesome said:

in the "/boot/config/plugins/user.scripts/scripts" directory, the scripts permissions are set to 600 which make them not executable.

Security precaution in Unraid.

 

use this

/bin/bash /boot/config/plugins/user.scripts/scripts/.....

 

  • Thanks 1
Link to comment

I am looking for a script that would monitor a TCP port and accept commands to spinup, spindown, or return status of a disk. The the minimum capability I need would be a command to spin up all the disks in the array.  I could have them spin down after 4 hours of inactivity.  The major use of the array is to feed my own home theater movie system. The delay when loading a movie bothers me and I would like to spin up the the array disks when I open the theater's movie librarian. 

 

It is my belief that if disks are generally not being used keeping them in a spun down state will increase their longevity

 

Any help or advice would be greatly appreciated. 

Link to comment

Hello all,

 

Thought I would post my experience here since my search-fu didn't come up with an answer, and someone else may have the same issue.

 

I wanted to create a simple script to reboot my server once a week. My script worked when manually executed (RUN SCRIPT). However I was unable to make any schedule stick. I noticed that when hovering over the cog for pre-installed docker restart $(docker ps -q) no options appeared. The contents /boot/config/plugins/user.scripts/scripts contained the directory:

 

docker\ restart\ $docker\ ps\ -q/

 

I renamed this directory to docker_restart and refreshed the User Scripts page and now hovering over cog displays options and I can apply a schedule to my new script.

 

Cheers

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.