Created
September 23, 2015 19:21
-
-
Save jandk/39477b0fe2ab1b5e265f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ "$#" -lt 1 ] | |
then | |
echo "Usage: fix.sh <folder> [folder]...\n" | |
exit 1 | |
fi | |
for d in $@ | |
do | |
echo "Fixing owners, groups and permissions in $d" | |
n=$( \ | |
find $d \ | |
\( -not -user nasbox , -not -group users -exec \ | |
chown -v nasbox:users {} \; \) , \ | |
\( -type d -not -perm 755 -exec \ | |
chmod -v 755 {} \; \) , \ | |
\( -type f -not -perm 644 -exec \ | |
chmod -v 644 {} \; \) \ | |
| tee \ | |
) | |
echo $n | |
n=$(echo $n | wc -l) | |
echo "Fixed $n items." | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment