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

Well, not sure if hard linking would be best.  Once the files are copied (just for now will eventually move them) to the sonarr pick up folder, sonarr will do a move and rename from there to the final destination.  So in the pickup folder and in the syncthing folder there will be no files once sonarr has done it's job.  Then when a new episode of a watched show is grabbed by sonarr and passed to deluge, it will be donwloaded and grabbed by syncthing and the process starts over with the script....or I hope it works anyhow.  That's the idea.

 

 

  • Replies 2.1k
  • Views 567.3k
  • 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

Hmm got an error running the script

Script location: /tmp/user.scripts/tmpScripts/SonarrCopy/script
Note that closing this window will abort the execution of this script
mv: invalid option -- 'R'
Try 'mv --help' for more information.

 

I had

mv -R /mnt/disks/DELUGETorrents/Seedbox_Downloads/* /mnt/disks/DELUGETorrents/Sonarr_Pickup/

 

I'm guessing the -R was for copy only?

Edited by DigitalDivide

You are correct, just remove the "-R" option when using the "mv" command.

Removed the -r and it worked.

Hi Guys,

Great plugin, I have two small questions:

- Will the scheduler start a script if it's still running? (I only want to run one piece in any single time, otherwise I need to put some simple locking into the script)

- I have a simple script what's running rclone sync. When I click on the abort button the  button disappears but the script keeps running. I have to kill the processes manually. How should I run it to be able to abort from the GUI? 

  • Author
59 minutes ago, Norbs said:

Will the scheduler start a script if it's still running?

yes

 

59 minutes ago, Norbs said:

When I click on the abort button the  button disappears but the script keeps running. I have to kill the processes manually.

Long running processes cannot be killed via the abort button.  (I've tried everything to try and kill the PID of children from the PID of the parent, and nothing works because of how everything works under the hood)

Thx for the quick answer.  No worries, it's not a big deal, I can kill the processes from command line (in my case rclone forks an rcloneorig process, killing both with the default SIGTERM works fine)

Just another question on my script, mv /mnt/disks/DELUGETorrents/Seedbox_Downloads/* /mnt/disks/DELUGETorrents/Sonarr_Pickup/

 

If a file is being written to the /seedbox_downloads/ folder and the script above runs, will it try to copy the file while it's still being written?  When a files is being written (synched) to the folder, Syncthing names it .sync(filename).  Would I need to put in the move to exclue anything that starts with ".synch"?  If so, what would I need to add to the above script.

If your source files have all the same extension you could use this:

/mnt/disks/DELUGETorrents/Seedbox_Downloads/*.mp4

 

Or this one should work, too:

/mnt/disks/DELUGETorrents/Seedbox_Downloads/!(*.synch)

21 minutes ago, mgutt said:

If your source files have all the same extension you could use this:

/mnt/disks/DELUGETorrents/Seedbox_Downloads/*.mp4

 

Or this one should work, too:

/mnt/disks/DELUGETorrents/Seedbox_Downloads/!(*.synch)

I think I didn't explain that properly.  The file starts with .sync so I think in the case of *.synch, that's looking for all files with .synch extension.  That won't work.  All files end in .mkv including the ones being written.  I think I need something that excludes all .syncthing.*

 

Just not sure how to do it.

Then try

!(.syncthing.*)

 

I think this should work.

1 hour ago, mgutt said:

Then try

!(.syncthing.*)

 

I think this should work.

Could I change that to !(.sync*.*) 

 

Would that work?

It didn't work, got the following error 

Script location: /tmp/user.scripts/tmpScripts/SonarrCopy/script
Note that closing this window will abort the execution of this script
/tmp/user.scripts/tmpScripts/SonarrCopy/script: line 2: syntax error near unexpected token `('
/tmp/user.scripts/tmpScripts/SonarrCopy/script: line 2: `mv /mnt/disks/DELUGETorrents/Seedbox_Downloads/!(.syncthing.*) /mnt/disks/DELUGETorrents/Sonarr_Pickup/'

 

I tried with !(.sync*.*) and got the same error as above.

seems to work.  I'll have to do some testing to see. 

 

Much appreciated the assistance!

Hi, I've one docker container that somehow often fails to restart after e.g. stop for backup.

However, if manually initiated it, it works. Always. I tried checking logs etc but couldn't find a solution.

 

Then I remembered that User Scripts is able to use "restart" command to start a docker container and I could configure it to run every now and then.

However, I don't want it to restart if the status is already running. How can I add something like "if status = active, idle, else star/restart dockercontainer.

 

Can someone please help me to find those commands if possible or point me to script documentation? Or do I need to look at docker commands? Ofc. I tried searching the forums beforehand but couldn't find a solution or similar case yet. If I missed it, feel free to point me to it.

 

Thanks

2 hours ago, twok said:

However, I don't want it to restart if the status is already running. How can I add something like "if status = active, idle, else star/restart dockercontainer.

 

This is how I check the status and start a container through one of my scripts:

        # check if mkvtoolnix container exists
        if [[ ! "$(docker ps -q -f name=mkvtoolnix_mkv2sub)" ]]; then # https://stackoverflow.com/a/38576401/318765
            # check for blocking container
            if [[ "$(docker ps -aq -f status=exited -f name=mkvtoolnix_mkv2sub)" ]]; then
                docker rm mkvtoolnix_mkv2sub
            fi
            echo "mkvtoolnix container needs to be started"
            # start mkvtoolnix container
            docker_options=(
                run -d
                --name=mkvtoolnix_mkv2sub
                -e TZ=Europe/Berlin
                -v "${docker_config_path}mkvtoolnix_mkv2sub:/config:rw"
                -v "${movies_path}:/storage:rw"
                jlesage/mkvtoolnix
            )
            echo "docker ${docker_options[@]}"
            docker "${docker_options[@]}"
        fi

 

Found here:

https://stackoverflow.com/a/38576401/318765

 

But this checks only if the container is already existing or its status is "exited".

 

I tried to check if the container is not used anymore by its cpu usage, but this produced problems with parallel running scripts so I disabled it:

    # check if container exists
    if [[ -x "$(command -v docker)" ]] && [[ "$(docker ps -q -f name=mkvtoolnix_mkv2sub)" ]]; then
        # stop container only if its not in use (by other shell script)
        mkvtoolnix_cpu_usage="$(docker stats mkvtoolnix_mkv2sub --no-stream --format "{{.CPUPerc}}")"
        # if [[ ${mkvtoolnix_cpu_usage%.*} -lt 1 ]]; then
            # we do not stop the container as our script is not race-condition safe!
            # echo "Stop mkvtoolnix container"
            # docker stop mkvtoolnix_mkv2sub
            # docker rm mkvtoolnix_mkv2sub
        # fi
    fi

Maybe I will set in the future a random container name and clean them up after they become too old. I'm not sure.

Edited by mgutt

Hi,

 

I want to run a command every 12 hours, here is the command and it works from putty


docker exec -u abc -it sabnzbdrninja /downloads/opus/opus.bash /music

 

if I put that in user scripts it does not work?  

 

#!/bin/bash
docker exec -u abc -it sabnzbdrninja /downloads/opus/opus.bash /music

 

here is the log output, do I need to do something else?

 

Script Starting Jun 02, 2020  15:14.32

Full logs for this script are available at /tmp/user.scripts/tmpScripts/music folder - flac to opus/log.txt

the input device is not a TTY
Script Finished Jun 02, 2020  15:14.32

Full logs for this script are available at /tmp/user.scripts/tmpScripts/music folder - flac to opus/log.txt
 

 

Many Thanks

Hello.

I am running into a slight issue. I just updated from 6.7.2 to 6.8.3 (a little late, I know) and it seems to have broken one of my scripts. Any time I try to run

Quote

/etc/rc.d/rc.docker start

or

Quote

/etc/rc.d/rc.docker restart

the done button never appears which leads me to believe the script is hanging. If I open the docker tab of the web ui in another browser tab without closing the script, the docker service appears to have started and works fine. However, closing the script in the original tab causes it to abort leading the docker service to return that it failed to start despite it working fine up until then. I have deleted my docker image to verify that it was not an issue with docker and the issue persists. Executing the same commands from the terminal works fine. Any help would be very appreciated!

Hi everyone,

 

I just setup rclone with user scripts. All good but I can´t configure a schedule. Whenever I change a schedule status "apply" appears and when I hit it nothing happens.

 

What am I missing here?

  • Author

What are you expecting to happen?  Does Schedule Applied appear and the Apply button go back to being grayed out after hitting it?

I expect it to safe the new schedule status, but it doesn´t. Apply doesn´t work for me, no schedule applied message.

 

I deinstalled and reinstalled user scripts. Same problem.

Edited by antagon

I'm getting the following error on m

y move script

Script location: /tmp/user.scripts/tmpScripts/SonarrCopy/script
Note that closing this window will abort the execution of this script
mv: cannot move '/mnt/disks/DELUGETorrents/Seedbox_Downloads/The 100 Season 3 [1080p] WEB-DL H264' to '/mnt/disks/DELUGETorrents/Sonarr_Pickup/The 100 Season 3 [1080p] WEB-DL H264': File exists
mv: cannot move '/mnt/disks/DELUGETorrents/Seedbox_Downloads/The.100.S06.1080p.BluRay.x264-TURMOiL' to '/mnt/disks/DELUGETorrents/Sonarr_Pickup/The.100.S06.1080p.BluRay.x264-TURMOiL': File exists

 

I suspect that when a folder is being moved that has 3 or 4 files in it but a copy is still copying the rest of the files there, when the script runs an hour later and sees an existing folder it won't overwrite it.   Is there a way to have my script below overwrite an existing folder?

 

#!/bin/bash
shopt -s extglob

mv /mnt/disks/DELUGETorrents/Seedbox_Downloads/!(.sync*.*) /mnt/disks/DELUGETorrents/Sonarr_Pickup/

 

Would this be correct?

mv - f /mnt/disks/DELUGETorrents/Seedbox_Downloads/!(.sync*.*) /mnt/disks/DELUGETorrents/Sonarr_Pickup/

 

As well, if I want to change the above script to not copy files ending in a .tmp extension instead would it read

mv - f /mnt/disks/DELUGETorrents/Seedbox_Downloads/!(*.tmp) /mnt/disks/DELUGETorrents/Sonarr_Pickup/

 

Edit: tried the -f but that didn't work...not sure if I have it in the wrong place or just have it wrong

Edited by DigitalDivide

So I tried

#!/bin/bash
shopt -s extglob

mv [-f]/mnt/disks/DELUGETorrents/Seedbox_Downloads/*.mkv /mnt/disks/DELUGETorrents/Sonarr_Pickup/

 

However that didn't work.  I got the following errror now.  I think that's because some files are in the folder /seedbox_downloads itself and some get dumped into folders beneath it and the script it just looking at the top folder which in this case has no files in it but the subfolders do...I'm guessing....I guess I need the script to copy all .mkv files in the top folder and any folders with .mkv files in it as well.

 

Script location: /tmp/user.scripts/tmpScripts/SonarrCopy/script
Note that closing this window will abort the execution of this script
mv: cannot stat '[-f]/mnt/disks/DELUGETorrents/Seedbox_Downloads/*.mkv': No such file or directory

Edited by DigitalDivide
clarify

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.