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

Hello!

 

I'm using this plugin but my script included CJK(Chinese japan, Korea)

 

When saving the script in web ui

the chinese char would be vanish

Is there any bug or somthing?

Thanks!

 

CJK example:

monthchi=("01-一月" "02-二月" "03-三月" "04-四月" "05-五月" "06-六月" "07-七月" "08-八月" "09-九月" "10-十月" "11-十一月" "12-十二月")
would become

monthchi=("01-" "02-" "03-" "04-" "05-" "06-" "07-" "08-" "09-" "10-" "11-" "12-")
 

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

Is there any variable that lets you know the original location of the script? Or the only option is to replace:

 

/tmp/user.scripts/tmpScripts/YYY

 

With

 

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

Edited by Bruno

  • Author
7 hours ago, tah said:

Hello!

 

I'm using this plugin but my script included CJK(Chinese japan, Korea)

 

When saving the script in web ui

the chinese char would be vanish

Is there any bug or somthing?

Thanks!

 

CJK example:

monthchi=("01-一月" "02-二月" "03-三月" "04-四月" "05-五月" "06-六月" "07-七月" "08-八月" "09-九月" "10-十月" "11-十一月" "12-十二月")
would become

monthchi=("01-" "02-" "03-" "04-" "05-" "06-" "07-" "08-" "09-" "10-" "11-" "12-")
 

Due to various problems with people cutting and pasting from the forum, all characters except for ASCII are stripped from the scripts automatically.  You're best saving your script elsewhere and use user.scripts to create a script to call the real one.

  • Author
5 hours ago, Bruno said:

Is there any variable that lets you know the original location of the script?

no

  • Author

OK, so now all schedules including Array Start and 1st boot only will start in the background.  This does mean that if you have multiple scripts running on the same schedule then they will run concurrently.  If this causes issues, you will have to redo your scripts so that #1 calls #2 calls #3 etc.

Is there a way to start a screen through user scripts and bind it to tty pts/0?

On 2/27/2020 at 10:29 AM, Squid said:

no

 

On 2/27/2020 at 5:25 AM, Bruno said:

Is there any variable that lets you know the original location of the script? Or the only option is to replace:

 

/tmp/user.scripts/tmpScripts/YYY

 

With

 

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

Try:


#!/bin/bash

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

$DIR will then contain the folder the script was ran from.

  • Author
15 minutes ago, Xaero said:

 

Try:


#!/bin/bash

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

 

$DIR will then contain the folder the script was ran from.

He was asking the original location of the script and not where its executed from.   The original location is on the flash.   But its processed and then executed from /tmp

35 minutes ago, Squid said:

He was asking the original location of the script and not where its executed from.   The original location is on the flash.   But its processed and then executed from /tmp

Oh, rip

Anyone also experiencing instant Firefox tab hang2crash after clicking script log of an in background running script?

This happens when running rsync with quite some stdout.

Currently running UR 6.8.3/ US 2020.02.27 / FF 73.0.1

Edited by 54tgedrg45

  • Author
15 minutes ago, 54tgedrg45 said:

Anyone also experiencing instant Firefox tab hang2crash after clicking script log of an in background running script?

This happens when running rsync with quite some stdout.

Currently running UR 6.8.3/ US 2020.02.27 / FF 73.0.1

If the log is insanely long, any browser will choke on it.

22 minutes ago, Squid said:

If the log is insanely long, any browser will choke on it.

If so, is it somehow possible to just capture tail of log for the plugin to display within browser limits?

Edited by 54tgedrg45

  • Author

Command prompt

 

Something akin to

tail -f /tmp/user.scripts/tmpScripts/Set permissions on Downloads/log.txt

 

I have a working script that I'm now trying to run every 2 minutes via cron. I selected the Custom option from the scheduled drop down menu and enter */2 * * * * as the Custom Cron Schedule value and then click on Run In Background. A pop-up window opens telling me the script is running in the background which I then close. I have modified my script temporarily to write entries into the log file every time it runs. I know the script runs once because I see the output in the log file but it but does not run again. My settings do not remain after reboot or even if I navigate away from the User Scripts management page and then come back. I'm not sure how to fix this issue. What am I doing wrong here??

  • Author

You don't need to click run in background.  All you have to do is set the cron and hit apply down at the bottom.  As to why it's doing what it's doing no one can answer without seeing the exact script.

50 minutes ago, Squid said:

You don't need to click run in background.  All you have to do is set the cron and hit apply down at the bottom.  As to why it's doing what it's doing no one can answer without seeing the exact script.

Thanks for the reply. The script was working just fine all I needed was to get it running in cron. I was clicking Run In Background instead of Apply.  Once I used Apply it was loaded into Cron and persistent across a reboot. Everything is working just like I need now. Thank you

  • 2 weeks later...

Is #noParity=true working on 6.8.2? My script still runs during parity check so I have to manually abort it. 

  • Author

Send me a PM in a week to remind me to look at / fix

Is there a way to purge or fix this plugin? I did broke it, don't know how, it lands me to a blank page even upon reinstalling it.

  • Author

Deleting the contents of /config/plugins/user.scripts on the flash drive followed by an uninstall then a reinstall will set it back to default.   You will however loose your scripts.  If you need to keep your scripts then dont delete the contents of the scripts folder

Hi, Squid.

The pop-up argument input was fine, but after I upgraded the plugin. It's gone.

Could you review my code?

#!/bin/bash
#description=Here is a housekeeping script. By default just deletes empty timestamp directories. Optionally, it can delete snapshots.
foregroundOnly=true
backgroundOnly=true
#arrayStarted=false
#name= BTRFS cleanup
#argumentDescription="-a purges all snapshots; -i <Comma seperated list of shares> purges the selected shares. example -i Downloads,Test1,Test2 will purge all snapshots for Downloads, Test1, and Test2."
#argumentDefault=-a
shopt -s nullglob

POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"

case $key in
    -i|--include)
    INCLUDE="$2"
    shift # past argument
    shift # past value
    ;;
    -a|--all)
    ALL=YES
    shift
    ;;
    *)    # unknown option
    POSITIONAL+=("$1") # save it in an array for later
    shift # past argument
    ;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters

#Tokenize include list
declare -A includes
for token in ${INCLUDE//,/ }; do
        includes[$token]=1
done

#iterate over all disks on array
for disk in /mnt/disk*[0-9]* ; do
 #iterate over each timestamp
 for timestamp in ${disk}/.snapshots/* ; do
  #iterate over each share in the timestamp
  for snap in $timestamp/* ; do
   if [ -n "${includes[$(basename $snap)]}" ] || [ "$ALL" = "YES" ] ; then
    echo "Purging - $snap"
    btrfs subvolume delete $snap
  fi
  #check for empty timestamp
  if [ ! "$(ls -A $timestamp)" ] ; then
   echo "Purging empty directory - $timestamp"
   rmdir $timestamp
  fi
  done
 done
done

and it's original from 

Thank you so much.

On 3/26/2020 at 10:52 AM, Squid said:

Deleting the contents of /config/plugins/user.scripts on the flash drive followed by an uninstall then a reinstall will set it back to default.   You will however loose your scripts.  If you need to keep your scripts then dont delete the contents of the scripts folder

Once deleted tryed to reinstall it, this happens:

 

image.png.de0cc2c00d934e850b06633287a7e267.png

 

image.thumb.png.d4968da067e842ac08a983b20deb0a53.png

 

Removed and installed again, same behaviour.

Are there any caveats to using email notification?

 

I've got a user script that calls another script. Both scripts have an email notification and unRAID notification:

  • Script email notification is to say something will start, or won't start based on conditions. If the conditions are met, it calls script2 (stored elsewhere)
  • Script2 then does its thing and tells me whether or not its job was successful (that email notification works fine)
  • unRAID UI notification works in all cases, and whether manually run or run through user.scripts UI. Email notification works for script2, but not script.
  • The command before and the command after it work normally.

I created a test script which had the exact same command (just the email command) and ran it via user.scripts UI and it worked - it sent an email...

 

/usr/local/emhttp/webGui/scripts/notify -e "CronJob" -s "unRAID-backup >> STARTED <<" -d "$SCRIPT" -m "Logs :: $LOGFILE" -i "normal"

 

Really weird. I can't figure it out.

 

Note - when i ran manually for testing, the script was on the Array. I can't seem to manually run it from withing /boot/config/plugins/user.scripts/scripts/myscript.

 

UPDATE: Oddly, several of my previous test runs have trickled through now. So while the script2 sent me an email more or less immediately, script dribbled them out between and hour or two after the script was run.

 

Any ideas?

Edited by Derek_

Another question:

  • When i run Borg with a user.script - it performs its operations as root (as expected) and the dir/file ownership is root:root
  • When i run and rsync copy with a user.script - it performs its operations as root (as expected) and the file ownership is with nobody:users.

How come it differs? I'd like my Borg backups to be nobody:users too - but it looks like the only way i can do that is with chown. I can't run it as nobody can i?

What is the viewDockerLogSize script telling me exactly?  The zoneminder log gets big pretty fast.  It doesn't seem to be the same info you get from docker logs <container>.  Can I move that log outside the container somehow?

 

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.