Last active
December 7, 2017 17:02
-
-
Save jdavidbakr/4e2a47fb75eee9a444ff452a8c6cd1a7 to your computer and use it in GitHub Desktop.
Script to repair website permissions
This file contains hidden or 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 | |
LOCK_FILE=/tmp/permission-repair-lock | |
if [ ! -e $LOCK_FILE ]; then | |
trap "rm -f $LOCK_FILE; exit" 0 1 2 3 15 | |
touch $LOCK_FILE | |
for d in /var/www/html/* | |
do | |
cd $d | |
if [ -d releases ]; then | |
nice /bin/find ./ -perm 644 | sed 's/.*/"&"/' | xargs -r chmod 664 | |
nice /bin/find ./ -perm 755 | sed 's/.*/"&"/' | xargs -r chmod 2775 | |
nice /bin/find ./ -perm 2755 | sed 's/.*/"&"/' | xargs -r chmod 2775 | |
nice /bin/find ./ -perm 600 | sed 's/.*/"&"/' | xargs -r chmod 664 | |
nice /bin/find ./ -perm 700 | sed 's/.*/"&"/' | xargs -r chmod 2775 | |
nice /bin/find ./ -perm 2700 | sed 's/.*/"&"/' | xargs -r chmod 2775 | |
nice /bin/find ./ \! -group apache | sed 's/.*/"&"/' | xargs -r chgrp apache | |
sleep 1 | |
fi | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment