perfessor101 Posted December 14, 2019 Share Posted December 14, 2019 Hello, Recently iTunes has started deleting my podcasts in a rather random way ... might be filename related. iTunes will download free content, then randomly delete certain files ... it always seems to end up deleting the same ones and keeping the same others. I started tracking changes in my iTunes share Via inotifywait and hoped if I did a chmod a-w on newly downloaded files after a CLOSE event I could stop iTunes from deleting them. The share is secure setting security with the iTunes user having read/write permissions. Fewer files are getting deleted, but the permissions change hasn’t stopped them disappearing. How do I stop iTunes from deleting files in this share after the writable permission has been cleared? thanks for your time, Bobby Quote Link to comment
BRiT Posted December 14, 2019 Share Posted December 14, 2019 I do the following for files I want to be protected against all forms of modifcation (make it read-only for everyone, make it owned by user root and group root, and make it immutable to change). The change-attribute command does not work through fuse ie: /mnt/user/ or /mnt/user0/ . chmod 444 /mnt/disk#/share/dir/subdir/filename chown root.root /mnt/disk#/share/dir/subdir/filename chattr +i /mnt/disk#/share/dir/subdir/filename To make it able to be changed again: chattr -i /mnt/disk#/share/dir/subdir/filename Quote Link to comment
perfessor101 Posted December 15, 2019 Author Share Posted December 15, 2019 (edited) Thank you for your help just discovered shellcheck.net the other day ... helps me greatly. I’ll give it a try yes I was changing the permissions on the fuse file system, my mistake. Can I do this to files on the cache drive? And then will the mover still be able to move the files? if not I’ll change it so the share is set to skip the cache drive. Edited December 18, 2019 by perfessor101 Quote Link to comment
perfessor101 Posted December 18, 2019 Author Share Posted December 18, 2019 I've got this far ... this command gives me the format and data I want in a form I can hopefully pass on to the permissions part ... using '?' as a separator as the filenames have spaces and it looked like one of the only characters not used in filenames. inotifywait -e close -mr --format '%T?%e?/mnt/disk5/music/iTunes/iTunes Media/%w?%f?' --timefmt '%D-%T' 'Podcasts/' | grep -v 'ISDIR' when I try expanding it to this ... it doesn't work and I'm not sure how to track down where its broken ... inotifywait -e close -mr --format '%T?%e?/mnt/disk5/music/iTunes/iTunes Media/%w?%f?' --timefmt '%D-%T' 'Podcasts/' | grep -v 'ISDIR' | while IFS='?' read -r datetime action mypath file1; do echo " Date: "$datetime echo "Action: "$action echo " Path: "$mypath echo " File1: "$file1 echo "cd "$mypath cd $mypath echo "chmod -c a-w "$file1 chmod -c a-w $file1 printf '\n' done Thanks for your time and help, Bobby Quote Link to comment
perfessor101 Posted December 19, 2019 Author Share Posted December 19, 2019 (edited) okay flipping some things around after much googling ... this appears to work I should just ask on fiver for these scripts ... now to try to get it to do something with the files ... #!/bin/bash cd /mnt/disk5/music/iTunes/ cd iTunes\ Media/ pwd echo " $(date) " while IFS='?' read -r datetime action mypath file1; do if [[ "$(echo "$action" | tr '[:upper:]' '[:lower:]')" != *"isdir"* ]] ; then if [[ "$(echo "$file1" | tr '[:upper:]' '[:lower:]')" != *"download.mp3"* ]] ; then echo " Date: '$datetime'" echo "Action: '$action'" echo " Path: '$mypath'" echo " File1: '$file1'" printf '\n' fi fi done < <(exec inotifywait -e close -mr --format '%T?%e?/mnt/disk5/music/iTunes/iTunes Media/%w?%f?' --timefmt '%D-%T' 'Podcasts/') Edited December 19, 2019 by perfessor101 full script so far 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.