DigitalDivide Posted May 30, 2020 Share Posted May 30, 2020 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. Quote Link to comment
DigitalDivide Posted May 30, 2020 Share Posted May 30, 2020 (edited) 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 May 30, 2020 by DigitalDivide Quote Link to comment
remotevisitor Posted May 30, 2020 Share Posted May 30, 2020 You are correct, just remove the "-R" option when using the "mv" command. Quote Link to comment
DigitalDivide Posted May 30, 2020 Share Posted May 30, 2020 Removed the -r and it worked. Quote Link to comment
Norbs Posted May 31, 2020 Share Posted May 31, 2020 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? Quote Link to comment
Squid Posted May 31, 2020 Author Share Posted May 31, 2020 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) 1 Quote Link to comment
Norbs Posted May 31, 2020 Share Posted May 31, 2020 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) Quote Link to comment
DigitalDivide Posted May 31, 2020 Share Posted May 31, 2020 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. Quote Link to comment
mgutt Posted May 31, 2020 Share Posted May 31, 2020 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) Quote Link to comment
DigitalDivide Posted May 31, 2020 Share Posted May 31, 2020 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. Quote Link to comment
mgutt Posted May 31, 2020 Share Posted May 31, 2020 Then try !(.syncthing.*) I think this should work. Quote Link to comment
DigitalDivide Posted May 31, 2020 Share Posted May 31, 2020 1 hour ago, mgutt said: Then try !(.syncthing.*) I think this should work. Could I change that to !(.sync*.*) Would that work? Quote Link to comment
DigitalDivide Posted June 1, 2020 Share Posted June 1, 2020 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. Quote Link to comment
mgutt Posted June 1, 2020 Share Posted June 1, 2020 You need to add "shopt -s extglob" to allow this command: https://askubuntu.com/a/1228370/227119 Quote Link to comment
DigitalDivide Posted June 1, 2020 Share Posted June 1, 2020 seems to work. I'll have to do some testing to see. Much appreciated the assistance! Quote Link to comment
twok Posted June 2, 2020 Share Posted June 2, 2020 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 Quote Link to comment
mgutt Posted June 2, 2020 Share Posted June 2, 2020 (edited) 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 June 2, 2020 by mgutt Quote Link to comment
mbc0 Posted June 2, 2020 Share Posted June 2, 2020 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 Quote Link to comment
mgutt Posted June 2, 2020 Share Posted June 2, 2020 18 minutes ago, mbc0 said: the input device is not a TTY Solution? https://stackoverflow.com/a/43099210/318765 Quote Link to comment
Ecsport108 Posted June 9, 2020 Share Posted June 9, 2020 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! Quote Link to comment
antagon Posted June 10, 2020 Share Posted June 10, 2020 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? Quote Link to comment
Squid Posted June 10, 2020 Author Share Posted June 10, 2020 What are you expecting to happen? Does Schedule Applied appear and the Apply button go back to being grayed out after hitting it? Quote Link to comment
antagon Posted June 11, 2020 Share Posted June 11, 2020 (edited) 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 June 11, 2020 by antagon Quote Link to comment
DigitalDivide Posted June 13, 2020 Share Posted June 13, 2020 (edited) 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 June 13, 2020 by DigitalDivide Quote Link to comment
DigitalDivide Posted June 13, 2020 Share Posted June 13, 2020 (edited) 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 June 13, 2020 by DigitalDivide clarify Quote Link to comment
Recommended Posts
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.