January 9, 201115 yr Hi all, I got quite frustrated when the newperms script didn't work when calling it manually to assign new permissions on a folder that contained spaces so I decided to fix it. I use SABnzbd extensively and a few other apps that create files on the array and they're always being created as root with messed up permissions. I couldn't use the new perms script since anything with a space in it would fail. Well, all is good, here it is.. Quite simple fix really. #!/bin/bash # Usage: newperms [dir] # Recursively changes the ownership and permissions of the directory and all files/subdirs # within the directory. If dir is omitted, then operates on /mnt/cache and /mnt/disk* # This was created to fix ownership/permissions for unRAID version 5.x function process { if [ -e "$1" ] ; then echo "processing $1" echo "... chmod -R go-rwx $1" chmod -R go-rwx "$1" echo "... chmod -R u-x $1" chmod -R u-x "$1" echo "... chmod -R g+u $1" chmod -R g+u "$1" echo "... chmod -R ug+X $1" chmod -R ug+X "$1" echo "... chgrp -R users $1" chgrp -R users "$1" echo "... chown -R nobody $1" chown -R nobody "$1" fi } if [ -n "$1" ] ; then process "$1" else process /mnt/cache for disk in /mnt/disk* ; do process $disk done fi
January 9, 201115 yr Great, thanks! I have sabnzbd set to run a post-processing script to fix the permissions but it isn't always successful. I think it's to do with the sorting when it doesn't work as expected. The script itself is just a one-liner... chown -R nobody.users "$1"
January 9, 201115 yr Author The correct syntax would be chown -R nobody:users "$1" note it's a ":" and not a "." that concatenates the user and the group. Cheers,
January 9, 201115 yr Actually the character between owner and group does not matter if it's ":" or ".". In Slackware distros, such as unRAID the "." works perfectly fine because of backwards compatability. Even though "." is still supported, it is deprecated and considered to be bad form to still use it. Directly from the "chown" invocation info pages Some older scripts may still use `.' in place of the `:' separator. POSIX 1003.1-2001 (*note Standards conformance: does not require support for that, but for backward compatibility GNU `chown' supports `.' so long as no ambiguity results. New scripts should avoid the use of `.' because it is not portable, and because it has undesirable results if the entire OWNER`.'GROUP happens to identify a user whose name contains `.'.
January 10, 201115 yr Author Interesting.. I did not know that, but then again, I've never seen it used that way.
January 10, 201115 yr The correct syntax would be chown -R nobody:users "$1" note it's a ":" and not a "." that concatenates the user and the group. Caveat, I'm new to unRAID so perhaps there are quirks I am unaware of. Not true. Using a '.' works just fine, in fact any character would do the trick to split the two parts. I've been using '.' for 10+ yeats in Unix/Linux. I always use this format to avoid also using chgrp command.
Archived
This topic is now archived and is closed to further replies.