Engine23
blogBannerImage
By Engine23

GIT code push

#!/bin/bash

NOW=$(date +"%Y%m%d%H%M%S")

NEW_FOLDER_PATH="/var/www/magento/releases/$NOW"

VAR_FOLDER="/var/www/magento/shared/var/"

MEDIA_FOLDER="/var/www/magento/shared/media/"

SHARED_ETC_FOLDER="/var/www/magento/shared/app/etc"

MAGENTO_ROOT="/var/www/magento/"

GROUP="www-data"

REPO="ssh://username@192.168.1.1/~/git/projectname.git --depth 1 "

 

echo "The new clone will be located at $NEW_FOLDER_PATH"

mkdir $NEW_FOLDER_PATH

echo "$NEW_FOLDER_PATH created"

 

echo "Setting group for $NEW_FOLDER_PATH to: $GROUP"

sudo chgrp -R $GROUP "$NEW_FOLDER_PATH/"

 

echo "Clone Repo into $NEW_FOLDER_PATH"

git clone $REPO $NEW_FOLDER_PATH/

 

echo "Creating symbolic links for folders var and media"

ln -s $VAR_FOLDER $NEW_FOLDER_PATH/var

ln -s $MEDIA_FOLDER $NEW_FOLDER_PATH/media

 

echo "Creating symbolic link for app/etc/local.xml"

ln -s $SHARED_ETC_FOLDER/local.xml $NEW_FOLDER_PATH/app/etc/local.xml

 

echo "Creating symbolic link for app/etc/config.xml"

ln -s $SHARED_ETC_FOLDER/config.xml $NEW_FOLDER_PATH/app/etc/config.xml

 

echo "Creating Symlink for site to current release"

ln -sfn $NEW_FOLDER_PATH/ $MAGENTO_ROOT/current

 

echo "Clearing Caches"

rm -rf $VAR_FOLDER/cache/* $VAR_FOLDER/full_page_cache/*

 

echo "Restarting Apache"

sudo apache2ctl graceful