Jump to content
Squid

[Plugin] CA User Scripts

755 posts in this topic Last Reply

Recommended Posts

4 hours ago, comet424 said:

hi i like to know using the cron guru generator site

to do every 3rd month  does this start whenever i save the crontab

“At 04:00 on day-of-month 1 and on Monday in every 3rd month.”

0 4 1 */3 1

or does it change everytime you reboot unraid

 

now my other one i tried is 

doing this to start From January and do ever 3 months 

“At 04:00 on day-of-month 1 and on Monday in every 3rd month from January through December.”

0 4 1 1/3 1

 

now the 2nd option is what i perfer... least for now..  but the cronguru page says it may not work on some cron jobs.. will that work for unraid the 2nd option..

"non standard! May not work with every cron."  is the error on the page i get..

 

and if i wanted to do specific months how does it work for unraid..  i tried some other crontab jobs examples like JAN APR AUG NOV   for the month section  but unraid didnt like that....

 

0 4 1 1,3,5,7,9,11 *

 

At 00 minutes past 4:00 on the 1st day of Jan, Mar, May, Jul, Sep, and Nov

Share this post


Link to post

Does anyone know if there is a way to post the status of a script to unRaid's dashboard?

I'd like to see if my backup script is still running right on the dashboard instead of going into the CA User Scripts area.

Share this post


Link to post

Not until if the dashboard gets opened up for other cards

Sent from my NSA monitored device

Share this post


Link to post

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. ;-)

Share this post


Link to post

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. 

Share this post


Link to post
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.

Share this post


Link to post

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

 

Share this post


Link to post
Posted (edited)

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

Share this post


Link to post
13 minutes ago, johnnie.black said:

It works if I run it manually after array start, any ideas?

Try firing your script with a simple at now script.

#!/bin/bash
echo "/boot/config/plugins/user.scripts/scripts/desired target script/script" | at now

 

Share this post


Link to post
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.

Share this post


Link to post
5 minutes ago, johnnie.black said:

Not even after starting the array and running that manually, so maybe I'm doing something wrong?

I was, apparently I can't have spaces in the name, I'll try again tomorrow since I'm out for the rest of the day.

Share this post


Link to post
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.

Share this post


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

apparently I can't have spaces in the name

Which part?

 

In general I make it a habit not to use spaces whenever possible, I hate tracking down those type errors.

Share this post


Link to post
Posted (edited)
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

Share this post


Link to post

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? 

Share this post


Link to post
4 minutes ago, tmchow said:

Why wouldn't internet connectivity be available by the time the array is started?

Sometimes depending upon NIC / router it is delayed

Share this post


Link to post
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

Share this post


Link to post
Posted (edited)
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

Share this post


Link to post
Posted (edited)

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

Share this post


Link to post
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?

Share this post


Link to post
Posted (edited)
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

Share this post


Link to post

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
 

Share this post


Link to post

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

Share this post


Link to post
1 hour ago, Akuno said:

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

You can use the crontab generator-

https://crontab-generator.org

Share this post


Link to post
On 9/9/2019 at 12:01 AM, wgstarks said:

You can use the crontab generator-

https://crontab-generator.org

Tahnk you for the link. I got this out:

0 4 * * 1 reboot >/dev/null 2>&1

 

But I think I just need to set in the userscript the crone shedule to custom and write there >0 4 * * 1<. Am I right?

Edited by Akuno

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.