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

  • Author
6 hours ago, hawihoney said:

Output of commands within scripts is not shown with latest User Script plugin. Example:

 

Fixed...  Thanks

  • Replies 2.1k
  • Views 567.3k
  • 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

  • Author
11 hours ago, Barry Staes said:

Thanks for these wonderful Unraid Plugins!

 

Links updated

 

11 hours ago, Barry Staes said:

I found no link or mention of the Unraid Plugin User Scripts source repository anywhere in the CA, plugin itself, changelog, this plugin forum thread, or your (Squid's) profile.

Since I also do CA, I do not publish any URLs to any plugin installation URL.  Only CA do I publish the URL (and by implication the GitHub repository) publicly

17 hours ago, Squid said:

Fixed...  Thanks

No - Thank you!

I'm running the latest plugin version but since then some scripts do not get executed regularly.

 

I have 5 scripts that should run every minute but one of them is mostly running every 2 minutes and sometimes every 1 minute.

How can we fix this? Before the update the scripts were working as intended...

 

EDIT: Most of the script set to a minute interval with "* * * * *" are running in a 2 minute interval at best, and the script takes around 0.1 to 2 seconds of run time.

Even after a restart of the whole system the problem still persist. 

Edited by gekoch

On 2/26/2023 at 6:10 AM, Squid said:

I'll look at it, but effectively they are both the same thing just opposite ways of wording it.  Only use one of them.

IMO, having something like the following,

    #foregroundButton=[true|false]
    #backgroundButton=[true|false]

would make a lot more sense and prevent one of them becoming redundant when you use the other.

 

But my problem isn't about the wording, it's about the fact that if I use the variables at all (regardless of setting) BOTH buttons disappear, preventing me from running the script.

 

It took a bit of fidgeting to realize I had to remove the variables altogether to get the buttons back.

Is it a problem if a CA script I have set to run on start of the array never completes when I test with "RUN SCRIPT"?

 

During my script I call another script that is first copy into /usr/local/bin

 

In the unraid WEBUI Shell, If I run ./monitor_arrayAudioChanges.sh I am returned to the # prompt and the process runs in background fine.

If I close the RUN SCRIPT window the PID started by the monitor_arrayAudioChanges.sh is also terminated. I have tried sever suggestions I found online to have this .sh start in a different way / in background but have had no luck. Any suggestions?

 

Quote

 

## Install inotify-tools package ##
installpkg /boot/packages/inotify-tools-3.22.6.0-x86_64-1.txz

## Setup monitoring of music and audiobooks array folders ##
cp -r /boot/custom/audioArrayToSSD /usr/local/bin && chmod +x /usr/local/bin/audioArrayToSSD/sync_arrayAudioToSSD.sh && chmod +x /usr/local/bin/audioArrayToSSD/monitor_arrayAudioChanges.sh
source /usr/local/bin/audioArrayToSSD/monitor_arrayAudioChanges.sh

## Install  docker compose 
BLABLABLA


 

Edited by Presjar

8 hours ago, Presjar said:

Is it a problem if a CA script I have set to run on start of the array never completes when I test with "RUN SCRIPT"?

 

During my script I call another script that is first copy into /usr/local/bin

 

In the unraid WEBUI Shell, If I run ./monitor_arrayAudioChanges.sh I am returned to the # prompt and the process runs in background fine.

If I close the RUN SCRIPT window the PID started by the monitor_arrayAudioChanges.sh is also terminated. I have tried sever suggestions I found online to have this .sh start in a different way / in background but have had no luck. Any suggestions?

 

 

## Install inotify-tools package ##
installpkg /boot/packages/inotify-tools-3.22.6.0-x86_64-1.txz

## Setup monitoring of music and audiobooks array folders ##
cp -r /boot/custom/audioArrayToSSD /usr/local/bin && chmod +x /usr/local/bin/audioArrayToSSD/sync_arrayAudioToSSD.sh && chmod +x /usr/local/bin/audioArrayToSSD/monitor_arrayAudioChanges.sh
source /usr/local/bin/audioArrayToSSD/monitor_arrayAudioChanges.sh

## Install  docker compose 
BLABLABLA


 

Use "bash /usr/local/bin/audioArrayToSSD/monitor_arrayAudioChanges.sh" instead of "source /usr/local/bin/audioArrayToSSD/monitor_arrayAudioChanges.sh"
From the 1st link you provided: "In the second method, if you are using exit in second script, it will exit the first script as well."

1 hour ago, ICDeadPpl said:

Use "bash /usr/local/bin/audioArrayToSSD/monitor_arrayAudioChanges.sh"

Thanks! I will give that a try. I had previously tried it as per the first link, top answer, point 3. /bin/bash /usr/local/bin/audioArrayToSSD/monitor_arrayAudioChanges.sh

 

Edit: no good unfortunately. Same issue.

 

Link the script im trying to run on array start. Original script was on github. Modified to made it work for my purpose and made it messy.

https://pastebin.com/Xu5U9nAB

Edited by Presjar
Updated after testing

Is there any way for a script to check if it was run manually or on a schedule? Like a variable set to true, only if the script was run manually?

Edited by allenormond
typo

Installed the User Scripts plugin, and followed the usage / guides to populate the various files.

 

After adding the script and executing it, I cannot now run in the background or schedule it for future runs.

 

Is this a known issue? Is there a fix?

  • Author
1 hour ago, explosionhole said:

Installed the User Scripts plugin, and followed the usage / guides to populate the various files.

 

After adding the script and executing it, I cannot now run in the background or schedule it for future runs.

 

Is this a known issue? Is there a fix?

Works for me.  Make sure there is no weird punctuation etc in the naming

I cannot see any difference in punctuation from the default provided scripts. File permissions are the same.

 

I had to debug it by re-running it while editing the script, but it executes now.

Edited by explosionhole
re-worded

On 2/26/2023 at 9:43 PM, kennymc.c said:

I noticed that the ACE Editor settings (Ctrl+,) like theme or text size are not saved. As soon as you exit the User Scripts plugin and open it again, the default settings are loaded again.
There are also display problems with the Black and White Base Themes. Themes with a vertical menu bar like Azure and Grey are not affected.
The problem also affects other plugins that use the ACE editor, like Dynamix File Manager.

 

Could anyone reproduce this?

this is my `script` syntax:


 

#!/bin/bash
#foregroundOnly=true
backgroundOnly=true
arrayStarted=true
#name=blah blah blah
#argumentDescription=This is the description of the argument(s)
#argumentDefault=defaultArg1 defaultArg2 etc

docker exec mariadb sh -c 'exec mysqldump --all-databases -uroot -p"password" | gzip > /mnt/backups/unraid_`date "+%d-%m-%Y"`.sql.gz'
find /mnt/user/data/Backups/mariadb/ -type f -mtime +15 | xargs rm

 

I am looking to do some automatic copying and deleting between shares for my media server.  Is there any danger just copying using the disk paths directly?  Like "cp /mnt/disk1/path/to/source /mnt/disk2/path/to/destination"?  The paths would be shares.  Or should I use "cp /mnt/user/path/to/source /mnt/user/path/to/destination"?

 

Or does it matter using this plugin?  I don't want to mess up permissions or something.

 

Thanks.

I have a problem about 502 bad gateway when i run script or run in backgroud.I tried to reinstall the plugin to no avail.

Snipaste_2023-03-15_16-38-48.png

Any chance of adding sort options to the top, like by script name, next run date/time?

On 2/26/2023 at 9:43 PM, kennymc.c said:

I noticed that the ACE Editor settings (Ctrl+,) like theme or text size are not saved. As soon as you exit the User Scripts plugin and open it again, the default settings are loaded again.
There are also display problems with the Black and White Base Themes. Themes with a vertical menu bar like Azure and Grey are not affected.
The problem also affects other plugins that use the ACE editor, like Dynamix File Manager.

The ACE editor settings appearance bug was recently fixed in Dynamix File Manager but unfortunately these settings cannot be saved permanently. Maybe someone here knows if and how this is possible.

 

unable to install plugin neither via webui or cli

os version:6.12.0-rc2.

Installing info via cli:

SNAIL ~ # plugin install https://raw.githubusercontent.com/Squidly271/user.scripts/master/plugins/user.scripts.plg
plugin: installing: user.scripts.plg
Executing hook script: pre_plugin_checks
plugin: downloading: user.scripts.plg
plugin: downloading: user.scripts.plg ... done
Executing hook script: pre_plugin_checks
plugin: downloading: user.scripts-2023.03.04-x86_64-1.txz ... done

+==============================================================================
| Installing new package /boot/config/plugins/user.scripts/user.scripts-2023.03.04-x86_64-1.txz
+==============================================================================

Verifying package user.scripts-2023.03.04-x86_64-1.txz.
Installing package user.scripts-2023.03.04-x86_64-1.txz:
PACKAGE DESCRIPTION:
Package user.scripts-2023.03.04-x86_64-1.txz installed.


plugin: run failed: /usr/bin/php
Executing hook script: post_plugin_checks
SNAIL ~ #

syslog during installation:

Mar 27 02:57:32 SNAIL root: plugin: creating: /boot/config/plugins/user.scripts/user.scripts-2023.03.04-x86_64-1.txz - downloading from URL https://raw.githubusercontent.com/Squidly271/user.scripts/master/archive/user.scripts-2023.03.04-x86_64-1.txz
Mar 27 02:57:34 SNAIL root: plugin: checking: /boot/config/plugins/user.scripts/user.scripts-2023.03.04-x86_64-1.txz - MD5
Mar 27 02:57:34 SNAIL root: plugin: running: upgradepkg --install-new /boot/config/plugins/user.scripts/user.scripts-2023.03.04-x86_64-1.txz
Mar 27 02:57:36 SNAIL root: plugin: running: anonymous

diagnostics

snail-diagnostics-20230327-0258.zip

  • Author

Try it again.  On 6.12 it wouldn't install fresh due to a PHP8 error

5 hours ago, Squid said:

Try it again.  On 6.12 it wouldn't install fresh due to a PHP8 error

Thx,worked!

Can you add theme Support for the PopUp window, when i click "run script" ? 

i have a issue for me:

 

startScript.sh 

 

Quote

#!/bin/bash
echo "Script location: <b>$1</b>"
echo "<style> body {background-color: #000000} </style>"
echo "<body>"
export HOME=$(grep $(whoami) /etc/passwd | cut -d: -f 6)
source ${HOME}/.bashrc
echo "<font color='red'>Note that closing this window will abort the execution of this script</font>"
"$1" "$2" 2>&1
echo "</body>"

 

I use unraid 6.12-rc2.

 

 

I added "style" and "body" in this script and i can theme now. 

Maybe you can add theme support for the future versions.

 

I added a picture for impressions.

 

 

Picture:

Spoiler

image.thumb.png.7f538d1c2e8b9ab556146adca549f15b.png

 

regards

 

Sakashi

 

Edited by Sakashi

I have a question, I am not 100% familiar with scripting so someone on another group helped me out with this.

 

It's supposed to look at the trailers folder and compare it to my movies folder for a movie match and if a trailer isn't in that movies folder, and there is a match in the Trailers folder,  it will copy it over, otherwise ignore the movie folder and move on.

 

He wrote it assuming the script would be sitting in the same share (Storage-1) as the trailer and movie folder sits in. But I think with this pugin the script is in it's own folder in /boot/config/plugins/user.scripts/scripts

 

I was wondering if someone could help me put the direct paths in this script so I can get it working? Right now the paths of my share and the two folders are structured like this, with Storage-1 being the main share folder.

 

Storage-1  /  Trailers

 

Storage-1  / Movies

 

Thanks for the help! Much appriciated 

 

 

#!/usr/bin/bash

for trailer in Trailers/*; do
	echo "Searching for movie for Trailer - '$trailer'"
	basename=$(basename "$trailer" .mkv)
	basename=${basename%-trailer}
	basename=${basename/%.[[:digit:]][[:digit:]][[:digit:]][[:digit:]]/}
	basename=${basename/% ([[:digit:]][[:digit:]][[:digit:]][[:digit:]])/}
	basename=${basename/[/\\[}
	basename=${basename/]/\\]}

	matches=`find Movies -iname "$basename"\*`
	if [[ -n "${matches}" ]]; then
	    num=$(echo -n "${matches}" | grep -c '^')
	    if [[ "$num" == "1" ]]; then
		    echo "--> Found match for trailer ${matches}"
		    echo mv "$trailer" "${matches}"
	    else
		echo "Multiple matches for trailer: ${trailer}"
		echo "${matches}"
	    fi
	#else
	#    echo "--> No match found for trailer ${matches}"
	fi
done

 

 

 

 

  • Author
On 3/27/2023 at 3:04 PM, Sakashi said:

Maybe you can add theme support for the future versions.

 

Done.  The popup window already follows the theme set by the webGUI.  IE: it doesn't make any changes to the popup

18 hours ago, 1971camaroguy said:

I have a question, I am not 100% familiar with scripting so someone on another group helped me out with this.

 

It's supposed to look at the trailers folder and compare it to my movies folder for a movie match and if a trailer isn't in that movies folder, and there is a match in the Trailers folder,  it will copy it over, otherwise ignore the movie folder and move on.

 

He wrote it assuming the script would be sitting in the same share (Storage-1) as the trailer and movie folder sits in. But I think with this pugin the script is in it's own folder in /boot/config/plugins/user.scripts/scripts

 

I was wondering if someone could help me put the direct paths in this script so I can get it working? Right now the paths of my share and the two folders are structured like this, with Storage-1 being the main share folder.

 

Storage-1  /  Trailers

 

Storage-1  / Movies

 

Thanks for the help! Much appriciated 

 

 

#!/usr/bin/bash

for trailer in Trailers/*; do
	echo "Searching for movie for Trailer - '$trailer'"
	basename=$(basename "$trailer" .mkv)
	basename=${basename%-trailer}
	basename=${basename/%.[[:digit:]][[:digit:]][[:digit:]][[:digit:]]/}
	basename=${basename/% ([[:digit:]][[:digit:]][[:digit:]][[:digit:]])/}
	basename=${basename/[/\\[}
	basename=${basename/]/\\]}

	matches=`find Movies -iname "$basename"\*`
	if [[ -n "${matches}" ]]; then
	    num=$(echo -n "${matches}" | grep -c '^')
	    if [[ "$num" == "1" ]]; then
		    echo "--> Found match for trailer ${matches}"
		    echo mv "$trailer" "${matches}"
	    else
		echo "Multiple matches for trailer: ${trailer}"
		echo "${matches}"
	    fi
	#else
	#    echo "--> No match found for trailer ${matches}"
	fi
done

 

I got my issue sorted out, moving and matching trailers as expected now

 

 

 

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.