[Plugin] CA User Scripts


Recommended Posts

Relatively new Unraid install - 6.11.1. Installed the User Scripts plugin. I am unable to "Apply" any changes whether it's changing the schedule from the dropdown list or setting a cron schedule. Pressing the Apply button seems to do nothing, pressing Done losses all changes. I've tried Firefox, Chrome, and Edge. I uninstalled the plugin but then reinstalling it just retained any previous scripts and settings and the Apply button still doesn't function. Thoughts?

Link to comment
7 hours ago, kennand said:

Since I updated User-Script to the latest version and updated Unraid to 6.11.1, my User-Script cannot display logs, what is the reason?

 

and they already ran once ? as if you just updated ... they need to run atleast once to have a log ;)

 

just in case you expected "old" logs ;)

Link to comment
4 hours ago, usr.local said:

I can't imagine that you would use more memory available on a usb stick to make that much difference.  If you you do, then I would say you should purchase a decent USB stick for less than $20.00.

 

Not so much about how much memory storage a USB drive has than trying to limit how much writing activity the flash drive sees.  Thumb drives aren't designed to be a general storage drive but rather for storage to archive and transport data from one system to another.  One of the main reasons of flash drive failure is from heat generated from continuous writes.  It has become more an issue with drives capacities and speeds increasing.  Most flash drives have little to no heat absorbing mass to dissipate the heat generated by multiple writes.

 

While text logs generally don't have many writes, it still may be best to be in the mindset to limit writes to your boot flash to only those that are needed to be there.

 

There has also been a large number of people finding themselves with counterfeit flash drives they though were genuine products from major suppliers (SanDisk, Samsung).  Many of these were purchased from popular sources such as Amazon.  So you can not know for sure your new flash drive is one of the decent ones.

Link to comment
On 11/1/2022 at 3:05 AM, alturismo said:

then i would start run it manually and see what comes in the box, if there are "logs" and not written to logs ... may take a look at syslog parallel to see if there are any errors like "not writeable" ...

I found that only when I click "run in background" can logs appear. If I click "RUN SCRIPT" or run script automatically on a regular basis, no logs will be generated

Link to comment
On 10/31/2022 at 5:22 AM, usr.local said:

I can't imagine that you would use more memory available on a usb stick to make that much difference.  If you you do, then I would say you should purchase a decent USB stick for less than $20.00.

 

 

One configuration mistake, or some issue, and you could write gigs to a log file. It depends on the log file. You generally never want to write logs to a boot folder/partition/drive. 

  • Like 1
Link to comment

Hi, I have a very simple python script but if I run it via the user scripts the execution is not in order.

 

subprocess.run running before everything at the start of the script, however it is called later in the script.

 

Do you have idea what is causing this? If I run the script manually in ssh shell it is executing the commands in order.

 

edit: I am not sure right now. Maybe just the output is not in order in the log?

 

The script:

#!/usr/bin/python3

import shutil
import subprocess

print("Starting")

letsencryptCert = "/mnt/user/appdata/swag/etc/letsencrypt/live/my.domain/priv-fullchain-bundle.pem"
guiCert = "/boot/config/ssl/certs/TOWER_unraid_bundle.pem"

print("Copy certificate...")
shutil.copyfile(letsencryptCert, guiCert)

print("Reload WebGUI...")
subprocess.run(["/etc/rc.d/rc.nginx", "reload"])

print("Finished")

 

Edited by MasterMark
Link to comment

I'm having an issue with my scripts not showing the logs after clicking on Run Script. The logs will show after clicking on Run in Background. 

I believe my NTP server settings weren't correct. I fixed that, but I still can't get two of my scripts to work at all. 

 

 

Could anyone tell me what is going on?

 

Here are the two scripts I need help with:

-first "arraycache errors":

Spoiler
#!/bin/bash
if mountpoint -q /mnt/arraycache; then
btrfs dev stats -c /mnt/arraycache
if [[ $? -ne 0 ]]; then /usr/local/emhttp/webGui/scripts/notify -i warning -s "ERRORS on arraycache pool"; fi
fi

 

-second "plexcache errors":

Spoiler

#!/bin/bash
if mountpoint -q /mnt/plexcache; then
btrfs dev stats -c /mnt/plexcache
if [[ $? -ne 0 ]]; then /usr/local/emhttp/webGui/scripts/notify -i warning -s "ERRORS on plexcache pool"; fi
fi

 

Here's the output of "cat /etc/cron.d/root":

Spoiler

root@Threadripper19:~# cat /etc/cron.d/root
# Generated btrfs balance arraycache schedule:
0 12 1 * * /usr/local/emhttp/plugins/dynamix/scripts/btrfs_balance start /mnt/arraycache -dusage=50 &> /dev/null

# Generated btrfs balance nvmecache schedule:
30 12 1 * * /usr/local/emhttp/plugins/dynamix/scripts/btrfs_balance start /mnt/nvmecache -dusage=50 &> /dev/null

# Generated btrfs balance plexcache schedule:
5 12 1 * * /usr/local/emhttp/plugins/dynamix/scripts/btrfs_balance start /mnt/plexcache -dusage=50 &> /dev/null

# Generated docker monitoring schedule:
10 0 * * * /usr/local/emhttp/plugins/dynamix.docker.manager/scripts/dockerupdate check &> /dev/null

# Generated languages version check schedule:
10 0 1 * * /usr/local/emhttp/plugins/dynamix.plugin.manager/scripts/languagecheck &> /dev/null

# Generated system monitoring schedule:
*/1 * * * * /usr/local/emhttp/plugins/dynamix/scripts/monitor &> /dev/null

# Generated mover schedule:
0 9 * * 0 /usr/local/sbin/mover &> /dev/null

# Generated parity check schedule:
0 22 * 1,4,7,10 2 [[ $(date +%e -d +7days) -le 7 ]] && /usr/local/sbin/mdcmd check NOCORRECT &> /dev/null || :
# Generated plugins version check schedule:
10 0 * * 1 /usr/local/emhttp/plugins/dynamix.plugin.manager/scripts/plugincheck &> /dev/null

# Generated btrfs scrub arraycache schedule:
0 11 * * 0 /usr/local/emhttp/plugins/dynamix/scripts/btrfs_scrub start /mnt/arraycache -r &> /dev/null

# Generated btrfs scrub nvmecache schedule:
30 11 * * 0 /usr/local/emhttp/plugins/dynamix/scripts/btrfs_scrub start /mnt/nvmecache -r &> /dev/null

# Generated btrfs scrub plexcache schedule:
5 11 * * 0 /usr/local/emhttp/plugins/dynamix/scripts/btrfs_scrub start /mnt/plexcache -r &> /dev/null

# Generated ssd trim schedule:
0 1 * * 0 /sbin/fstrim -a -v | logger &> /dev/null

# Generated array status check schedule:
20 0 * * 1 /usr/local/emhttp/plugins/dynamix/scripts/statuscheck &> /dev/null

# Generated Unraid OS update check schedule:
11 0 1 * * /usr/local/emhttp/plugins/dynamix.plugin.manager/scripts/unraidcheck &> /dev/null

# Generated cron settings for docker autoupdates
0 9 * * 0 /usr/local/emhttp/plugins/ca.update.applications/scripts/updateDocker.php >/dev/null 2>&1
# Generated cron settings for plugin autoupdates
0 10 * * * /usr/local/emhttp/plugins/ca.update.applications/scripts/updateApplications.php >/dev/null 2>&1

I'm also attaching my unRAID diagnostics for your review. 

 

Any help is appreciated. 

Thanks

threadripper19-diagnostics-20221107-2014.zip

Edited by FQs19
spelling correction
Link to comment
6 minutes ago, FQs19 said:

I'm having an issue with my scripts not showing the logs after clicking on Run Script. The logs will show after clicking on Run in Background. 

I believe my NTP server settings weren't correct. I fixed that, but I still can't get two of my scripts to work at all. 

 

 

Could anyone tell me what is going on?

 

Here are the two scripts I need help with:

-first "arraycache errors":

  Reveal hidden contents
#!/bin/bash
if mountpoint -q /mnt/arraycache; then
btrfs dev stats -c /mnt/arraycache
if [[ $? -ne 0 ]]; then /usr/local/emhttp/webGui/scripts/notify -i warning -s "ERRORS on arraycache pool"; fi
fi

 

-second "plexcache errors":

  Reveal hidden contents

#!/bin/bash
if mountpoint -q /mnt/plexcache; then
btrfs dev stats -c /mnt/plexcache
if [[ $? -ne 0 ]]; then /usr/local/emhttp/webGui/scripts/notify -i warning -s "ERRORS on plexcache pool"; fi
fi

 

Here's the output of "cat /etc/cron.d/root":

  Reveal hidden contents

root@Threadripper19:~# cat /etc/cron.d/root
# Generated btrfs balance arraycache schedule:
0 12 1 * * /usr/local/emhttp/plugins/dynamix/scripts/btrfs_balance start /mnt/arraycache -dusage=50 &> /dev/null

# Generated btrfs balance nvmecache schedule:
30 12 1 * * /usr/local/emhttp/plugins/dynamix/scripts/btrfs_balance start /mnt/nvmecache -dusage=50 &> /dev/null

# Generated btrfs balance plexcache schedule:
5 12 1 * * /usr/local/emhttp/plugins/dynamix/scripts/btrfs_balance start /mnt/plexcache -dusage=50 &> /dev/null

# Generated docker monitoring schedule:
10 0 * * * /usr/local/emhttp/plugins/dynamix.docker.manager/scripts/dockerupdate check &> /dev/null

# Generated languages version check schedule:
10 0 1 * * /usr/local/emhttp/plugins/dynamix.plugin.manager/scripts/languagecheck &> /dev/null

# Generated system monitoring schedule:
*/1 * * * * /usr/local/emhttp/plugins/dynamix/scripts/monitor &> /dev/null

# Generated mover schedule:
0 9 * * 0 /usr/local/sbin/mover &> /dev/null

# Generated parity check schedule:
0 22 * 1,4,7,10 2 [[ $(date +%e -d +7days) -le 7 ]] && /usr/local/sbin/mdcmd check NOCORRECT &> /dev/null || :
# Generated plugins version check schedule:
10 0 * * 1 /usr/local/emhttp/plugins/dynamix.plugin.manager/scripts/plugincheck &> /dev/null

# Generated btrfs scrub arraycache schedule:
0 11 * * 0 /usr/local/emhttp/plugins/dynamix/scripts/btrfs_scrub start /mnt/arraycache -r &> /dev/null

# Generated btrfs scrub nvmecache schedule:
30 11 * * 0 /usr/local/emhttp/plugins/dynamix/scripts/btrfs_scrub start /mnt/nvmecache -r &> /dev/null

# Generated btrfs scrub plexcache schedule:
5 11 * * 0 /usr/local/emhttp/plugins/dynamix/scripts/btrfs_scrub start /mnt/plexcache -r &> /dev/null

# Generated ssd trim schedule:
0 1 * * 0 /sbin/fstrim -a -v | logger &> /dev/null

# Generated array status check schedule:
20 0 * * 1 /usr/local/emhttp/plugins/dynamix/scripts/statuscheck &> /dev/null

# Generated Unraid OS update check schedule:
11 0 1 * * /usr/local/emhttp/plugins/dynamix.plugin.manager/scripts/unraidcheck &> /dev/null

# Generated cron settings for docker autoupdates
0 9 * * 0 /usr/local/emhttp/plugins/ca.update.applications/scripts/updateDocker.php >/dev/null 2>&1
# Generated cron settings for plugin autoupdates
0 10 * * * /usr/local/emhttp/plugins/ca.update.applications/scripts/updateApplications.php >/dev/null 2>&1

I'm also attaching my unRAID diagnostics for your review. 

 

Any help is appreciated. 

Thanks

threadripper19-diagnostics-20221107-2014.zip 140.82 kB · 0 downloads

 

It would help if I actually started my array. 

Attached is the diagnostics after starting my array and running the first script with Run then Run in Background. 

Here's the output of "cat /etc/cron.d/root":

Spoiler
root@Threadripper19:~# cat /etc/cron.d/root
# Generated btrfs balance arraycache schedule:
0 12 1 * * /usr/local/emhttp/plugins/dynamix/scripts/btrfs_balance start /mnt/arraycache -dusage=50 &> /dev/null

# Generated btrfs balance nvmecache schedule:
30 12 1 * * /usr/local/emhttp/plugins/dynamix/scripts/btrfs_balance start /mnt/nvmecache -dusage=50 &> /dev/null

# Generated btrfs balance plexcache schedule:
5 12 1 * * /usr/local/emhttp/plugins/dynamix/scripts/btrfs_balance start /mnt/plexcache -dusage=50 &> /dev/null

# Generated docker monitoring schedule:
10 0 * * * /usr/local/emhttp/plugins/dynamix.docker.manager/scripts/dockerupdate check &> /dev/null

# Generated languages version check schedule:
10 0 1 * * /usr/local/emhttp/plugins/dynamix.plugin.manager/scripts/languagecheck &> /dev/null

# Generated system monitoring schedule:
*/1 * * * * /usr/local/emhttp/plugins/dynamix/scripts/monitor &> /dev/null

# Generated mover schedule:
0 9 * * 0 /usr/local/sbin/mover &> /dev/null

# Generated parity check schedule:
0 22 * 1,4,7,10 2 [[ $(date +%e -d +7days) -le 7 ]] && /usr/local/sbin/mdcmd check NOCORRECT &> /dev/null || :
# Generated plugins version check schedule:
10 0 * * 1 /usr/local/emhttp/plugins/dynamix.plugin.manager/scripts/plugincheck &> /dev/null

# Generated btrfs scrub arraycache schedule:
0 11 * * 0 /usr/local/emhttp/plugins/dynamix/scripts/btrfs_scrub start /mnt/arraycache -r &> /dev/null

# Generated btrfs scrub nvmecache schedule:
30 11 * * 0 /usr/local/emhttp/plugins/dynamix/scripts/btrfs_scrub start /mnt/nvmecache -r &> /dev/null

# Generated btrfs scrub plexcache schedule:
5 11 * * 0 /usr/local/emhttp/plugins/dynamix/scripts/btrfs_scrub start /mnt/plexcache -r &> /dev/null

# Generated ssd trim schedule:
0 1 * * 0 /sbin/fstrim -a -v | logger &> /dev/null

# Generated array status check schedule:
20 0 * * 1 /usr/local/emhttp/plugins/dynamix/scripts/statuscheck &> /dev/null

# Generated Unraid OS update check schedule:
11 0 1 * * /usr/local/emhttp/plugins/dynamix.plugin.manager/scripts/unraidcheck &> /dev/null

# Generated cron settings for docker autoupdates
0 9 * * 0 /usr/local/emhttp/plugins/ca.update.applications/scripts/updateDocker.php >/dev/null 2>&1
# Generated cron settings for plugin autoupdates
0 10 * * * /usr/local/emhttp/plugins/ca.update.applications/scripts/updateApplications.php >/dev/null 2>&1

# CRON for CA background scanning of applications
26 * * * * php /usr/local/emhttp/plugins/community.applications/scripts/notices.php > /dev/null 2>&1

# Generated local master browser check:
*/1 * * * * /usr/local/emhttp/plugins/dynamix.local.master/scripts/localmaster &> /dev/null

# Generated system data collection schedule:
*/1 * * * * /usr/local/emhttp/plugins/dynamix.system.stats/scripts/sa1 1 1 &> /dev/null

# Generated cron schedule for user.scripts
0 0,8,16 * * * /usr/local/emhttp/plugins/user.scripts/startCustom.php /boot/config/plugins/user.scripts/scripts/btrfs_error_monitoring/script > /dev/null 2>&1
0 0,,8,16 * * * /usr/local/emhttp/plugins/user.scripts/startCustom.php /boot/config/plugins/user.scripts/scripts/btrfs_error_monitoring_plexcache/script > /dev/null 2>&1

 

 

threadripper19-diagnostics-20221107-2020.zip

Link to comment

Here is my super simple script... 
 

#!/bin/bash
cd /mnt/user/data/bullmoose20/Documents/Plex-Meta-Manager-Images
sudo tree --charset=ascii people > people_listing2.txt

##############
# chown      #
##############
chown nobody people_listing2.txt

##############
# chgrp      #
##############
chgrp users people_listing2.txt

##############
# chmod      #
##############
chmod 666 people_listing2.txt


When I run this manually in Unraid User Scripts, I get the following output:

 

people
|-- bw
|   |-- Aaron Beelner.jpg
|   |-- Aaron Eckhart.jpg
|   |-- Aaron Lazar.jpg
|   |-- Aaron Nee.jpg
|   |-- Aaron O'Connell.jpg
|   |-- Aaron Paul.jpg
|   |-- Aaron Ryder.jpg
|   |-- Aaron Schneider.jpg
|   |-- Aaron Schwartz.jpg
|   |-- Aaron Sorkin.jpg
|   |-- Aaron Stanford.jpg
|   |-- Aaron Taylor-Johnson.jpg
|   |-- Aaron W Reed.jpg
|   |-- Aarón Díaz.jpg
|   |-- Abbey Hoes.jpg
|   |-- Abby Elliott.jpg


However, when it runs every 5 minutes, I get the following output:
 

people
|-- bw
|   |-- Aaron\ Beelner.jpg
|   |-- Aaron\ Eckhart.jpg
|   |-- Aaron\ Lazar.jpg
|   |-- Aaron\ Nee.jpg
|   |-- Aaron\ O'Connell.jpg
|   |-- Aaron\ Paul.jpg
|   |-- Aaron\ Ryder.jpg
|   |-- Aaron\ Schneider.jpg
|   |-- Aaron\ Schwartz.jpg
|   |-- Aaron\ Sorkin.jpg
|   |-- Aaron\ Stanford.jpg
|   |-- Aaron\ Taylor-Johnson.jpg
|   |-- Aaron\ W\ Reed.jpg
|   |-- Aar\303\263n\ D\303\255az.jpg
|   |-- Abbey\ Hoes.jpg
|   |-- Abby\ Elliott.jpg


Notice the backslashes and notice the Aarón Díaz.jpg is missing the characters. 

Any way I can fix this so that when it runs with the schedule, it keeps the characters and eliminates the backslashes?

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.