Commit 7ffec458 authored by Ernesto Rodriguez Ortiz's avatar Ernesto Rodriguez Ortiz
Browse files

docker: Delete variable, using echo directly to print information

parent ee58f4ea
......@@ -74,10 +74,3 @@ DRUSH_ALIASES=$DRUPAL_ROOT/sites/all/drush
# User that execute the script #
################################
ME=`whoami`
################################
# Echo script location #
################################
ECHO=/bin/echo
......@@ -80,18 +80,20 @@ function display_usage {
# Put the site offline
function site_offline {
$ECHO "Setting $DRUPAL_ENV environment on maintenance mode ..."
echo "Setting $DRUPAL_ENV environment on maintenance mode ..."
drush --yes @$DRUPAL_ENV vset site_offline $MAINTENANCE_MODE
}
# Put the site online
function site_online {
$ECHO "Setting $DRUPAL_ENV environment off maintenance mode ..."
echo "Setting $DRUPAL_ENV environment off maintenance mode ..."
drush --yes @$DRUPAL_ENV vset site_offline $ONLINE_MODE
}
# Install the site using the site-install script to reuse code
function site_install {
echo "site_install"
# start apache
service apache2 start
# start mysql server
......@@ -125,29 +127,31 @@ function site_install_end {
# Param should be a drush valid alias for the current drupal installation
# cf aliases.drushrc.php
function site_deploy {
# Put site on maintenance mode
site_offline
echo "site_deploy"
# Copy env settings
$ECHO "Preparing environment-specific configuration ..."
sudo cp $WORKSPACE/deploy/env/settings.${DRUPAL_ENV}.php $DRUPAL_ROOT/sites/default/
# Put site on maintenance mode
site_offline
$ECHO "Deploying code on $DRUPAL_ENV environment ..."
drush --yes rsync --exclude=sites/default/files --exclude=external --exclude=.htaccess --delete --verbose @self @$DRUPAL_ENV
# Copy env settings
echo "Preparing environment-specific configuration ..."
sudo cp $WORKSPACE/deploy/env/settings.${DRUPAL_ENV}.php $DRUPAL_ROOT/sites/default/
if [ $DRUPAL_ENV != prod ]; then
if [ "${sqlreplace}" == true ]; then
$ECHO "Synchronising SQL database from self to $DRUPAL_ENV"
drush --yes sql-sync --create-db @self @$DRUPAL_ENV
fi
fi
echo "Deploying code on $DRUPAL_ENV environment ..."
drush --yes rsync --exclude=sites/default/files --exclude=external --exclude=.htaccess --delete --verbose @self @$DRUPAL_ENV
if [ $DRUPAL_ENV != prod ]; then
if [ "${sqlreplace}" == true ]; then
echo "Synchronising SQL database from self to $DRUPAL_ENV"
drush --yes sql-sync --create-db @self @$DRUPAL_ENV
fi
fi
# Run any available database update
$ECHO "Running available database update(s) on $DRUPAL_ENV environment ..."
drush --yes @$DRUPAL_ENV updatedb
# Run any available database update
echo "Running available database update(s) on $DRUPAL_ENV environment ..."
drush --yes @$DRUPAL_ENV updatedb
# Put site online
site_online
# Put site online
site_online
}
# Set right permissions to drupal files after installation and tests
......@@ -211,7 +215,8 @@ function run_phpmd {
# Test of Drupal core
function run_tests {
echo "run_tests START"
# Create the directory to saves the results
mkdir -p ${WORKSPACE}/logs/tests
cd $DRUPAL_ROOT
drush en simpletest --yes
......@@ -222,6 +227,7 @@ function run_tests {
# Test scenarios specific to Drupal sites using behat drupalextension
function run_behat {
echo "run_behat START"
mkdir -p ${WORKSPACE}/logs/behat
#Behat tests
#Init for initialise the yml config of behat
......@@ -231,25 +237,23 @@ function run_behat {
# Generate a report of the site using site_audit
function site_audit {
cd $DRUPAL_ROOT
echo "site_audit"
cd $DRUPAL_ROOT
# Full report using site_audit drush module
drush aa --html --bootstrap --detail --skip=insights > $WORKSPACE/output/site_audit.html
}
# Export code and database. This is a test for Pantheon
function build_artefacts {
# Specify the destination folder
TARGET=$WORKSPACE/build
# Specify the source folder
SOURCE=$WORKSPACE/src
# Change directory to the source folder
cd $SOURCE
echo "build_artefacts"
# Change directory to the root drupal folder
cd $DRUPAL_ROOT
# Create an archive that excludes sites/default/files
drush archive-dump --tar-options="--exclude=.git" --destination=$TARGET/sfl_boilerplate-archive.tar.gz --overwrite
drush archive-dump --tar-options="--exclude=.git" --destination=$WORKSPACE/build/sfl_boilerplate-archive.tar.gz --overwrite
# Create a compressed database backup
drush sql-dump | gzip -9 > $TARGET/db.sql.gz
drush sql-dump | gzip -9 > $WORKSPACE/build/db.sql.gz
}
# Main function that control the execution of the script
......@@ -259,7 +263,7 @@ function run {
fix_permissions
else
if ! drush @${DRUPAL_ENV} status; then
$ECHO "Failed to get ${DRUPAL_ENV} status" >&2
echo "Failed to get ${DRUPAL_ENV} status" >&2
exit 1
fi
fi
......@@ -288,17 +292,17 @@ function run {
fi
if [ $EN_DEPLOY -eq 1 ]; then
if [ $DRUPAL_ENV=prod && "${branch}" != 'prod' ]; then
$ECHO "Only \'prod\' branch is deployable in production" >&2
echo "Only \'prod\' branch is deployable in production" >&2
exit 1
fi
site_deploy
fi
if [ $EN_SQLSYNC -eq 1 ]; then
if [ $DRUPAL_ENV=staging ]; then
$ECHO "Sync \'staging\' environment" >&2
echo "Sync \'staging\' environment" >&2
drush --yes sql-sync @self @test
else
$ECHO "Only \'staging\' environment can be sync" >&2
echo "Only \'staging\' environment can be sync" >&2
fi
fi
}
......@@ -341,7 +345,7 @@ done
# Check that drush is installed
if ! type drush
then
$ECHO 'You must install drush to install and deploy' >&2
echo 'You must install drush to install and deploy' >&2
exit 1
fi
......@@ -349,5 +353,5 @@ fi
run
# Clear all cache
$ECHO "Clearing cache on $DRUPAL_ENV environment ..."
echo "Clearing cache on $DRUPAL_ENV environment ..."
cd $DRUPAL_ROOT && drush --yes @$DRUPAL_ENV cache-clear all
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment