- Save the file as fixsysperms.sh
- Set execution permission: $ chmod +x fixsymperms.sh
- If you want to use it globally: $ sudo cp fixsymperms.sh /usr/local/bin/fixsymperms
Last active
September 17, 2016 15:44
-
-
Save mrexclamation/9807de2bace1533ffac018665e163f2a to your computer and use it in GitHub Desktop.
Symfony3 Setting up or Fixing File Permissions Using ACL on a System that Supports setfacl BASH SCRIPT
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 [ -d "var" ]; then | |
rm -rf var/cache/* | |
rm -rf var/logs/* | |
HTTPDUSER=`ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1` | |
# if this doesn't work, try adding `-n` option | |
sudo setfacl -R -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX var | |
sudo setfacl -dR -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX var | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment