[Plugin] CA User Scripts


Recommended Posts

No trouble on my part.  Just use crontab to add the jobs in

 

crontab -l > /tmp/temp
echo 25 0 * * * ssh [email protected] sudo shutdown -h now >> /tmp/temp
crontab /tmp/temp

something like that.

 

Alternatively you can also mimic a plugin's cron entries by making a file called /boot/config/plugins/someDummyName/someDummyName.cron with the appropriate cron entry, and every reboot (not sure about starts) unRaid'll add in the cronjob automatically

Link to comment

This is a great plugin, been after something like this for a while as I loathe going to the command line  :D  So many thanks to Squid.

 

A couple of suggestions:

  • Minor: I've noticed the output doesn't seem to support UTF-8 chars, not sure if this is due to the plugin, the browser, the way the plugin captures the output etc...
  • Major: It would be great to be able to manage scripts from the plugin page, i.e. create, edit and delete in a simple form. I know this has been suggested, but this would really make this an all-in-one solution IMO

 

Link to comment

  • Minor: I've noticed the output doesn't seem to support UTF-8 chars, not sure if this is due to the plugin, the browser, the way the plugin captures the output etc...
  • Major: It would be great to be able to manage scripts from the plugin page, i.e. create, edit and delete in a simple form. I know this has been suggested, but this would really make this an all-in-one solution IMO

UTF - I'm using a built-in routine to display everything, and technically, the display format is actually full HTML, so you can rejig everything to display according to that.  However, doing that will then make any logs if you run the script in the background look rather strange.

 

And, yeah the editing, etc has been suggested before, but isn't at the top of my priority list.

Link to comment

On 6.2.1 via Unassigned Devices I see I can mount Remote SMB shares

 

Currently I backup Tower1 shares to Tower2 using Rsync in a Tower2/VM

Tower1 contains Exported Smb shares with both Read/Write and Read Only users

Tower2 contains a Clone of Tower1 shares with Hidden Smb Shares all Read Only user

 

On Tower2's VM I pass through the Shares and mount in FSTAB via Virito 9c.  I mount the Tower1 shares in FSTAB via CIFS.  http://lime-technology.com/forum/index.php?topic=45039.0

 

The Current Script run within the VM uses 2 types of backups:

rsync -r -v --progress --ignore-existing -s /home/UbuntuUserName/tower1/writeonce/ /home/UbuntuUserName/tower2/writeonce

rsync -r -v --progress --delete -s /home/UbuntuUserName/tower1/documents/ /home/UbuntuUserName/tower2/documents

 

Can I skip the VM overhead and run the backup on Tower2 directly using the following? 

Mount the Tower1 shares via Unassigned Devices Plugins

In a file saved under config/plugins/user.scripts/scripts/backup/script place the equivalent Rsync (are these correct)

rsync -r -v --progress --ignore-existing -s /mnt/disks/writeonce/ /mnt/user/writeonce

rsync -r -v --progress --delete -s /mnt/disks/documents/ / mnt/user/documents

 

Schedule the running of the script via Squid's User Scripts plugin

 

Thanks Crew!

Link to comment

 

Alternatively you can also mimic a plugin's cron entries by making a file called /boot/config/plugins/someDummyName/someDummyName.cron with the appropriate cron entry, and every reboot (not sure about starts) unRaid'll add in the cronjob automatically

 

You can also just run update_cron to update the from schedules for changes in /boot/confit/plugins

Link to comment

I installed the plugin onto unRAID 6.2.1 via Community Apps and noticed the following warning:

 

Warning: array_diff(): Argument #1 is not an array in - on line 4

 

There's nothing mentioned in syslog and I haven't noticed any problems. I just thought I'd mention it.

Thanks...  Fixed...

 

It was just a spurious error message (now suppressed) that only displayed on 100% clean installs.  And it didn't affect anything at all.  No update of the plugin is required, as I just changed the .plg to suppress it on clean installs.

Link to comment

I installed the plugin onto unRAID 6.2.1 via Community Apps and noticed the following warning:

 

Warning: array_diff(): Argument #1 is not an array in - on line 4

 

There's nothing mentioned in syslog and I haven't noticed any problems. I just thought I'd mention it.

Thanks...  Fixed...

 

It was just a spurious error message (now suppressed) that only displayed on 100% clean installs.  And it didn't affect anything at all.  No update of the plugin is required, as I just changed the .plg to suppress it on clean installs.

 

Cool. Thanks Squid. I confirm that it was indeed a clean install.

 

Link to comment

Wondering if someone can help..

 

I built a docker for Plex Sync (https://github.com/jacobwgillespie/plex-sync) which syncs your watch lists between multiple Plex Servers. I'm doing this because I"m slowly moving my Plex server to a Linode VPS backed by Amazon Drive (encrypted with EncFS) and I can't seem to get this running with User Scripts.

 

The plex-sync tool is a bit finicky and requires I run the Docker command this way:

docker run -ti --rm plexsync plex-sync TOKEN@source_ip/1 TOKEN@destination_ip/1

 

the -ti runs it in pseudoTTY and in interactive mode. Without these, the plex-sync tool (built on NodeJS) will simply not run for some reason.

 

Trying to run this via User Scripts, I get this in the logs:

 

Script Starting Mon, 24 Oct 2016 18:47:01 -0400

Full logs for this script are available at /tmp/user.scripts/tmpScripts/PlexSyncWatched/log.txt

cannot enable tty mode on non tty input

 

This is Docker throwing the error, I'm guessing due to the environment User Scripts uses to run.

 

Any idea how I can get around this, I'd like to run this script on an hourly basis as I transition my Library to my VPS/ACD

 

Thanks!

Link to comment
  • 2 weeks later...
  • 2 weeks later...

Is it possible to have a script that only executes while the array is up? I was just going to do a cron job but I haven't found the functionality yet to test if the array is up.

You have to incorporate a test into your script.  If the output of
cat /var/local/emhttp/var.ini | grep "mdState"

is

mdSate="STARTED"

then your script can continue

 

Link to comment

meet6.gif

 

Added: Inline variables to scripts

 

Going forward, the file description is now deprecated on user scripts (but will remain supported)

 

The recommended way of setting the description for the script(s) are via inline variables in the script itself.

 

There currently only a few variables available that you can use:  (but I'm thinking about others)

 

description This is the description of the script - ie: what will show up on the UI for the plugin

foregroundOnly Setting this to be true disallows background running (and scheduling) of the script

backgroundOnly Setting this to be true disallows foreground running of the script

arrayStarted Setting this to be true will only run the script (foreground or background or scheduled) if the array is up and running

 

How to implement these variables:  Immediately after the interpreter line (eg: immediately after the #!/bin/bash  *) line, add these lines if you choose:

#description=this is the description of the script

#foregroundOnly=true

#backgroundOnly=true

#arrayStarted=true

 

After the first non comment line within any script, parsing for these variables stops.  (IE: they have to be right at the top of the script file)

 

Note that you do NOT have to have any or all of the lines contained within any particular script.  (Also, if you do have the description file present, then its contents takes precedence over the description variable)

 

*PHP scripters:  You can also place these variable lines immediately after the <? or <?PHP line

 

 

Edited by Squid
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.