Skip to content

Instantly share code, notes, and snippets.

@kevinsmith
Created September 21, 2010 19:11
Show Gist options
  • Save kevinsmith/590318 to your computer and use it in GitHub Desktop.
Save kevinsmith/590318 to your computer and use it in GitHub Desktop.

Revisions

  1. kevinsmith revised this gist Sep 23, 2010. 1 changed file with 19 additions and 6 deletions.
    25 changes: 19 additions & 6 deletions deploy_ee2.sh
    Original file line number Diff line number Diff line change
    @@ -17,6 +17,17 @@ suphp=TRUE

    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.
    #
    #
    @@ -37,8 +48,10 @@ pwd
    echo
    echo "Clearing the cache."

    find $sysdir/codeigniter/system/cache/* -type d -print0 | xargs /bin/rm -rf
    find $sysdir/expressionengine/cache/* -type d -print0 | xargs /bin/rm -rf
    for cache_path in ${cache_dirs[@]}
    do
    find ${cache_path}/* -type d -print0 | xargs /bin/rm -rf
    done

    if [ $suphp = TRUE ]; then
    echo
    @@ -53,10 +66,10 @@ else
    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 \
    ${sysdir}/codeigniter/system/cache \
    ${sysdir}/codeigniter/system/logs \
    ${sysdir}/expressionengine/cache \
    ${sysdir}/expressionengine/config \
    )

    for path in ${folders[@]}
  2. kevinsmith created this gist Sep 21, 2010.
    78 changes: 78 additions & 0 deletions deploy_ee2.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,78 @@
    #!/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

    # 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."

    find $sysdir/codeigniter/system/cache/* -type d -print0 | xargs /bin/rm -rf
    find $sysdir/expressionengine/cache/* -type d -print0 | xargs /bin/rm -rf

    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."