Skip to content

Instantly share code, notes, and snippets.

@kevinsmith
Created September 21, 2010 19:11
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinsmith/590318 to your computer and use it in GitHub Desktop.
Save kevinsmith/590318 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Copyright (c) 2010 hearSAY, LLC @ http://gohearsay.com
# Author: Kevin Smith
#
# This script is meant to be installed in the web root directory
# and run immediately after an EE2 deployment. As long as it's
# installed in the web root, it can be executed from any working
# directory.
# VERY IMPORTANT: If you are running under a suPHP environment
# (like most shared servers), you need to change the 'suphp'
# value below to TRUE. Otherwise, leave it as is.
suphp=TRUE
# Change this value to the custom system folder name you're using with EE2.
sysdir=system
# List the cache directories here that you want cleared when this script
# is run. This will only clear the contents, not the directories themselves.
# No trailing slash!
cache_dirs=( \
${sysdir}/codeigniter/system/cache \
${sysdir}/expressionengine/cache \
assets/css/cache \
assets/js/cache \
)
# END OF USER CONFIGS. DO NOT EDIT PAST THIS LINE.
#
#
#
#
#
#
# Find the absolute path to this script, (e.g. /home/user/bin/foo.sh)
SCRIPT=`readlink -f $0`
# Find absolute path to directory where script is located (e.g. /home/user/bin)
SCRIPTPATH=`dirname $SCRIPT`
cd $SCRIPTPATH
echo "Now in working directory:"
pwd
echo
echo "Clearing the cache."
for cache_path in ${cache_dirs[@]}
do
find ${cache_path}/* -type d -print0 | xargs /bin/rm -rf
done
if [ $suphp = TRUE ]; then
echo
echo "Looks like this server is running a suPHP environment, so..."
echo "Giving all directories 0755 permissions as required by suPHP."
find . -type d -print0 | xargs -0 chmod -c 0755
echo "Giving all files (except .pl, .cgi, and .sh) 0644 permissions as required by suPHP."
find . -type f -not -name "*.pl" -not -name "*.cgi" -not -name "*.sh" -print0 | xargs -0 chmod -c 0644
else
echo
echo "Verifying and giving correct permissions to necessarily writable directories (cache, logs, config)."
folders=( \
${sysdir}/codeigniter/system/cache \
${sysdir}/codeigniter/system/logs \
${sysdir}/expressionengine/cache \
${sysdir}/expressionengine/config \
)
for path in ${folders[@]}
do
mkdir -pv ${path}
chmod -c 777 ${path}
done
fi
# We'll remove the .gitignore file since it's held in the
# repository (and therefore deployed), but the production
# server won't be a git repo.
echo
rm -vf .gitignore
echo
echo "Don't forget to upload the contents of the ${SCRIPTPATH}/assets directory if there are updates!"
echo
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment