Created
February 7, 2015 03:55
-
-
Save pichuang/ebb0d9d412185d064469 to your computer and use it in GitHub Desktop.
Easy Change WWW Permission
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 | |
USER="http" | |
GROUP="http" | |
DIR_PERMISSION="750" | |
FILE_PERMISSION="640" | |
DIRPATH="$1" | |
if [ $# == 0 ]; then | |
echo "Usage: changePerm.sh DIR" | |
elif [ -d $DIRPATH ]; then | |
echo "Processing owner" | |
find $DIRPATH \! \( -user $USER -and -group $GROUP \) -exec chown $USER\:$GROUP '{}' + | |
echo "Processing permission" | |
find $DIRPATH -type d \! \( -perm $DIR_PERMISSION \) -exec chmod $DIR_PERMISSION '{}' + | |
find $DIRPATH -type f \! \( -perm $FILE_PERMISSION \) -exec chmod $FILE_PERMISSION '{}' + | |
else | |
echo "You need a dir" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment