Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[Plugin] CA User Scripts

Featured Replies

11 hours ago, Kurotaku said:


pidof isn't reliable with scripts because basename might just return names like bash or sh.


You could do sth rly simple like that (if you don't mind skipping syncs when another sync is running):

#!/bin/bash

lock_file="/tmp/scriptname.lock";

if [ -f "${lock_file}" ]; then
    echo "Script is already running";
    exit 1;
fitouch "${lock_file}";

echo "Starting rsync process...";

rm -f "${lock_file}";

Hey thanks for that example, i'll try that out! I for sure do not wanting it to run twice. What happens is the script catches up to itself due to large files and then it starts deleting the file in progress by the other process.

My only question is what happens when I click the abort script, do I need to go delete the lock file manually?

  • Replies 2.1k
  • Views 580.7k
  • Created
  • Last Reply

Top Posters In This Topic

Most Popular Posts

  • I could make up something long, convoluted, and technical as a reason why it doesn't do that but it would all be bs.  The simple answer is that when I did this, I never thought of that, and why it sti

  • Hi All - We have a fix and are publishing a Connect plugin update to fix it today. Thanks for letting us know.

  • @Squid I tried many commands and by that I found out that pkill does not kill (all) child processes: root@Thoth:/tmp# pgrep -f isleep2m | xargs --no-run-if-empty ps fp PID TTY STAT T

Posted Images

17 minutes ago, nerbonne said:

Hey thanks for that example, i'll try that out! I for sure do not wanting it to run twice. What happens is the script catches up to itself due to large files and then it starts deleting the file in progress by the other process.

My only question is what happens when I click the abort script, do I need to go delete the lock file manually?


With abort it would not delete the file, you would need to delete the file first manually, or create another script which deletes it.
As for me I personally always just use python scripts.
Means the bash script calling py /mnt/cache/scripts/script.py for me, bcs Its much better syntax and you can do much more with python, like checks if the programm already running etc.

Just ask Claude/ChatGPT or Gemini to create scripts for stuff like that, thats what I do on daily basis.

As I'm currently working on a big and maybe last major release version of User Scripts Enhanced, I will may in the future create a Standalone version for User Scripts Enhanced which allows then for me to implement stuff like this, that you can't start the same script at the same time by default.
But that will take a lot time, and first my other 2 new Plugins must be finished :)

Edited by Kurotaku

  • 3 weeks later...

I have a user script to backup my movies, etc from one unraid server to another using rsync. How can I include the available disk space of the destination server in the log? I have attached a log file so that someone could show me how to interpret it.

log.zip

9 hours ago, Steviewunda said:

Anybody?

ChatGPT can typically easily help with those kinds of issues.

is there something i need to add i cant shut down a computer in user scripts.. i can wake it up rysnc but when it comes to shut down it doesnt shut down... i can do it in the terminal using ip address but in the user script doesnt work

server="192.168.0.4"
#ssh -o StrictHostKeyChecking=no -i /root/.ssh/id_rsa root@$server '/sbin/poweroff'
#ssh -o StrictHostKeyChecking=no root@$server '/sbin/poweroff'
ssh root@$server '/sbin/poweroff'

none of them work in the user script .. but if i replace it with ip address in the terminal no issues

is there something i missing in the user scripts?

2 hours ago, comet424 said:

is there something i need to add i cant shut down a computer in user scripts.. i can wake it up rysnc but when it comes to shut down it doesnt shut down... i can do it in the terminal using ip address but in the user script doesnt work

server="192.168.0.4"
#ssh -o StrictHostKeyChecking=no -i /root/.ssh/id_rsa root@$server '/sbin/poweroff'
#ssh -o StrictHostKeyChecking=no root@$server '/sbin/poweroff'
ssh root@$server '/sbin/poweroff'

none of them work in the user script .. but if i replace it with ip address in the terminal no issues

is there something i missing in the user scripts?


I don't know how to fix this, but if you need a bypass solution for that, install the python plugin and create a python script which is called via user scripts.
That way it will definitly work.

@Kurotaku ah ok so its some kind of glitch?

is there a way to show log files for ya

i not sure how to make a script for it

but the way i been doing it for like 8 years was just ssh [email protected] '/sbin/poweroff'

etc

but i recently last few days been updating my scripts so i can mod them a bit adding server and i can just change the ip address

as i have a few servers.. and i copy and paste the script and just change the ip address.. but i noticed this bug it doesnt like it

do you think its an unraid problem? or how user scripts works? i though user scripts was python scripts

1 hour ago, comet424 said:

@Kurotaku ah ok so its some kind of glitch?

is there a way to show log files for ya

i not sure how to make a script for it

but the way i been doing it for like 8 years was just ssh [email protected] '/sbin/poweroff'

etc

but i recently last few days been updating my scripts so i can mod them a bit adding server and i can just change the ip address

as i have a few servers.. and i copy and paste the script and just change the ip address.. but i noticed this bug it doesnt like it

do you think its an unraid problem? or how user scripts works? i though user scripts was python scripts


I can recommend you to just get a Claude Account (or ChatGPT/Gemini)

I personally use Claude for every big project only, even tho the limitations are extreme (after a couple of prompts you need to wait some hours)
But claude is extremly good compared to all others I've used.

User Scripts is bash, you will need to install python plugin to be able to use python scripts, my guess for you problem is that the bash is in a different environment.

I personally have nearly every script only in python as its much easier to read/maintain and debug for me, I have them all on /mnt/cache/scripts/
That way I can also easily update/modify them on a friends server and mine without going over the UI of Unraid which is a bit annoying to use.

@Kurotaku oh so you didnt write the user scripts since you said you dont know how to fix ..

ok ill look into the python stuff..

and isnt bash python? isnt the scripts in user scripts python least thats what i though they were

4 hours ago, comet424 said:

and isnt bash python? isnt the scripts in user scripts python least thats what i though they were

short, nope.

@alturismo oh ok whats the difference? is like bash is equal to dos batch files and python is just programming?

9 minutes ago, comet424 said:

@alturismo oh ok whats the difference? is like bash is equal to dos batch files and python is just programming?


Bash is a shell scripting language that's mainly used to automate commands and interact with the operating system. Basically the Linux equivalent of Windows batch files.

Python is a programming language. You can write everything from small scripts to web servers, desktop applications, AI tools, and much more.
User Scripts in Unraid executes Bash by default. If you want to run Python, you need to install Python separately and call your .py script explicitly.
I've sent you a solution to your problem in Discord yesterday.

@Kurotaku ah ok ya so dos/windows batch programs i used to write in in the 80s and 90s and early 2000s

learn something new everyday...

and i never got the message on discord.. least i dont have any notifications... ill take a look

and you were saying the user scripts executes in a different enviroment is that like you execute it in this bubble but when it runs it runs in a new bubble and thats why like the ssh cant can read variables for ssh right as the variable is in bubble 1 and the ssh is running in bubble 2.. baasiclly

and ill look on discord for your message now

@Kurotaku never saw a DM from ya and i looked in multiple unraid topics didnt see message from ya.. discord doesnt seem to show notificaiton you wrote.. i guess unless your in it and catch it fast enough you never know someone ever messaged you

and searching Kurotaku shows up nothing

so sorry i missed your message on there

Edited by comet424

Is there any way to fix the log windows so that they show in dark mode? The native unraid windows like terminal and syslog show in dark mode, but the log windows for user scripts don't and it's blinding. Is that something that can be fixed?

image.png

2 minutes ago, nerbonne said:

Is there any way to fix the log windows so that they show in dark mode? The native unraid windows like terminal and syslog show in dark mode, but the log windows for user scripts don't and it's blinding. Is that something that can be fixed?

image.png


The easiest solution would be install Stylus extension.
Create a Stylesheet for: http://SERVER-IP/logging.htm

body {

background: #000;

color: #fff;

}

Is there any way we could get the scripts list sorted alphabetically?

Edited by Led57

14 hours ago, Led57 said:

Is there any way we could get the scripts list sorted alphabetically?

They are alphabetically, with one exception.
When you create sth ABC, rename it then to XYZ it will still be in the folder ABC and sorted as well like this.

You can rearange them in categories with User Scripts Enhanced.

  • 2 weeks later...

Hi all,


when I click on install for User Scripts I get the following prompt:


Install Plugin - Finished


Downloading plugin
plugin: YfQmUk04Khw6hp31ZUib8XuigmgyVBJ9d_Yr4teGWFxKDxz6EwUbGeHZ4kqe9u6oM_WN6wH6JK3kD1fzw_PVJzgVfAhmSQhXxmFM5cANyNbglFovXixPLkcKLAUafcNY3wZt8sydLnVQVUCyjEBC-uLKQyZK6t8 is not a plg file
Plugin installed



anything i should be worries about?
Is your App ok?

Thanks for checking.

6 hours ago, iPat said:

Hi all,


when I click on install for User Scripts I get the following prompt:


Install Plugin - Finished


Downloading plugin
plugin: YfQmUk04Khw6hp31ZUib8XuigmgyVBJ9d_Yr4teGWFxKDxz6EwUbGeHZ4kqe9u6oM_WN6wH6JK3kD1fzw_PVJzgVfAhmSQhXxmFM5cANyNbglFovXixPLkcKLAUafcNY3wZt8sydLnVQVUCyjEBC-uLKQyZK6t8 is not a plg file
Plugin installed



anything i should be worries about?
Is your App ok?

Thanks for checking.

download is working again, thanks.

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.