#!/bin/bash

#
# @file .openshift/action_hooks/deploy
#
# Copyright (c) 2014 Simon Fraser University Library
# Copyright (c) 2010-2014 John Willinsky
# Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
#
# Deployment script for openshift to work around DOCUMENT_ROOT detection,
# which will otherwise choose "public".
#

echo 'Running deploy hook'
 
# Creating symlink to work around openshift's DOCUMENT_ROOT detection
cd $OPENSHIFT_REPO_DIR
ln -s ./ php
 
# Copy the configuration file from the data directory
CONFIG_FILE="$OPENSHIFT_DATA_DIR/config.inc.php"
if [ ! -f $CONFIG_FILE ]
then
	cp $OPENSHIFT_REPO_DIR/config.TEMPLATE.inc.php $CONFIG_FILE
fi
cp $CONFIG_FILE $OPENSHIFT_REPO_DIR
 
# Replace the default .gitmodules with a custom one
GITMODULES="$OPENSHIFT_DATA_DIR/.gitmodules"
if [ -f $GITMODULES ]
then
	cp $GITMODULES $OPENSHIFT_REPO_DIR
fi
