Created
February 22, 2015 03:02
-
-
Save karschsp/0832819dd3c37a3de648 to your computer and use it in GitHub Desktop.
fix perms
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 | |
# | |
# From anywhere within a Drupal site, | |
# this will set the correct permissions | |
# to keep Drupal happy. | |
# | |
CURRENT_USER=`who am i | awk '{print $1}'` | |
USER=${1:-$CURRENT_USER} | |
dir=`drush status --fields=root |cut -f2 -d: |sed s/\ //g` | |
if [ -d "$dir" ]; then | |
echo "Drupal root is $dir" | |
echo "Fixing permisisons and setting owner to ${USER}. Standby..." | |
cd $dir | |
chown -R ${USER}.www-data . | |
find -type f -exec chmod 644 {} \; | |
find -type d -exec chmod 755 {} \; | |
if [ -d "$dir/sites/default/files" ]; then | |
cd sites/default/files/ | |
find -type f -exec chmod 664 {} \; | |
find -type d -exec chmod 775 {} \; | |
cd .. | |
chmod 640 settings*php | |
fi | |
echo "All Done. Happy Coding" | |
else | |
echo "Sorry, can't find your Drupal root." | |
exit 1; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment