Skip to content

Instantly share code, notes, and snippets.

@jandk
Created September 23, 2015 19:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jandk/39477b0fe2ab1b5e265f to your computer and use it in GitHub Desktop.
Save jandk/39477b0fe2ab1b5e265f to your computer and use it in GitHub Desktop.
#!/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