dietpi-sync - run more often/continously? Topic is solved

Have some feedback, questions, suggestions, or just fancy a chat? Pop it in here.
hoverdonkey
Posts: 22
Joined: Sun Jul 12, 2020 2:32 pm

Re: dietpi-sync - run more often/continously?

Post by hoverdonkey »

I have just cracked it! But first let me respond to your last post:

Joulinar wrote: Wed Mar 17, 2021 11:03 pm question is if write permission for other would be enough to be able to access files on the NAS. Means to use 666 instead of 777
I just tried changing some files to 666 - with these permissions I cannot delete the files using Windows File Explorer.

Joulinar wrote: Wed Mar 17, 2021 11:03 pm There is an old request on qbit github to add a feature to be able to change permission :)
https://github.com/qbittorrent/qBittorrent/issues/8016
Nice to know that I'm not the only one! It would have been easier if this suggestion had been implemented, however it has forced me to learn more Linux - indeed I have now written my first ever script because of this! Thank you again for supporting me on the journey, I very much appreciate it.


So, my solution (after a LOT of Googliing and trial & error!):

I created file /home/qbittorrent/copyandperms.bash (I used this path as I saw it used in an example for another script I found, but maybe there is a better place for it). It took me a few trials to remember that it is neccesssary to make the file executable for it to work...

The contents of copyandperms.bash:

Code: Select all

#!/bin/bash
"%F"=$1
cp -r "$1" "/mnt/NFS_path/torrentdloads"
chmod 777 -R "/mnt/NFS_path/torrentdloads"
fi
I am not sure why the "%F"=$1 line is required, but the script does not work without it (i.e. just putting "%F" in the cp line does not work).

Finally, in the "Run external program on torrent completion" box in Qbittorrent I put: "/home/qbittorrent/copyandperms.bash" "%F"


That's it!

As summary of what this achieves (for the benefit of those reading this post having skipped the pages since my first post!):

1 - Copies Qbittorrent downloads on completion, from my DietPi box to my NAS (leaving the original download for Qbittorrent to continue seeding whilst allowing me to do what I like with the copies).
2 - Changes folder & file permissions of the copied items (so that they can be easily moved to wherever they are needed e.g. using Windows File Explorer. Without this step permissions must be changed manually every time).
Last edited by hoverdonkey on Thu Mar 18, 2021 12:31 pm, edited 2 times in total.
User avatar
Joulinar
Posts: 5115
Joined: Sat Nov 16, 2019 12:49 am

Re: dietpi-sync - run more often/continously?

Post by Joulinar »

yep that would be the alternative to have it running on an external script

But changing always permission on the entire NFS share might to much. Probably it would be ok to just change it on the folder you moved (just an idea).

Code: Select all

chmod 777 -R "/mnt/NFS_path/$1"
Not sure if this is working :P
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
hoverdonkey
Posts: 22
Joined: Sun Jul 12, 2020 2:32 pm

Re: dietpi-sync - run more often/continously?

Post by hoverdonkey »

Joulinar wrote: Thu Mar 18, 2021 12:11 pm yep that would be the alternative to have it running on an external script

But changing always permission on the entire NFS share might to much. Probably it would be ok to just change it on the folder you moved (just an idea).

Code: Select all

chmod 777 -R "/mnt/NFS_path/$1"
Not sure if this is working :P
Good spot - I don't actually change whole share, I just showed a simplified the path in my explanation. Good point though, maybe I simplified it too far, I will edit it it for the benefit of the next noob who stumbles through here!

EDIT: I just tried your $1 idea - it didn't work. I then tried %F instead - that didn't work either. So I'm sticking with changing the whole destination folder every time (since it's not very big): chmod 777 -R "/mnt/NFS_path/torrentdloads"
Post Reply