ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Shell script to automate PB version updates ...

December 12, 2009 6:28pm

Subscribe [2]
  • #1 / Dec 12, 2009 6:28pm

    eduqate

    53 posts

    I expect (hope!) PB updates will be quite frequent for a little while. To take the tedium out of this I wrote the following quick and dirty shell script which follows the steps in the user guide as of 091211. Developed on a Mac, it should also work on Unices/Linux. Windows users have my sympathy though doing something similar in Powershell would be no big deal.

    Caveat emptor, if you’re not capable of reading through and fixing it up for your environment then leave well alone and stick to the update instructions in the PB user guide.

    I just used it to update to 091211 and it seemed to work fine.

    Basic operation is to backup some directories from the current system, unpack the new version into a temp directory, install the new files, reinstate the old backed up files, clean the cache and tidy up.

    I note at the end that the themes may need fixing up by hand, as I don’t have any yet sorting this out is of no importance to me.

    Hope someone finds this of use.

    #!/bin/sh
    
    oops() {
      echo "$1"
      exit 1
    }
    
    # Fix these for your own environment
    D=/Users/xxx/Sites/
    N=test-site
    SD=system/expressionengine
    # New name for system
    NS=metsys
    ND=$NS/expressionengine
    
    # The new version
    S=/Volumes/Data/web/ee
    R=ExpressionEngine2.0.0_FL_PB1
    
    # End of customization
    
    F=$S/$R.zip
    
    # Anything to do?
    test -f $F || oops "Can't find $F"
    
    # All 3 directories must exist
    test -d $D/$N/$NS || oops "Can't find $D/$N/$NS"
     
    cd $D
    BKD=eebk`date +'%y%m%d%H%M'`
    echo '***' backing up to ${BKD}
    
    mkdir ${BKD} || oops "Can't create ${BKD}"
    mv \
    $N/$ND/config $N/$ND/templates $N/$ND/third_party $N/themes \
    ${BKD}
    
    # Get the new files
    echo '***' unzipping
    rm -rf t/$R
    unzip -q -d t $F
    echo '***' cleaning up installer
    # Just in case there are new files we leave the new directories and overwrite
    # with our backed up files
    rm -r t/$R/$SD/installer \
    #t/$R/system/config /$R/system/templates t/$R/system/third_party
    
    echo '***' installing new system dir
    rm -rf $N/${NS}-old
    mv $N/${NS} $N/${NS}-old
    mv t/$R/system $N/${NS}
    mv t/$R/themes $N
    
    echo '***' Reinstating old system dirs excluding themes
    #mv ${BKD}/* $N/$ND
    cp -R \
    ${BKD}/config ${BKD}/templates ${BKD}/third_party \
    $N/$ND
    #rmdir -rf ${BKD}
    
    echo '***' Fixing Permissions
    
    chmod 777 $N/$ND/cache
    chmod 666 $N/$ND/config/config.php $N/$ND/config/database.php
    
    echo '***' Cleaning cache and temp dir
    # Delete any folder
    find $N/$ND/cache -depth 1 -type d | xargs rm -rf
    rm -rf t
    
    echo Finished, be sure to reinstate any custom themes from ${BKD}/themes
    
    exit 0

    [Mod Edit: Moved to the How to forum]

  • #2 / Dec 13, 2009 6:37am

    eduqate

    53 posts

    I have cleaned up this script a little by improving the error handling and sequence of events. I will refrain from posting it until I have had a chance to test. The above worked for me but please read carefully before using it for yourself.

  • #3 / Dec 14, 2009 5:30pm

    Ingmar

    29245 posts

    Looks nice, thanks for sharing. Giving this a try later on.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases