PHP Classes
elePHPant
Icontem

File: scripts/update_codebase.sh

Recommend this page to a friend!
  Classes of Brett Dutton  >  JackBooted PHP Framework  >  scripts/update_codebase.sh  >  Download  
File: scripts/update_codebase.sh
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: JackBooted PHP Framework
Web application framework using simplified MVC
Author: By
Last change:
Date: 3 years ago
Size: 1,033 bytes
 

Contents

Class file image Download
#!/bin/bash
source ./scripts/env.sh
LOCKDIR=/tmp/update_codebase.sh.lock

if ! mkdir $LOCKDIR; then
    echo "Lock failed"
    exit 1
fi

OLDVERSION=`$PHP ./jack.php ODCA:version`
UPDATES=`git pull | grep "Already up-to-date." | wc -l`
if [  $UPDATES -eq 0 ]; then
    $PHP ./jack.php DB:migrate
    /usr/sbin/chown -R _www:_www *
    chmod -R a+w _private
    chmod -R g+w _private

    # Update crontab if necessary
    CWD=`pwd`
    cat ./scripts/crontab.txt | sed 's|INSTALLDIR|'$CWD'|g' > /tmp/tcrontab_new
    crontab -l > /tmp/tcrontab_old
    DIFF=`diff /tmp/tcrontab_old /tmp/tcrontab_new`
    if [ "$DIFF" != "" ]; then
        echo "$(date) $0 new crontab installed"
        crontab /tmp/tcrontab_new
    fi;
    rm /tmp/tcrontab_new /tmp/tcrontab_old

    NEWVERSION=`$PHP ./jack.php ODCA:version`
    echo "$(date) $0 Updated code base and migrated database"
    echo "$(date) $0 Old Version: $OLDVERSION"
    echo "$(date) $0 New Version: $NEWVERSION"
else
    echo "$(date) $0 No Software Updates"
fi

rmdir $LOCKDIR