Skip to content

Instantly share code, notes, and snippets.

@mrexclamation
Last active September 17, 2016 15:44
Show Gist options
  • Save mrexclamation/9807de2bace1533ffac018665e163f2a to your computer and use it in GitHub Desktop.
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
  1. Save the file as fixsysperms.sh
  2. Set execution permission: $ chmod +x fixsymperms.sh
  3. If you want to use it globally: $ sudo cp fixsymperms.sh /usr/local/bin/fixsymperms
#!/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