Created
March 13, 2014 11:05
-
-
Save sumpygump/9526413 to your computer and use it in GitHub Desktop.
Script to update the cache and logs directory with correct permissions for a Symfony project. Adapted from http://symfony.com/doc/current/book/installation.html
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 | |
# This script will update the cache and logs dirs to be owned by apache user | |
rm -rfv app/cache/* | |
rm -rfv app/logs/* | |
APACHEUSER=`ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data' | grep -v root | head -1 | cut -d\ -f1` | |
echo Apache user is $APACHEUSER | |
chmod +a allow 2> /dev/null | |
if [ $? -eq 1 ]; then | |
# System doesn't support chmod +a | |
echo setfacl -R -m u:"$APACHEUSER":rwX -m u:`whoami`:rwX app/cache app/logs | |
setfacl -R -m u:"$APACHEUSER":rwX -m u:`whoami`:rwX app/cache app/logs | |
echo setfacl -dR -m u:"$APACHEUSER":rwX -m u:`whoami`:rwX app/cache app/logs | |
setfacl -dR -m u:"$APACHEUSER":rwX -m u:`whoami`:rwX app/cache app/logs | |
else | |
# System supports chmod +a | |
PERMS=delete,write,append,file_inherit,directory_inherit | |
echo chmod +a "$APACHEUSER allow $PERMS" app/cache app/logs | |
chmod +a "$APACHEUSER allow $PERMS" app/cache app/logs | |
echo chmod +a "`whoami` allow $PERMS" app/cache app/logs | |
chmod +a "`whoami` allow $PERMS" app/cache app/logs | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment