Created
October 4, 2012 00:30
-
-
Save dcsg/3830786 to your computer and use it in GitHub Desktop.
Shell script to add the correct write permissions for Symfony2 Cache and Logs app directories
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 | |
# | |
# author: Daniel Gomes <me@danielcsgomes.com> | |
# twitter: @danielcgomes | |
# License: MIT | |
# Change the value of the $apacheuser to match your apache user | |
# This command must be run on the root of your Symfony2 project | |
# You should Symlink it to your /usr/bi | |
# | |
APACHE_USER="add_apache_user" | |
CURRENT_DIR="${PWD}" | |
CACHE_DIR="app/cache" | |
LOGS_DIR="app/logs" | |
APP_DIR="app" | |
if [ -d "$APP_DIR" ] ; then | |
echo "Will remove all files under $CACHE_DIR & $LOGS_DIR in $CURRENT_DIR, are you sure?" | |
echo "(yes/no)" | |
read input_variabled | |
if [ "$input_variabled" == "yes" ]; then | |
if [ ! -d "$CACHE_DIR" ] ; then | |
echo "Creating $CACHE_DIR directory." | |
mkdir "$CACHE_DIR" | |
else | |
echo "Removing all files under $CACHE_DIR" | |
rm -rf "$CACHE_DIR/*" | |
fi | |
if [ ! -d "$LOGS_DIR" ] ; then | |
echo "Creating $LOGS_DIR directory." | |
mkdir "LOGS_DIR" | |
else | |
echo "Removing all files under $LOGS_DIR" | |
rm -rf "$LOGS_DIR/*" | |
fi | |
echo "Adding the right permissions to $CACHE_DIR and $LOGS_DIR" | |
sudo chmod +a "$APACHE_USER allow delete,write,append,file_inherit,directory_inherit" $CACHE_DIR $LOGS_DIR | |
sudo chmod +a "`whoami` allow delete,write,append,file_inherit,directory_inherit" $CACHE_DIR $LOGS_DIR | |
else | |
exit; | |
fi | |
else | |
echo "The directory does not exist." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment