[Plugin] CA User Scripts


Recommended Posts

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

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

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

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

Link to comment

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

Link to comment

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'

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

Link to comment
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"

 

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

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

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

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.