Created
May 22, 2014 20:49
-
-
Save uroshekic/36d43fbdeac27628644e to your computer and use it in GitHub Desktop.
Deploying Laravel 4 to Openshift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# http://openshift.github.io/documentation/oo_user_guide.html#the-openshift-directory | |
# Note: On Windows, the execute permissions of an action hook files will be lost during the git push. | |
# To fix this problem, you can run this command: | |
# git update-index --chmod=+x .openshift/action_hooks/* | |
cd $OPENSHIFT_DATA_DIR | |
if [ ! -d "repo" ]; then | |
echo 'Cloning repository...' | |
git clone -b dev https://github.com/dcrystalj/RubiKS.git repo | |
else | |
echo 'Pulling changes...' | |
cd repo | |
git pull | |
cd .. | |
fi | |
cp -rf repo/rubiKS/* $OPENSHIFT_REPO_DIR | |
# Check whether .env.php file exists | |
if [ ! -f "$OPENSHIFT_REPO_DIR/.env.php" ]; then | |
echo '.env.php file MISSING!' | |
fi | |
# Install/update Composer | |
export COMPOSER_HOME="$OPENSHIFT_DATA_DIR/.composer" | |
if [ ! -f "$OPENSHIFT_DATA_DIR/composer.phar" ]; then | |
echo 'Installing Composer...' | |
curl -s https://getcomposer.org/installer | php -- --quiet --install-dir=$OPENSHIFT_DATA_DIR # Options must be appended to -- so that PHP ignores them | |
else | |
echo 'Updating Composer...' | |
php $OPENSHIFT_DATA_DIR/composer.phar --quiet self-update | |
fi | |
cd $OPENSHIFT_REPO_DIR | |
# https://www.openshift.com/blogs/openshift-online-march-2014-release-blog | |
# If php directory exists, it needs to point to laravel's public directory | |
if [ -d "php" ]; then | |
if [ -e "php/composer.json" ]; then | |
echo 'Public directory already symlinked, moving on...' | |
else | |
echo 'Creating symlink for public directory...' | |
rm -rf php | |
ln -s public php | |
fi | |
fi | |
# Load vendor directory from data/ if possible | |
if [ -d "$OPENSHIFT_DATA_DIR/vendor" ]; then | |
echo 'Loading vendor directory from cache...' | |
mv $OPENSHIFT_DATA_DIR/vendor vendor | |
fi | |
# Install/update laravel and dependencies | |
if [ ! -d "$OPENSHIFT_REPO_DIR/vendor" ]; then | |
echo 'Installing Laravel and dependencies...' | |
php $OPENSHIFT_DATA_DIR/composer.phar --quiet install | |
#php $OPENSHIFT_DATA_DIR/composer.phar install | |
else | |
echo 'Laravel dependencies already installed, updating...' | |
php $OPENSHIFT_DATA_DIR/composer.phar --quiet update | |
#php $OPENSHIFT_DATA_DIR/composer.phar update | |
fi | |
# Delete old data/vendor directory if it exists (not necessary, but just to be safe) | |
if [ -d "$OPENSHIFT_DATA_DIR/vendor" ]; then | |
rm -rf $OPENSHIFT_DATA_DIR/vendor | |
fi | |
# Copy new vendor directory to data/ | |
echo 'Saving vendor directory to cache...' | |
cp -rf vendor $OPENSHIFT_DATA_DIR/vendor |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment