[Plugin] CA User Scripts


Recommended Posts

It's wonky, but it gives me what I need.

I created a FreeDOS VM and called it scripts.

Inside of my borg backup script I start off with a "virsh start scripts" and then end the script with a "virsh destroy scripts".

 

The scripts VM will show running when the borg script is in process and will show stopped when it's not.

 

Close enough. ;-)

Link to comment
  • 3 weeks later...

Good day. appreciate some advice. Have been mounting rclone with the SpaceInvader tutorial for months; which runs the mount script at array start. After moving to Unraid 6.7 stable, this stopped working and on restart if the mount script runs, the array will not start. If I stop the script, the array starts and it's all good.

Would welcome a suggestion to (automatically) run the mount script after the array starts as opposed to on array start.

Thank you. 

Link to comment
  • 2 weeks later...
On 7/12/2019 at 4:08 PM, nraygun said:

It's wonky, but it gives me what I need.

I created a FreeDOS VM and called it scripts.

Inside of my borg backup script I start off with a "virsh start scripts" and then end the script with a "virsh destroy scripts".

 

The scripts VM will show running when the borg script is in process and will show stopped when it's not.

 

Close enough. ;-)

Not totally sure where I would start with something like this but you could probably code up a userscript to display a run status. I would have to imagine all this info is available to be displayed.

Link to comment

I could probably google this but I wonder if someone can help, I want to make a user scrip append something to /etc/samba/smb-shares.conf and then reload samba conf, but just want to add it to the end of a specific share, in this case to the cache share (I have disk shares enable), turn this:

[cache]
    path = /mnt/cache
    comment =
    browsable = yes
    # Public
    writeable = yes

Into:

[cache]
    path = /mnt/cache
    comment =
    browsable = yes
    # Public
    writeable = yes
    vfs objects = btrfs

 

Link to comment

Should have just googled it, found a way of doing what I want, likely not very elegant but it works, problem now is that the script is not working when set to run at array start, I thought it might need a delay for the array to start and the smb-shares.conf to be created but added a "sleep 20" and it still doesn't work, it works if I run it manually after array start, any ideas?

Edited by johnnie.black
Link to comment
7 minutes ago, jonathanm said:

Try firing your script with a simple at now script.

Nope 😪 Not even after starting the array and running that manually, so maybe I'm doing something wrong? The script works if I call it manually after array start, just not scheduled at array start.

Link to comment
1 minute ago, johnnie.black said:

Nope 😪 Not even after starting the array and running that manually, so maybe I'm doing something wrong? The script works if I call it manually after array start, just not scheduled at array start.

Huh. I've never had a failure to fire using the at now technique. Maybe test your at now on a simple test script, like echo "Hi".

 

Just to be clear, you unscheduled your end result script, and scheduled the at now script for array start? Maybe it's a combination of timing errors, and you really do need the short delay AND the at now handoff.

 

The reason I use the at now is because I had a script that would hang the array if run at array start, but ran fine if I passed it off one level deep.

Link to comment
14 hours ago, jonathanm said:

Try firing your script with a simple at now script.

After escaping the space in the script folder name this worked, I still had to add the sleep command, like so:

 

echo "sleep 30 ; /boot/config/plugins/user.scripts/scripts/desired target script/script" | at now

I don't understand why the sleep command doesn't work in the original script, but as long as this works I don't care, thanks.

 

 

Edited by johnnie.black
Link to comment

I have a user script that uses `wget` to download ffmpeg for use on my system. I have it setup to run "at first start of array".  In watching the bootup procedure, the script runs but complains it can't resolve the host, and I think it's due to network connectivity not being available yet.

 

The specific command I'm running is this:

wget -qO- --show-progress --progress=bar:force:noscroll https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-amd64-static.tar.xz -O //boot/custom/ffmpeg/ffmpeg-git-amd64-static.tar.xz

 

Why wouldn't internet connectivity be available by the time the array is started? Is the solution to just add say a multi-minute sleep to the start of the script? 

Link to comment
5 minutes ago, tmchow said:

Is the solution to just add say a multi-minute sleep to the start of the script? 

And you'd probably want to do something like

echo wget -q0 .... | at NOW +5 min

instead.  That's off top of my head.  You'll have to check the syntax of the at command

Link to comment
On 8/13/2019 at 11:32 AM, Squid said:

And you'd probably want to do something like


echo wget -q0 .... | at NOW +5 min

instead.  That's off top of my head.  You'll have to check the syntax of the at command

 

does this block execution of rest of script until that is run? If not, i think I'd have to either:

 

1. run a sleep command instead within the script

2. create another script that uses "at now" to call my existing script

Edited by tmchow
Link to comment

Because of ongoing issues from the IPS forum software which on occasion adds non-printable characters when copying code from the forum into user scripts' editing window, the editing window will now remove all characters over 0x7F when saving an edited script.

 

This solves the problem of copying and then pasting code from the forum directly to the edit window on user scripts.

 

This change will not affect the "code" itself, but may (or may not) affect the use of non-printable characters used in your echo statements.  If this does happen your script will still run, but the characters used in the echos will be removed.  If this happens, edit the script (/boot/config/plugin/user.scripts/.....) manually with your favourite text editor.

 

This update will not affect any existing scripts.  It will only affect the script when editing it.

Edited by Squid
Link to comment
22 hours ago, Squid said:

This update will not affect any existing scripts.  It will only affect the script when editing it.

Wait, what? So if you edit an existing script, it will be affected?

 

I'm guessing what you are saying is that until you open and save an existing script, the update doesn't change anything. Would it break things if instead of silently stripping the offending characters, remap the characters in the display to some visible character?

 

What I'm getting at is instead of silently fixing the issue, make it obvious where the characters are, like maybe blink the space? That way if the unprintable is in a spot where it will break the script, the user can just delete it, if it's intentional you can still use the web editor without stripping them?

Link to comment
5 minutes ago, jonathanm said:

Wait, what? So if you edit an existing script, it will be affected?

 

Yeah.  Catch-22.  Non ascii characters will be removed.  Personally, I doubt that any given script would ever have them in it.  If any problems happen because of this, then I will re-address.  In the meantime, this is the solution to copy / paste scripts from the forum.

Edited by Squid
Link to comment

Probably a simple syntax issue, but I have tried every format and combination I could think of and still can't figure out how to sync between two shares on my local network.

 

Setup:
remote = Machine1 = unraid box with source media held in a SMB-shared user share "mc1media"
local = Machine2 = unraid box running rclone, with disk share "mediasync"

 

I don't see any errors, but any files I put in "mc1media/test" don't sync to "mediasync/test".

Any help is GREATLY appreciated!


The most recent scripts and results below.

rclone.conf:

    [mediasync]
    type = local
    copy_links = true
    links = false


Rclone Mount Script:
 

    #----------------------------------------------------------------------------
    #!/bin/bash
    localshare="/mnt/disks/mediasync/test"
    remoteshare="//10.10.0.5/mnt/user/mc1media/test"
    mkdir -p $localshare     # create local folder
    rclone mount -vv --max-read-ahead 1024k --allow-other $remoteshare $localshare &
    #----------------------------------------------------------------------------

LOG FILE:
Script Starting Sun, 18 Aug 2019 15:36:33 -0400
Script Finished Sun, 18 Aug 2019 15:36:33 -0400

2019/08/18 15:36:33 DEBUG : rclone: Version "v1.48.0" starting with parameters ["rcloneorig" "--config" "/boot/config/plugins/rclone/.rclone.conf" "mount" "-vv" "--max-read-ahead" "1024k" "--allow-other" "//10.10.0.5/mnt/user/mc1media/test" "/mnt/disks/mediasync/test"]
2019/08/18 15:36:33 DEBUG : Using config file from "/boot/config/plugins/rclone/.rclone.conf"
2019/08/18 15:36:33 DEBUG : Local file system at /10.10.0.5/mnt/user/mc1media/test: Mounting on "/mnt/disks/mediasync/test"
2019/08/18 15:36:33 INFO  : Local file system at /10.10.0.5/mnt/user/mc1media/test: poll-interval is not supported by this remote
2019/08/18 15:36:33 DEBUG : Adding path "vfs/forget" to remote control registry
2019/08/18 15:36:33 DEBUG : Adding path "vfs/refresh" to remote control registry
2019/08/18 15:36:33 DEBUG : Adding path "vfs/poll-interval" to remote control registry
2019/08/18 15:36:33 DEBUG : : Root: 
2019/08/18 15:36:33 DEBUG : : >Root: node=/, err=<nil>
 

 

Rclone Sync Script:

    #----------------------------------------------------------------------------
    #!/bin/bash
    localshare="/mnt/disks/mediasync/test"
    remoteshare="//10.10.0.5/mnt/user/mc1media/test"
    rclone sync -vv $localshare $remoteshare
    #----------------------------------------------------------------------------

LOG FILE:
Script Starting Sun, 18 Aug 2019 15:43:08 -0400

2019/08/18 15:43:09 DEBUG : rclone: Version "v1.48.0" starting with parameters ["rcloneorig" "--config" "/boot/config/plugins/rclone/.rclone.conf" "sync" "-vv" "/mnt/disks/mediasync/test" "//10.10.0.5/mnt/user/mc1media/test"]
2019/08/18 15:43:09 DEBUG : Using config file from "/boot/config/plugins/rclone/.rclone.conf"
2019/08/18 15:43:09 INFO  : Local file system at /10.10.0.5/mnt/user/mc1media/test: Waiting for checks to finish
2019/08/18 15:43:09 INFO  : Local file system at /10.10.0.5/mnt/user/mc1media/test: Waiting for transfers to finish
2019/08/18 15:43:09 INFO  : Waiting for deletions to finish
2019/08/18 15:43:09 INFO  : 
Transferred:                0 / 0 Bytes, -, 0 Bytes/s, ETA -
Errors:                 0
Checks:                 0 / 0, -
Transferred:            0 / 0, -
Elapsed time:          0s

2019/08/18 15:43:09 DEBUG : 3 go routines active
2019/08/18 15:43:09 DEBUG : rclone: Version "v1.48.0" finishing with parameters ["rcloneorig" "--config" "/boot/config/plugins/rclone/.rclone.conf" "sync" "-vv" "/mnt/disks/mediasync/test" "//10.10.0.5/mnt/user/mc1media/test"]
Script Finished Sun, 18 Aug 2019 15:43:09 -0400
 

Link to comment
  • 3 weeks later...

Hi guys

First let me thank you for the tool and support you provide.

Now my question. I just made a script

#!/bin/bash
reboot

and it works finde. Yeay! :D

Now I want it to be sheduled every monday at 04:00 am how do i set the custom crone shedule? (what do i write in there?)
Tahnks for your help

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.