Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[Plugin] CA User Scripts

Featured Replies

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

  • 3 weeks later...
  • Replies 2.1k
  • Views 567k
  • Created
  • Last Reply

Top Posters In This Topic

Most Popular Posts

  • I could make up something long, convoluted, and technical as a reason why it doesn't do that but it would all be bs.  The simple answer is that when I did this, I never thought of that, and why it sti

  • Hi All - We have a fix and are publishing a Connect plugin update to fix it today. Thanks for letting us know.

  • @Squid I tried many commands and by that I found out that pkill does not kill (all) child processes: root@Thoth:/tmp# pgrep -f isleep2m | xargs --no-run-if-empty ps fp PID TTY STAT T

Posted Images

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. 

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

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

 

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

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

 

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.

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.

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.

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.

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

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? 

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

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

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

  • Author

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

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?

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

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
 

  • 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

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

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

  • Author
30 minutes ago, Akuno said:

0 4 * * 1

This is what you enter in.  4 AM on Mondays

Yes

Thanks alot guys!

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.