Jump to content
Squid

[Plugin] CA User Scripts

722 posts in this topic Last Reply

Recommended Posts

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

 

crontab -l > /tmp/temp
echo 25 0 * * * ssh admin@192.168.178.24 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

Share this post


Link to post

what time does the "scheduled daily" task run and is there any way to customize this?

Install the dynamix schedules plugin (find it in CA) and you can then adjust the time of day via Settings - Schedules - Fixed Schedules

Share this post


Link to post

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

 

Share this post


Link to post

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

Share this post


Link to post

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!

Share this post


Link to post

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.

User_Scripts.png.090b056e6471c845ae87fdbbbb45b472.png

Share this post


Link to post

 

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

Share this post


Link to post

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.

Share this post


Link to post

@Squid.  You mentioned being able to view the log output from previous script runs. 

How do I view this?

What is written to the log? - is it a full capture of the command line output? (would be great).

 

Thanks.

Share this post


Link to post

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.

 

Share this post


Link to post

Logs are saved when the script is run in the background or on a schedule.  No log is captured if running in the foreground

 

Sent from my LG-D852 using Tapatalk

 

 

Share this post


Link to post

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!

Share this post


Link to post

^^^^^^^^^

 

WooHoo!!!

 

Was wondering why the spammers always ignored my threads...  Now I feel special

Share this post


Link to post

^^^^^^^^^

 

WooHoo!!!

 

Was wondering why the spammers always ignored my threads...  Now I feel special

 

He's posting all over the place..

Share this post


Link to post

^^^^^^^^^

 

WooHoo!!!

 

Was wondering why the spammers always ignored my threads...  Now I feel special

 

He's posting all over the place..

You just had to rain on my parade, didn't you  >:(

Share this post


Link to post

^^^^^^^^^

 

WooHoo!!!

 

Was wondering why the spammers always ignored my threads...  Now I feel special

 

He's posting all over the place..

You just had to rain on my parade, didn't you  >:(

 

What can I say, it's a gift.. :)

Share this post


Link to post

^^^^^^^^^

 

WooHoo!!!

 

Was wondering why the spammers always ignored my threads...  Now I feel special

 

He's posting all over the place..

You just had to rain on my parade, didn't you  >:(

 

What can I say, it's a gift.. :)

 

You guys are seeing ghosts...

Share this post


Link to post
On 11/3/2016 at 6:55 PM, dockerPolice said:

If the alleged perp strayed into docker territory, it would have been all over far sooner.  As it stands, it was pluginCop (pfft) who, as usual was slow on the draw.

Did I miss something?

205badffd47d011724fa84f8e61bfbb2_3224.jp

Edited by pluginCop

Share this post


Link to post

I was a bit baffled by the posts above, investigated, spotted the IP's, and figured it out.  ;)  And I'm not talking!

Share this post


Link to post

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.

Share this post


Link to post

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

 

Share this post


Link to post

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

Share this post


Link to post

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.