File: scripts/

Recommend this page to a friend!
  Classes of Brett Dutton  >  JackBooted PHP Framework  >  scripts/  >  Download  
File: scripts/
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: 4 years ago
Size: 5,422 bytes



Class file image Download
PHP=`which php`

#Check if we need to install mcrypt
MCRYPT=`$PHP -i | grep mcrypt`
PHPVER=`$PHP -version`
if [ "$MCRYPT" == "" ]; then
    echo "$(date) $0 ******************** Cannot Continue ***********************"
    echo "$(date) $0 Checked PHP and it looks like mcrypt has not been installed"
    echo "$(date) $0 mcrypt is not needed for the application, but it will make system less secure"
    echo "$(date) $0 Installing mcrypt is really hard to do with scripts, so I need you to do it manually, or comment out this code"
    echo "$(date) $0 Please check they have step by step guides for installation of mcrypt"
    echo "$(date) $0 use the search string to find your version of OSX and PHP"
    echo "$(date) $0 Your PHP Version is: $PHPVER"
    echo "$(date) $0 Useful URLs:"
    echo "$(date) $0"
    echo "$(date) $0"
    echo "$(date) $0"
    echo "$(date) $0 ************************************************************"
    exit 1

#**************************** Do you need beanstalkd? **************
# If you need to check the command line for beanstalk then you can install this
#**************************** Uncomment below if you do? **************
#echo "$(date) $0 Checking if we need to install beanstalk for queueing"
#if [ -e /usr/local/bin/beanstalkd ]; then
#    echo "$(date) $0 Beanstalk already installed"
#    echo "$(date) $0 Checking if we need to install brew for package management"
#    if [ -e /usr/local/bin/brew ]; then
#        echo "$(date) $0 Brew is already installed"
#    else
#        echo "$(date) $0 Installing Brew"
#        ruby -e "$(curl -fsSL"
#        echo "$(date) $0 Installing Brew... All done"
#    fi
#    echo "$(date) $0 Installing beanstalk"
#    brew install beanstalkd
#    echo "$(date) $0 Installing beanstalk... done. Now setting up so that will auto start"
#    sudo cp /usr/local/opt/beanstalk/homebrew.mxcl.beanstalk.plist /Library/LaunchDaemons
#    sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.beanstalk.plist

echo "$(date) $0 Setting up log file: $LOG_FILE"
if [ -e $LOG_FILE ]; then
    echo "$(date) $0 Log file: $LOG_FILE already exists"
    sudo touch $LOG_FILE
    sudo chmod 666 $LOG_FILE

if [ -e $ROTATE_CONF ]; then
    echo "$(date) $0 Rotation conf ($ROTATE_CONF) already set up"
    sudo touch $ROTATE_CONF
    sudo chmod g+w $ROTATE_CONF
    sudo chmod a+w $ROTATE_CONF
    echo "$LOG_FILE                       666  5     2500 *     J" >> $ROTATE_CONF

echo "$(date) $0 Checking Source code installation"
if [ -e $INSTALL_DIR ]; then
    echo "$(date) $0 Source code installed, just updating the codebase"
    sudo ./scripts/
    echo "$(date) $0 First Time checkout of code"
    sudo git clone $INSTALL_DIR
    sudo chown -R _www:_www $INSTALL_DIR
    sudo $PHP ./jack.php DB:initialize
    sudo $PHP ./jack.php DB:migrate
    sudo chmod -R a+w _private
    sudo chmod -R g+w _private
    NEWVERSION=`$PHP ./jack.php JACK:version`
    echo "$(date) $0 Updated code base and migrated database to $NEWVERSION"

echo "$(date) $0 Setting up crontab"
sudo crontab -l > /tmp/tcrontab
cat ./scripts/crontab.txt | sed 's|INSTALLDIR|'$INSTALL_DIR'|g' >> /tmp/tcrontab
sudo crontab /tmp/tcrontab
rm /tmp/tcrontab
echo "$(date) $0 Crontab deployed"

echo "$(date) $0 Checking httpd.conf to ensure that the docroot set correctly and modules loaded"
DOCROOT=`grep $INSTALL_DIR /etc/apache2/httpd.conf`
if [ "$DOCROOT" == "" ]; then
    read -r -d '' NEWCONF << EOT

LoadModule php5_module libexec/apache2/
LoadModule rewrite_module libexec/apache2/
DocumentRoot "$INSTALL_DIR"
<Directory "$INSTALL_DIR">
    Options FollowSymLinks Multiviews
    MultiviewsMatch Any
    AllowOverride All
    Require all granted


    echo "$(date) $0 Updating httpd.conf to ensure that the docroot"
    touch /tmp/httpd.conf
    while read -r line; do
        if [ "$line" = 'DocumentRoot "/Library/WebServer/Documents"' ]; then
            echo "$NEWCONF" >> /tmp/httpd.conf
            echo "$line" >> /tmp/httpd.conf
    done < /etc/apache2/httpd.conf

    echo "$(date) $0 Restarting Apache"
    sudo apachectl stop
    sudo mv /etc/apache2/httpd.conf "/etc/apache2/httpd.conf.$(date).backup"
    sudo mv /tmp/httpd.conf /etc/apache2/httpd.conf
    sudo apachectl start
    echo "$(date) $0 httpd.conf seems to have correct DocumentRoot go to http://localhost"
    echo "$(date) $0 If you still have errors, please check this script for configuration hints"

echo "$(date) $0 go to http://localhost username/password:"

For more information send a message to info at phpclasses dot org.