DZMM Posted March 11, 2018 Share Posted March 11, 2018 1 hour ago, hmgnsd said: Hello all! Would anyone be able to cast their eyes over a couple of scripts I have āadaptedā for my download setup? Ā The first one I donāt think there is a problem with, it should move Handbrake converted files from one directory to another where a media manager can pick them up: Ā Ā The next one, is supposed to delete theĀ original files after they have been copied. Ā Ā The last time I tried it, it looked like it was removing files from all directories which was not the desired effect. Ā Ā why not set the output folder for handbrake as your blackhole folder? Quote Link to comment
hmgnsd Posted March 11, 2018 Share Posted March 11, 2018 Thank you for the suggestion, I have looked at other possibilities before finding something that works for me regarding radarr/sonarr and post processing media. I can go in an delete the left overs manually but if I can get this script working itād be much less maintenance. Quote Link to comment
hmgnsd Posted March 15, 2018 Share Posted March 15, 2018 OK, anyone? This script to move files from one directory to another is removing the source directory if empty after it runs , how can I prevent it doing that? Ā #!/bin/bash if [ -f /var/run/mymover.pid ]; then if ps h `cat /var/run/mymover.pid` | grep mymover.sh ; then echo "mymover already running, sorry." exit 0 fi fi echo $$ >/var/run/mymover.pid echo "Moving files from $1 to $2" (cd "/mnt/user/downloads/Complete/"; find -depth -print \( ! -exec fuser -s '{}' \; -exec rsync -i -qdIWRpEAXogt --numeric-ids --inplace --remove-source-files {} "/mnt/user/downloads/Import/" \; \)) # Prune empty directories from source dir find "/mnt/user/downloads/Complete/" -type d -empty -prune -exec rmdir --ignore-fail-on-non-empty {} \; # Prune empty directories from destination dir find "/mnt/user/downloads/Import/" -type d -empty -prune -exec rmdir --ignore-fail-on-non-empty {} \; sync rm /var/run/mymover.pid echo "Moving all done." Ā Quote Link to comment
BRiT Posted March 15, 2018 Share Posted March 15, 2018 Remove or comment out the line under the comment of #Ā Prune empty directories from source dir Quote Link to comment
hmgnsd Posted March 15, 2018 Share Posted March 15, 2018 2 minutes ago, BRiT said: Remove or comment out the line under the comment of #Ā Prune empty directories from source dir Ā Ah, that's moving stuff but now /mnt/user/downloads/complete/season 01/ directory is left, for example... There's no way of getting the subdirectories from /complete/ moved without it deleting the directory /complete/ is it's empty? Ā Am I making sense? I feel like I'm not.Ā Quote Link to comment
NewDisplayName Posted March 15, 2018 Share Posted March 15, 2018 (edited) COuld someone help me? Ā I would like a script which limit nzbget if IP1 and or IP2 are online. Ā Ive foundĀ https://nzbget.net/api/Ā but no exemple, and since i cant code...Ā Ā Something like if { ping 192.168.0.1 | 192.168.0.2 search for *not reachable* } http... /limit/nzbget 0Ā (no limit) else {Ā Ā http.../limit/nzbget 500 } (means 500kbs) Ā Edited March 15, 2018 by nuhll Quote Link to comment
JonathanM Posted March 15, 2018 Share Posted March 15, 2018 5 hours ago, hmgnsd said: Am I making sense? I feel like I'm not.Ā Well, here's what you said. 5 hours ago, hmgnsd said: This script to move files from one directory to another is removing the source directory if empty after it runs , how can I prevent it doing that? and then you said... 5 hours ago, hmgnsd said: now /mnt/user/downloads/complete/season 01/ directory is left It sounds like in the first post you want the empty folders left behind, in the second post you complain that it left them behind. Ā So no, you aren't making sense. Quote Link to comment
hmgnsd Posted March 15, 2018 Share Posted March 15, 2018 1 minute ago, jonathanm said: Well, here's what you said. and then you said... It sounds like in the first post you want the empty folders left behind, in the second post you complain that it left them behind. Ā So no, you aren't making sense. Ā My apologies!Ā Let me simplify; I would like the script to move the files and folders in the directory /downloads/complete/. What I have noticed, is that when that directory is empty and the script runs, it actually removes the directory /downloads/complete/. Ā How could I adapt it to move the contents of the directory, but not remove the directory itself when empty? Quote Link to comment
itimpi Posted March 15, 2018 Share Posted March 15, 2018 5 minutes ago, hmgnsd said: Ā My apologies!Ā Let me simplify; I would like the script to move the files and folders in the directory /downloads/complete/. What I have noticed, is that when that directory is empty and the script runs, it actually removes the directory /downloads/complete/. Ā How could I adapt it to move the contents of the directory, but not remove the directory itself when empty? I think that if you changed the second phase to start with a ācdā like in the first phase it will give you the results you want. Quote Link to comment
hmgnsd Posted March 15, 2018 Share Posted March 15, 2018 4 minutes ago, itimpi said: I think that if you changed the second phase to start with a ācdā like in the first phase it will give you the results you want. Like this? # Prune empty directories from source dir find cd "/mnt/user/downloads/Complete/" -type d -empty -prune -exec rmdir --ignore-fail-on-non-empty {} \; I get this error? Ā . find: `cd': No such file or directory Moving all done. Ā Quote Link to comment
kizer Posted March 15, 2018 Share Posted March 15, 2018 how about this. Ā # Prune empty directories from source dir find "/mnt/user/downloads/Complete/*" -type d -empty -prune -exec rmdir --ignore-fail-on-non-empty {} \; # Prune empty directories from destination dir find "/mnt/user/downloads/Import/*" -type d -empty -prune -exec rmdir --ignore-fail-on-non-empty {} \; Ā Ā Quote Link to comment
hmgnsd Posted March 15, 2018 Share Posted March 15, 2018 2 minutes ago, kizer said: how about this. Ā # Prune empty directories from source dir find "/mnt/user/downloads/Complete/*" -type d -empty -prune -exec rmdir --ignore-fail-on-non-empty {} \; # Prune empty directories from destination dir find "/mnt/user/downloads/Import/*" -type d -empty -prune -exec rmdir --ignore-fail-on-non-empty {} \; Ā Ā hmm, still moves but throws up Ā . find: `/mnt/user/downloads/Complete/*': No such file or directory /tmp/user.scripts/tmpScripts/Move Completed Downloads/script: line 17: -empty: command not found find: `/mnt/user/downloads/Import/*': No such file or directory /tmp/user.scripts/tmpScripts/Move Completed Downloads/script: line 21: -prune: command not found Moving all done. Ā Quote Link to comment
kizer Posted March 15, 2018 Share Posted March 15, 2018 Ok I'm trying to figure out exactly what your trying to do.Ā Ā On my machine anything that is in this folder gets moved to this folder. mv /mnt/cache/uploads/* /mnt/user/Movies/All/ Ā You have a bunch of code for pruning and other things and I'm kinda lost of what exactly your attempting to do.Ā Quote Link to comment
hmgnsd Posted March 15, 2018 Share Posted March 15, 2018 1 minute ago, kizer said: Ok I'm trying to figure out exactly what your trying to do.Ā Ā On my machine anything that is in this folder gets moved to this folder. mv /mnt/cache/uploads/* /mnt/user/Movies/All/ Ā You have a bunch of code for pruning and other things and I'm kinda lost of what exactly your attempting to do.Ā Ā Ah, not my code. Copied from another thread where someone adapted the unRAID mover script. What I'd like is for everything to be moved from /mnt/user/downloads/Complete to /mnt/user/downloads/Import without the /Complete/ directory being removed. Ā I'm really appreciating the replies Quote Link to comment
trurl Posted March 15, 2018 Share Posted March 15, 2018 15 minutes ago, hmgnsd said: hmm, still moves but throws up Ā . find: `/mnt/user/downloads/Complete/*': No such file or directory /tmp/user.scripts/tmpScripts/Move Completed Downloads/script: line 17: -empty: command not found find: `/mnt/user/downloads/Import/*': No such file or directory /tmp/user.scripts/tmpScripts/Move Completed Downloads/script: line 21: -prune: command not found Moving all done. Ā Could you post the exact script that produced this output? I am wondering if you haven't tried but failed to type the script that kizer gave. Quote Link to comment
hmgnsd Posted March 15, 2018 Share Posted March 15, 2018 25 minutes ago, trurl said: Could you post the exact script that produced this output? I am wondering if you haven't tried but failed to type the script that kizer gave. Ā sure Ā #!/bin/bash if [ -f /var/run/mymover.pid ]; then if ps h `cat /var/run/mymover.pid` | grep mymover.sh ; then echo "mymover already running, sorry." exit 0 fi fi echo $$ >/var/run/mymover.pid echo "Moving files from $1 to $2" (cd "/mnt/user/downloads/Complete/"; find -depth -print \( ! -exec fuser -s '{}' \; -exec rsync -i -qdIWRpEAXogt --numeric-ids --inplace --remove-source-files {} "/mnt/user/downloads/Import/" \; \)) # Prune empty directories from source dir find "/mnt/user/downloads/Complete/*" -type d -empty -prune -exec rmdir --ignore-fail-on-non-empty {} \; # Prune empty directories from destination dir find "/mnt/user/downloads/Import/*" -type d -empty -prune -exec rmdir --ignore-fail-on-non-empty {} \; sync rm /var/run/mymover.pid echo "Moving all done." Ā Quote Link to comment
DZMM Posted March 21, 2018 Share Posted March 21, 2018 Can I make a feature request please.Ā Can the scripts be sorted by the name give under 'Edit Name' rather than the original script name please.Ā Ā I've changed the names of manyĀ of my scripts from what they were originally created as e.g. my script 'fuse rclone install and mount' was originally called 'rclone_install_and_mount' and hence is stored atĀ boot/config/plugins/user.scripts/scripts/rclone_install_and_mount, which is controlling the sort.Ā Ā Ideally I'd want to be able to change the names of my scripts to add prefixes e.g. 'PLEXDRIVE:Ā fuse rclone install and mount' & 'PLEXDRIVE: rclone_upload_plexdrive' - so that they are grouped together but it won't work unless I go and change the actual script filename. Quote Link to comment
itimpi Posted March 28, 2018 Share Posted March 28, 2018 I have a feature request as well. Ā I am looking at an easy wayĀ to have a script available both via the plugin and from the command line. Ā One way I though of achieving this would be to set up a symbolic link under /usr/local/bin that pointed to the script file on the flash. Ā Ā I could do this myself in the current implementationĀ by running the appropriate commands on each boot of the system, but it would be neater if the plugin did this on my behalf. Ā I cannot think of any obvious downsides (but I may have missed something). Ā Another option might be to allow the plugin to point to an external script file on the flash, but this seems more of an effort to implement and provide no obvious benefits over the approach outlined above. Quote Link to comment
bonienl Posted March 28, 2018 Share Posted March 28, 2018 2 hours ago, itimpi said: One way I though of achieving this would be to set up a symbolic link under /usr/local/bin that pointed to the script file on the flash Ā This directory is used by other internal scripts as well. The only risk I see with your approach is a naming conflict, if something is accidentallyĀ called the same as one of the internal scripts. Quote Link to comment
BRiT Posted March 28, 2018 Share Posted March 28, 2018 I wouldnt symlink things, I'd merely expand the Path setting inside the bashrc/profile to include the user scripts, but make sure its added last so they wont have naming conflicts. 1 Quote Link to comment
Squid Posted March 28, 2018 Author Share Posted March 28, 2018 3 hours ago, itimpi said: Another option might be to allow the plugin to point to an external script file on the flash This actually has been on the todo list for quite awhile, but it introduces a complication because by design to make life easier for the end-user, all scripts are not executed in place, but rather from /tmp after having their line endings normalized for linux.Ā Because of that, any scripts already existing that may have other dependencies within their own directory may or may not work properly. Ā Plus, you can simply make a script to cd and then execute the required script anyways. Quote Link to comment
itimpi Posted March 28, 2018 Share Posted March 28, 2018 39 minutes ago, BRiT said: I wouldnt symlink things, I'd merely expand the Path setting inside the bashrc/profile to include the user scripts, but make sure its added last so they wont have naming conflicts. I thought of that, but each script is in its own folder which makes that approach a bit unwieldy 1 Quote Link to comment
Maticks Posted March 29, 2018 Share Posted March 29, 2018 Anyone know how to fix this error in the script.. delete_dangling_images broken Script location:Ā /tmp/user.scripts/tmpScripts/delete_dangling_images/scriptNote that closing this window will abort the execution of this script"docker rmi" requires at least 1 argument.See 'docker rmi --help'.Usage: docker rmi [OPTIONS] IMAGE [IMAGE...] [flags]Remove one or more imagesFinishedif an error shows above, no dangling images were found to delete Quote Link to comment
Squid Posted March 29, 2018 Author Share Posted March 29, 2018 Anyone know how to fix this error in the script.. [emoji20]delete_dangling_images brokenScript location:Ā /tmp/user.scripts/tmpScripts/delete_dangling_images/scriptNote that closing this window will abort the execution of this script"docker rmi" requires at least 1 argument.See 'docker rmi --help'.Usage: docker rmi [OPTIONS] IMAGE [iMAGE...] [flags]Remove one or more imagesFinishedif an error shows above, no dangling images were found to deleteWhat error? The script states that if an error appears no dangling images were found. 1 Quote Link to comment
cockroach Posted March 29, 2018 Share Posted March 29, 2018 (edited) Removed Edited March 29, 2018 by cockroach 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.