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

The [-f] in the documentation means that -f is optional. You must not type the brackets in your script to use it.

 

And you made a second mistake. You did not add a white space, so mv tried to find the path "[-f]/mnt...". That's the reason why it returned the "no such directory" error.

Edited by mgutt

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

ok modified to 

#!/bin/bash
shopt -s extglob

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

 

Got the exact same error. I double checked and there is a folder beneath seedbox_downloads with a bunch of mkv files.

 

I wondering about something else as well.  If the tv series folder in /seedbox_downloads/ is still being written to and the script runs, it can't actually move the folder can it?  Does it mean that will just move the episodes that have completed and have a *.mkv extension.  When they are being written to they have a *.tmp extension.

 

 

Edited by DigitalDivide
clarify

So I put back my orig script and just added the -f to see if it won't overwrite without prompting on giving an error.  I got the arror below but it did move the files.

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

 

So to my orig script below I changed it to read below and it doesn't do anything.  I'm so confused at this point.

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

 

Orig script

#!/bin/bash
shopt -s extglob

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

Edited by DigitalDivide

Hmm I wonder why this does not work.

 

But you can instead use rsync with the --remove-source-files option. This will delete the source after it has been transfered to the target. Example:

rsync -a --remove-source-files --exclude=".sync*" /mnt/disks/DELUGETorrents/Seedbox_Downloads/ /mnt/disks/DELUGETorrents/Sonarr_Pickup/

 

Explanation:

-a = -rlptgoD = recursive, symbolic links, preserve all auth, preserve date

--remove-soure-files = delete source file after transfer

--exclude=".sync*"  = ignore files starting with ".sync

 

Another useful setting if you want to use rsync to sync two folders:

--delete = delete files in the target that are not present in the source (not useful in combination with "--remove-soure-files") ;)

The problem is rscync is a copy that takes much longer.  The pickup folder is being watched by Sonarr to copy the files to the final destination.  If the file is still being written I have a feeling Sonarr might try to copy a partial file that rsync is still copying.  Move is done instantly.

 

 

Do you maybe aren't allowed to delete the target file? In this manual it says that the target file is removed before the local file is moved:

https://unix.stackexchange.com/a/236676/101920

 

You should test it in a script by using rm:

rm '/mnt/disks/DELUGETorrents/Sonarr_Pickup/The 100 Season 3 [1080p] WEB-DL H264'

 

 

Edited by mgutt

When I do the remove command it tells me it can't because it's a directory.

rm: cannot remove '/mnt/disks/DELUGETorrents/Sonarr_Pickup/The.100.S06.1080p.BluRay.x264-TURMOiL': Is a directory

 

I tried with a file in it and with no files in the folder.  Same message.  Seems rm can't remove a folder...??

Ok that worked.  So I know the folder can be removed.  I think it just can't overwrite an existing folder when I use the mv command

 

I think you may have missed what I typed above.  The below did remove the folder.  The issue is now with the MV command.  I don't think it will overwrite an existing folder.  I think I may just have to leave things as they are.  

 

rm '/mnt/disks/DELUGETorrents/Sonarr_Pickup/The 100 Season 3 [1080p] WEB-DL H264'

On 6/10/2020 at 11:25 AM, Squid said:

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

Same issue happened for me. 

 

If I change the timing(or disable) any of the scripts, apply lights up(so i can click it). but when i actually click, nothing happens. upon refresh or revisiting this page the changes are not saved. it worked a few minutes ago but not its not. 

  • Author
8 minutes ago, Aerodb said:

Same issue happened for me. 

 

If you look at the syslog (Tools), do you see "bread" errors?

1 minute ago, Squid said:

If you look at the syslog (Tools), do you see "bread" errors?

I do not see an Errors with any "bread" text. 

 

one error but doesn't seem related. Error text below just in case its helpful. 

error start- 

Jun 13 17:57:20 SCRUBBED nginx: 2020/06/13 17:57:20 [error] 15488#15488: *12780505 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 127.0.0.1, server: , request: "GET /admin/api.php?version HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "127.0.0.1"
Jun 13 17:57:20 SCRUBBED nginx: 2020/06/13 17:57:20 [error] 15488#15488: *12780507 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 127.0.0.1, server: , request: "GET /admin/api.php?version HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "localhost"

 

1 hour ago, DigitalDivide said:

Ok that worked.  So I know the folder can be removed.  I think it just can't overwrite an existing folder when I use the mv command

 

Yes, that's correct. Sorry, I thought it was a file because mv returned a file error instead of "Directory not empty" error for directories.

 

mv is not able to merge dirs.

 

cp is able to do that. Example:

cp -al source/folder destination

rm -r source/folder

 

The -l option causes to create hardlinks instead of copying the files. But cp does not contain an exclude flag so it does not solve your problem.

 

Instead use rsync "--link-dest=". By that it creates hardlinks and does NOT copy the files and after that "--remove-source-files" removes the initial hardlink of a file:

 

rsync -a --remove-source-files --exclude=".sync*" --link-dest=/mnt/disks/DELUGETorrents/Seedbox_Downloads/ /mnt/disks/DELUGETorrents/Seedbox_Downloads/ /mnt/disks/DELUGETorrents/Sonarr_Pickup/

 

Sadly it does not remove the empty dirs in the source. This needs a separate command:

https://unix.stackexchange.com/a/46326/101920

On 6/14/2020 at 1:11 AM, Squid said:

If you look at the syslog (Tools), do you see "bread" errors?

no "bread" errors for me. One thing I see is one user scipts related error:

root: error: /plugins/user.scripts/exec.php: uninitialized csrf_token

  • Author
2 hours ago, antagon said:

uninitialized csrf_token

That would definitely cause the problem you're seeing.  Only time the forum has ever seen that error is when either rootfs or tmpfs is completely full.

 

If you can, post a diagnostics.  Either way, a reboot is going to be required.

On 6/9/2020 at 2:55 AM, Ecsport108 said:

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

or

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!

Is anyone else having issues running either of these commands. Alternatively, does anyone have any ideas I what I can do to correct this issue. I can still run the commands manually it's just a bit annoying.

Edited by Ecsport108

17 hours ago, Squid said:

That would definitely cause the problem you're seeing.  Only time the forum has ever seen that error is when either rootfs or tmpfs is completely full.

 

If you can, post a diagnostics.  Either way, a reboot is going to be required.

there you go :) 

tower-diagnostics-20200616-0727 2.zip

Edited by antagon

Maybe someone needs a script for file encryption:

 

  • Author

Yes it does.  However, any long-running processes spawned by the script will run to completion.  (ie: your rsync)

1 hour ago, Squid said:

Yes it does.  However, any long-running processes spawned by the script will run to completion.  (ie: your rsync)

My script contains a loop of different short running processes (mkdir, openssl, touch) and not one long running single process. If I close f.e. the "Run Script" window it is killed completely (as expected).

Edited by mgutt

On 6/13/2020 at 6:11 PM, Squid said:

If you look at the syslog (Tools), do you see "bread" errors?

checked syslog, not seeing anything with the word "bread" in it. yet i cant apply any changes in the user scripts plugin. i can only run the scripts or hit done. 

On 6/21/2020 at 6:20 AM, Squid said:

Then post the diagnostics

Sorry for the delay. I pulled the log and have attached. Think you could take a look and share some wisdom?

aeroserver2-syslog-20200629-0051.zip

31 minutes ago, Aerodb said:

I pulled the log and have attached.

That is not the diagnostics. Diagnostics includes log but also other things.

 

Tools - Diagnostics.

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.