From 2e91f77b953297ff412d755121aaaf245ec0f9a4 Mon Sep 17 00:00:00 2001 From: Alejandro Barrios Date: Fri, 7 May 2021 22:04:43 -0400 Subject: [PATCH 01/13] First pass at handling DOCROOT --- scripts/publisher_install.sh | 13 ++++++++++++- scripts/site_installation.sh | 33 ++++++++++++++++++++++----------- scripts/subscriber_install.sh | 13 ++++++++++++- 3 files changed, 46 insertions(+), 13 deletions(-) diff --git a/scripts/publisher_install.sh b/scripts/publisher_install.sh index 5faf685..37ccff5 100755 --- a/scripts/publisher_install.sh +++ b/scripts/publisher_install.sh @@ -2,6 +2,17 @@ DRUSH="/var/www/html/vendor/bin/drush -l ${HOSTNAME}" +# Finding the DOCROOT... +# @TODO: Find a better way to find out the docroot. +if [ -d "/var/www/html/docroot" ] +then + echo "Using directory 'docroot' as the DOCROOT..." + DOCROOT='docroot'; +else + echo "Using directory 'web' as the DOCROOT..." + DOCROOT='web'; +fi + # ------------------------------------------------------------- # Enable additional contrib/custom modules for publishers. echo "Enabling additional contributed modules for publishers..." @@ -17,7 +28,7 @@ $DRUSH pm-enable -y acquia_contenthub \ echo "Done." # Adding additional configuration to settings.php. -SETTINGS_PHP=/var/www/html/web/sites/${HOSTNAME}/settings.php +SETTINGS_PHP=/var/www/html/${DOCROOT}/sites/${HOSTNAME}/settings.php echo "Adding additional publisher configuration to settings.php ..." chmod u+w ${SETTINGS_PHP} echo " diff --git a/scripts/site_installation.sh b/scripts/site_installation.sh index f078c26..162921e 100755 --- a/scripts/site_installation.sh +++ b/scripts/site_installation.sh @@ -12,30 +12,41 @@ DB_PASS='db'; DB_HOST='database'; DB_NAME=`echo ${HOSTNAME//[-._]} | awk -F'.' '{print $1}'` +# Finding the DOCROOT... +# @TODO: Find a better way to find out the docroot. +if [ -d "/var/www/html/docroot" ] +then + echo "Using directory 'docroot' as the DOCROOT..." + DOCROOT='docroot'; +else + echo "Using directory 'web' as the DOCROOT..." + DOCROOT='web'; +fi + # Use the hostname as database name. Create it if it does not exist yet. mysql -u${DB_USER} -p${DB_PASS} -h${DB_HOST} -s -N -e "CREATE DATABASE IF NOT EXISTS ${DB_NAME};" DB_URL="mysql://${DB_USER}:${DB_PASS}@${DB_HOST}:3306/${DB_NAME}" # If the site is not persistent then delete it and start over. if [ ${PERSISTENT} = false ]; then - chmod -R 777 /var/www/html/web/sites/${HOSTNAME} - rm -Rf /var/www/html/web/sites/${HOSTNAME} + chmod -R 777 /var/www/html/${DOCROOT}/sites/${HOSTNAME} + rm -Rf /var/www/html/${DOCROOT}/sites/${HOSTNAME} fi # Verifying if site is installed. -FILE=/var/www/html/web/sites/${HOSTNAME}/settings.php +FILE=/var/www/html/${DOCROOT}/sites/${HOSTNAME}/settings.php echo "Checking file: ${FILE}" if [ -f "$FILE" ]; then echo "Site ${HOSTNAME} is already installed." else echo "Installing Drupal for site ${HOSTNAME}." - mkdir /var/www/html/web/sites/${HOSTNAME} - chmod -R 777 /var/www/html/web/sites/${HOSTNAME} - # chown -R nginx:nginx /var/www/html/web/sites/${HOSTNAME} + mkdir /var/www/html/${DOCROOT}/sites/${HOSTNAME} + chmod -R 777 /var/www/html/${DOCROOT}/sites/${HOSTNAME} + # chown -R nginx:nginx /var/www/html/${DOCROOT}/sites/${HOSTNAME} - cd /var/www/html/web || return; + cd /var/www/html/${DOCROOT} || return; mkdir -p ./sites/${HOSTNAME}/files - cp /var/www/html/web/sites/default/default.settings.php ./sites/${HOSTNAME}/settings.php + cp /var/www/html/${DOCROOT}/sites/default/default.settings.php ./sites/${HOSTNAME}/settings.php chmod 777 ./sites/${HOSTNAME}/settings.php # Site installation. @@ -44,9 +55,9 @@ else echo "Done." # Enabling PHPUnit XML. - PHPUNIT_XML="/var/www/html/web/core/phpunit-${DB_NAME}.xml" + PHPUNIT_XML="/var/www/html/${DOCROOT}/core/phpunit-${DB_NAME}.xml" echo "Configuring PHPUnit: ${PHPUNIT_XML}..." - cp /var/www/html/web/core/phpunit.xml.dist $PHPUNIT_XML + cp /var/www/html/${DOCROOT}/core/phpunit.xml.dist $PHPUNIT_XML DB_URL="mysql:\/\/${DB_USER}:${DB_PASS}@${DB_HOST}:3306\/${DB_NAME}" sed -i "s/ Date: Fri, 14 May 2021 11:55:17 -0400 Subject: [PATCH 02/13] LCH-5000: Increasing max_allowed_packet to 64MB in database to handle big inserts. --- bin/templates/default/database.tpl.sh | 2 +- bin/templates/nfs/database.tpl.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/templates/default/database.tpl.sh b/bin/templates/default/database.tpl.sh index 10fd7bc..d5d6f46 100644 --- a/bin/templates/default/database.tpl.sh +++ b/bin/templates/default/database.tpl.sh @@ -14,7 +14,7 @@ services: hostname: database.docker build: context: ./database - command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci + command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --max_allowed_packet=64MB restart: always environment: MYSQL_ROOT_PASSWORD: $MYSQL_ROOT_PASSWORD diff --git a/bin/templates/nfs/database.tpl.sh b/bin/templates/nfs/database.tpl.sh index 75bce6c..4f62f68 100644 --- a/bin/templates/nfs/database.tpl.sh +++ b/bin/templates/nfs/database.tpl.sh @@ -15,7 +15,7 @@ services: hostname: database.docker build: context: ./database - command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci + command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --max_allowed_packet=64MB restart: always environment: MYSQL_ROOT_PASSWORD: $MYSQL_ROOT_PASSWORD From d2768e162d83d744ba5706b209a6169c79d029a7 Mon Sep 17 00:00:00 2001 From: Alejandro Barrios Date: Fri, 14 May 2021 16:00:07 -0400 Subject: [PATCH 03/13] LCH-5000: Adding customer profile and allow to build using this information --- bin/commands/internal/go.sh | 12 +-- bin/commands/internal/setup.sh | 140 ++++++++++++++++----------- bin/include/setup_publisher.sh | 10 ++ bin/include/setup_subscriber.sh | 10 ++ bin/profiles/customer-environment.sh | 55 +++++++++++ 5 files changed, 164 insertions(+), 63 deletions(-) create mode 100644 bin/profiles/customer-environment.sh diff --git a/bin/commands/internal/go.sh b/bin/commands/internal/go.sh index 0242872..a38e475 100755 --- a/bin/commands/internal/go.sh +++ b/bin/commands/internal/go.sh @@ -39,12 +39,12 @@ echo "" source $SCRIPT_DIRECTORY/../../../setup_options.sh # Building Source code. -bash $SCRIPT_DIRECTORY/build_code.sh ${CONFIG_BUILD_CODE_SOURCE} ${CONFIG_BUILD_CODE_BRANCH} ${CONFIG_BUILD_DRUPAL_CORE} ${CONFIG_BUILD_PROFILE} -#if [ "${CONFIG_BUILD_CODE_SOURCE}" == 'public' ] ; then -# sh $SCRIPT_DIRECTORY/build_code.sh -#else -# sh $SCRIPT_DIRECTORY/build_code.sh ${CONFIG_BUILD_CODE_SOURCE} ${CONFIG_BUILD_CODE_BRANCH} -#fi +if [ "${CONFIG_BUILD_PROFILE}" == 'customer-environment' ] ; then + bash $SCRIPT_DIRECTORY/build_code.sh ${CONFIG_BUILD_CODE_REPOSITORY} ${CONFIG_BUILD_CODE_BRANCH} ${CONFIG_BUILD_DRUPAL_CORE} ${CONFIG_BUILD_PROFILE} +else + # By default just use the 'default' profile. + bash $SCRIPT_DIRECTORY/build_code.sh ${CONFIG_BUILD_CODE_SOURCE} ${CONFIG_BUILD_CODE_BRANCH} ${CONFIG_BUILD_DRUPAL_CORE} ${CONFIG_BUILD_PROFILE} +fi # Building containers. echo "Building Docker containers." diff --git a/bin/commands/internal/setup.sh b/bin/commands/internal/setup.sh index a7ce082..3334d00 100755 --- a/bin/commands/internal/setup.sh +++ b/bin/commands/internal/setup.sh @@ -60,6 +60,87 @@ echo "CONFIG_MYSQL_LOCAL_PORT=\"${CONFIG_MYSQL_LOCAL_PORT}\";" >> ${SETUP_FILE} echo "" >> ${SETUP_FILE} echo "" +# Build code using Build Profiles. + +# Obtaining list of available profiles. +PROFILE_FILES=`ls -1 ${SCRIPT_DIRECTORY}/../../profiles/ | sed -e 's/\.sh$//'` +BUILD_PROFILES=() +for i in ${PROFILE_FILES}; do + BUILD_PROFILES=("${BUILD_PROFILES[@]}" "$i") +done + +echo "Select a Build Profile:" +select BUILD_PROFILE in "${BUILD_PROFILES[@]}" +do + CONFIG_BUILD_PROFILE="${BUILD_PROFILE##*/}" + if ! [[ "$REPLY" =~ ^[0-9]+$ ]]; then + echo " Incorrect Input: Select a number from the options presented." + elif [ 1 -le "$REPLY" ] && [ "$REPLY" -le $((${#BUILD_PROFILES[@]})) ]; then + echo "You selected Build Profile: \"$CONFIG_BUILD_PROFILE\"." + break; + else + echo "Incorrect Input: Select a number from the options presented." + fi +done + +# If user selects customer environment the provide git repository. +case $CONFIG_BUILD_PROFILE in + "customer-environment") + # This is the "Customer Environment" Profile. + echo "To replicate a Customer Environment, please provide the Git Repository and branch/tag to clone it from..." + echo "" + while : ; do + read -p "Insert the Customer's Git Repository: " CONFIG_BUILD_CODE_REPOSITORY + read -p "Insert the branch/tag name: " CONFIG_BUILD_CODE_BRANCH + echo "Are the following values correct:" + echo " - Customer's Git Repository = ${CONFIG_BUILD_CODE_REPOSITORY}" + echo " - Branch/tag name = ${CONFIG_BUILD_CODE_BRANCH}" + read -p "(y/n)? " line + [[ ! $line =~ ^[Yy]$ ]] || break + done + echo "Saving Customer Environment information..." + echo "# Build Site Codebase." >> ${SETUP_FILE} + echo "CONFIG_BUILD_PROFILE=\"${CONFIG_BUILD_PROFILE}\";" >> ${SETUP_FILE} + echo "CONFIG_BUILD_CODE_REPOSITORY=\"${CONFIG_BUILD_CODE_REPOSITORY}\";" >> ${SETUP_FILE} + echo "CONFIG_BUILD_CODE_BRANCH=\"${CONFIG_BUILD_CODE_BRANCH}\";" >> ${SETUP_FILE} + ;; + *) + # This is the "Default" Profile. + echo "Do you want to install Acquia Content Hub from Public or Private Repository?" + CONFIG_BUILD_CODE_SOURCE="public" + CONFIG_BUILD_CODE_BRANCH="^2" + options=("Public" "Private") + select opt in "${options[@]}" + do + case $opt in + "Public") + echo "Using latest public release of Content Hub 2.x from Drupal.org." + break; + ;; + "Private") + CONFIG_BUILD_CODE_SOURCE="private" + echo "Using Acquia's Private repository." + read -p "Insert a Branch (8.x-2.x): " CONFIG_BUILD_CODE_BRANCH + CONFIG_BUILD_CODE_BRANCH="${CONFIG_BUILD_CODE_BRANCH:-"8.x-2.x"}" + break; + ;; + *) echo "Invalid option $REPLY";; + esac + done + echo "Select the version of Drupal core you want to use. Default is D8 (^8). You can also select D9 (^9)." + read -p "Drupal Core (^8): " CONFIG_BUILD_DRUPAL_CORE + CONFIG_BUILD_DRUPAL_CORE="${CONFIG_BUILD_DRUPAL_CORE:-^8}" + + echo "# Build Site Codebase." >> ${SETUP_FILE} + echo "CONFIG_BUILD_PROFILE=\"${CONFIG_BUILD_PROFILE}\";" >> ${SETUP_FILE} + echo "CONFIG_BUILD_CODE_SOURCE=\"${CONFIG_BUILD_CODE_SOURCE}\";" >> ${SETUP_FILE} + echo "CONFIG_BUILD_CODE_BRANCH=\"${CONFIG_BUILD_CODE_BRANCH}\";" >> ${SETUP_FILE} + echo "CONFIG_BUILD_DRUPAL_CORE=\"${CONFIG_BUILD_DRUPAL_CORE}\";" >> ${SETUP_FILE} + ;; +esac +echo "" >> ${SETUP_FILE} +echo "" + # Number of Publishers/Subscribers. echo "Number of Publishers / Subscribers." while : ; do @@ -83,14 +164,14 @@ echo "" # Looping through each Publisher. for (( i=1; i<=${CONFIG_NUM_PUBLISHERS}; i++ )) do - bash $SCRIPT_DIRECTORY/../../include/setup_publisher.sh $i + bash $SCRIPT_DIRECTORY/../../include/setup_publisher.sh $i ${CONFIG_BUILD_PROFILE} echo "" done # Looping through each Subscriber. for (( i=1; i<=${CONFIG_NUM_SUBSCRIBERS}; i++ )) do - bash $SCRIPT_DIRECTORY/../../include/setup_subscriber.sh $i ${CONFIG_NUM_PUBLISHERS} + bash $SCRIPT_DIRECTORY/../../include/setup_subscriber.sh $i ${CONFIG_NUM_PUBLISHERS} ${CONFIG_BUILD_PROFILE} echo "" done @@ -105,61 +186,6 @@ echo "CONFIG_NGROK_TOKEN=\"${CONFIG_NGROK_TOKEN}\";" >> ${SETUP_FILE} echo "" >> ${SETUP_FILE} echo "" -# Build code using public or private Content Hub repository. - -# Obtaining list of available profiles. -PROFILE_FILES=`ls -1 ${SCRIPT_DIRECTORY}/../../profiles/ | sed -e 's/\.sh$//'` -BUILD_PROFILES=() -for i in ${PROFILE_FILES}; do - BUILD_PROFILES=("${BUILD_PROFILES[@]}" "$i") -done - -echo "Select a Build Profile:" -select BUILD_PROFILE in "${BUILD_PROFILES[@]}" -do - CONFIG_BUILD_PROFILE="${BUILD_PROFILE##*/}" - if ! [[ "$REPLY" =~ ^[0-9]+$ ]]; then - echo " Incorrect Input: Select a number from the options presented." - elif [ 1 -le "$REPLY" ] && [ "$REPLY" -le $((${#BUILD_PROFILES[@]})) ]; then - echo "You selected Build Profile: \"$CONFIG_BUILD_PROFILE\"." - break; - else - echo "Incorrect Input: Select a number from the options presented." - fi -done - -echo "Do you want to install Acquia Content Hub from Public or Private Repository?" -CONFIG_BUILD_CODE_SOURCE="public" -CONFIG_BUILD_CODE_BRANCH="^2" -options=("Public" "Private") -select opt in "${options[@]}" -do - case $opt in - "Public") - echo "Using latest public release of Content Hub 2.x from Drupal.org." - break; - ;; - "Private") - CONFIG_BUILD_CODE_SOURCE="private" - echo "Using Acquia's Private repository." - read -p "Insert a Branch (8.x-2.x): " CONFIG_BUILD_CODE_BRANCH - CONFIG_BUILD_CODE_BRANCH="${CONFIG_BUILD_CODE_BRANCH:-"8.x-2.x"}" - break; - ;; - *) echo "Invalid option $REPLY";; - esac -done -echo "Select the version of Drupal core you want to use. Default is D8 (^8). You can also select D9 (^9)." -read -p "Drupal Core (^8): " CONFIG_BUILD_DRUPAL_CORE -CONFIG_BUILD_DRUPAL_CORE="${CONFIG_BUILD_DRUPAL_CORE:-^8}" - -echo "# Build Site Codebase." >> ${SETUP_FILE} -echo "CONFIG_BUILD_PROFILE=\"${CONFIG_BUILD_PROFILE}\";" >> ${SETUP_FILE} -echo "CONFIG_BUILD_CODE_SOURCE=\"${CONFIG_BUILD_CODE_SOURCE}\";" >> ${SETUP_FILE} -echo "CONFIG_BUILD_CODE_BRANCH=\"${CONFIG_BUILD_CODE_BRANCH}\";" >> ${SETUP_FILE} -echo "CONFIG_BUILD_DRUPAL_CORE=\"${CONFIG_BUILD_DRUPAL_CORE}\";" >> ${SETUP_FILE} -echo "" - echo "Configuration Options saved in './setup_options.sh'." echo "Creating docker-compose.yml file." diff --git a/bin/include/setup_publisher.sh b/bin/include/setup_publisher.sh index f6fdde7..d8fe2a5 100755 --- a/bin/include/setup_publisher.sh +++ b/bin/include/setup_publisher.sh @@ -7,6 +7,7 @@ CONTENT_HUB_FARM=`echo ${CONTENT_HUB_FARM_DIRECTORY} | tr - _`; # Setting up initial definitions. COUNT=$1 +CONFIG_BUILD_PROFILE=$2 CONFIG_PUB_BINDING_PORT[${COUNT}]=$((8080+${COUNT})) IP=$((10+${COUNT})) CONFIG_PUB_IP_ADDRESS[${COUNT}]="192.168.1.${IP}" @@ -28,6 +29,9 @@ while : ; do read -p "XDEBUG_CONFIG: " CONFIG_PUB_XDEBUG_CONFIG[$COUNT] XDEBUG_CONFIG_DEFAULT="remote_port=9000 remote_autostart=1" CONFIG_PUB_XDEBUG_CONFIG[$COUNT]="${CONFIG_PUB_XDEBUG_CONFIG[$COUNT]:-${XDEBUG_CONFIG_DEFAULT}}" + if [ ${CONFIG_BUILD_PROFILE} == 'customer-environment' ]; then + read -p "DATABASE_BACKUP: " CONFIG_PUB_DATABASE_BACKUP[$COUNT] + fi # Asking for verification. echo "Are the following values correct:" @@ -35,6 +39,9 @@ while : ; do echo " - Acquia Content Client Name: ${CONFIG_PUB_ACH_CLIENT_NAME[$COUNT]}" echo " - PHP_IDE_CONFIG: ${CONFIG_PUB_PHP_IDE_CONFIG[$COUNT]}" echo " - XDEBUG_CONFIG: \"${CONFIG_PUB_XDEBUG_CONFIG[$COUNT]}\"" + if [ ${CONFIG_BUILD_PROFILE} == 'customer-environment' ]; then + echo " - DATABASE_BACKUP: \"${CONFIG_PUB_DATABASE_BACKUP[$COUNT]}\"" + fi read -p "(y/n)? " line [[ ! $line =~ ^[Yy]$ ]] || break done @@ -45,6 +52,9 @@ echo "CONFIG_PUB_HOSTNAME[${COUNT}]=\"${CONFIG_PUB_HOSTNAME[${COUNT}]}\";" >> ${ echo "CONFIG_PUB_ACH_CLIENT_NAME[${COUNT}]=\"${CONFIG_PUB_ACH_CLIENT_NAME[${COUNT}]}\";" >> ${SETUP_FILE} echo "CONFIG_PUB_PHP_IDE_CONFIG[${COUNT}]=\"${CONFIG_PUB_PHP_IDE_CONFIG[${COUNT}]}\";" >> ${SETUP_FILE} echo "CONFIG_PUB_XDEBUG_CONFIG[${COUNT}]=\"${CONFIG_PUB_XDEBUG_CONFIG[${COUNT}]}\";" >> ${SETUP_FILE} +if [ ${CONFIG_BUILD_PROFILE} == 'customer-environment' ]; then + echo "CONFIG_PUB_DATABASE_BACKUP[${COUNT}]=\"${CONFIG_PUB_DATABASE_BACKUP[${COUNT}]}\";" >> ${SETUP_FILE} +fi echo "CONFIG_PUB_BINDING_PORT[${COUNT}]=\"${CONFIG_PUB_BINDING_PORT[${COUNT}]}\";" >> ${SETUP_FILE} echo "CONFIG_PUB_IP_ADDRESS[${COUNT}]=\"${CONFIG_PUB_IP_ADDRESS[${COUNT}]}\";" >> ${SETUP_FILE} echo "" >> ${SETUP_FILE} diff --git a/bin/include/setup_subscriber.sh b/bin/include/setup_subscriber.sh index 03d47c2..d786a44 100755 --- a/bin/include/setup_subscriber.sh +++ b/bin/include/setup_subscriber.sh @@ -8,6 +8,7 @@ CONTENT_HUB_FARM=`echo ${CONTENT_HUB_FARM_DIRECTORY} | tr - _`; # Setting up initial definitions. COUNT=$1 NUM_PUBLISHERS=$2 +CONFIG_BUILD_PROFILE=$3 CONFIG_SUB_BINDING_PORT[${COUNT}]=$((8080+${NUM_PUBLISHERS}+${COUNT})) IP=$((10+${NUM_PUBLISHERS}+${COUNT})) CONFIG_SUB_IP_ADDRESS[${COUNT}]="192.168.1.${IP}" @@ -29,6 +30,9 @@ while : ; do read -p "XDEBUG_CONFIG: " CONFIG_SUB_XDEBUG_CONFIG[$COUNT] XDEBUG_CONFIG_DEFAULT="remote_port=9000 remote_autostart=1" CONFIG_SUB_XDEBUG_CONFIG[$COUNT]="${CONFIG_SUB_XDEBUG_CONFIG[$COUNT]:-${XDEBUG_CONFIG_DEFAULT}}" + if [ ${CONFIG_BUILD_PROFILE} == 'customer-environment' ]; then + read -p "DATABASE_BACKUP: " CONFIG_SUB_DATABASE_BACKUP[$COUNT] + fi # Asking for verification. echo "Are the following values correct:" @@ -36,6 +40,9 @@ while : ; do echo " - Acquia Content Client Name: ${CONFIG_SUB_ACH_CLIENT_NAME[$COUNT]}" echo " - PHP_IDE_CONFIG: ${CONFIG_SUB_PHP_IDE_CONFIG[$COUNT]}" echo " - XDEBUG_CONFIG: \"${CONFIG_SUB_XDEBUG_CONFIG[$COUNT]}\"" + if [ ${CONFIG_BUILD_PROFILE} == 'customer-environment' ]; then + echo " - DATABASE_BACKUP: \"${CONFIG_SUB_DATABASE_BACKUP[$COUNT]}\"" + fi read -p "(y/n)? " line [[ ! $line =~ ^[Yy]$ ]] || break done @@ -46,6 +53,9 @@ echo "CONFIG_SUB_HOSTNAME[${COUNT}]=\"${CONFIG_SUB_HOSTNAME[${COUNT}]}\";" >> ${ echo "CONFIG_SUB_ACH_CLIENT_NAME[${COUNT}]=\"${CONFIG_SUB_ACH_CLIENT_NAME[${COUNT}]}\";" >> ${SETUP_FILE} echo "CONFIG_SUB_PHP_IDE_CONFIG[${COUNT}]=\"${CONFIG_SUB_PHP_IDE_CONFIG[${COUNT}]}\";" >> ${SETUP_FILE} echo "CONFIG_SUB_XDEBUG_CONFIG[${COUNT}]=\"${CONFIG_SUB_XDEBUG_CONFIG[${COUNT}]}\";" >> ${SETUP_FILE} +if [ ${CONFIG_BUILD_PROFILE} == 'customer-environment' ]; then + echo "CONFIG_SUB_DATABASE_BACKUP[${COUNT}]=\"${CONFIG_SUB_DATABASE_BACKUP[${COUNT}]}\";" >> ${SETUP_FILE} +fi echo "CONFIG_SUB_BINDING_PORT[${COUNT}]=\"${CONFIG_SUB_BINDING_PORT[${COUNT}]}\";" >> ${SETUP_FILE} echo "CONFIG_SUB_IP_ADDRESS[${COUNT}]=\"${CONFIG_SUB_IP_ADDRESS[${COUNT}]}\";" >> ${SETUP_FILE} echo "" >> ${SETUP_FILE} diff --git a/bin/profiles/customer-environment.sh b/bin/profiles/customer-environment.sh new file mode 100644 index 0000000..cc7b027 --- /dev/null +++ b/bin/profiles/customer-environment.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +# Build Code base. + +# Project Document Base Root Folder. +BASE_ROOT=html + +# Gathering data to build the code base. +GIT_REPOSITORY="${1:-'NONE'}" +GIT_BRANCH="${2:-'NONE'}" + +if [ $GIT_REPOSITORY == 'NONE' ] || [ $GIT_BRANCH == 'NONE' ] ; then + echo "Not enough information provided to build Codebase from Customer's Git Repository." +fi + +echo "Building Codebase from Customer Repository using GIT REPOSITORY = '${GIT_REPOSITORY}' and GIT BRANCH = '${GIT_BRANCH}'." +echo "---------------------------------------------------" +if [ -d "$BASE_ROOT" ]; then + echo "Cleaning up existing directory $BASE_ROOT" + chmod -R 777 $BASE_ROOT + rm -Rf $BASE_ROOT +else + echo "Creating directory $BASE_ROOT" + mkdir $BASE_ROOT +fi +echo "Done." +echo "Building Drupal project in folder '${BASE_ROOT}'..." +git clone --branch ${GIT_BRANCH} --single-branch --depth=1 ${GIT_REPOSITORY} ${BASE_ROOT} +echo "Done." +echo "Adding Drupal contrib modules..." +cd $BASE_ROOT || exit + +# DO NOT MODIFY THIS LIST OF PACKAGES. +COMPOSER_MEMORY_LIMIT=-1 composer require drupal/environment_indicator \ + drupal/admin_toolbar \ + +# ------------------------------------------------------------- +echo "Done." + +# Finding the DOCROOT... +# @TODO: Find a better way to find out the docroot. +if [ -d "./docroot" ] +then + echo "Using directory 'docroot' as the DOCROOT..." + DOCROOT='docroot'; +else + echo "Using directory 'web' as the DOCROOT..." + DOCROOT='web'; +fi + +chmod -R 777 ${DOCROOT}/sites + +# Configure Coding Standards +# ./vendor/bin/phpcs --config-set installed_paths vendor/drupal/coder/coder_sniffer +echo "Done." From 43082868614d41bd4229618b7ceab15df66174c0 Mon Sep 17 00:00:00 2001 From: Alejandro Barrios Date: Fri, 14 May 2021 16:31:09 -0400 Subject: [PATCH 04/13] LCH-5000: Fixing build_code script to support customer profile --- bin/commands/internal/build_code.sh | 6 +++--- bin/include/setup_publisher.sh | 15 ++++++++------- bin/include/setup_subscriber.sh | 14 +++++++------- bin/profiles/customer-environment.sh | 8 ++++---- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/bin/commands/internal/build_code.sh b/bin/commands/internal/build_code.sh index 69fcb2d..3af77ad 100755 --- a/bin/commands/internal/build_code.sh +++ b/bin/commands/internal/build_code.sh @@ -28,9 +28,9 @@ fi # By default use 'public' repository. BUILD="${1:-public}" -if [[ ! (-z "$1") && $BUILD != 'public' ]] ; then - BUILD='private' -fi +#if [[ ! (-z "$1") && $BUILD != 'public' ]] ; then +# BUILD='private' +#fi # If provided a branch name, use it, otherwise use default 8.x-2.x ACH_BRANCH=$2 diff --git a/bin/include/setup_publisher.sh b/bin/include/setup_publisher.sh index d8fe2a5..34d7424 100755 --- a/bin/include/setup_publisher.sh +++ b/bin/include/setup_publisher.sh @@ -20,6 +20,9 @@ while : ; do CONFIG_PUB_HOSTNAME_DEFAULT="publisher${COUNT}.ngrok.io" CONFIG_PUB_HOSTNAME[$COUNT]="${CONFIG_PUB_HOSTNAME[$COUNT]:-${CONFIG_PUB_HOSTNAME_DEFAULT}}" read -p "Insert your Acquia Content Client Name: " CONFIG_PUB_ACH_CLIENT_NAME[$COUNT] + if [ ${CONFIG_BUILD_PROFILE} == 'customer-environment' ]; then + read -p "DATABASE_BACKUP (full path): " CONFIG_PUB_DATABASE_BACKUP[$COUNT] + fi echo "The following are Environmental variables used for PHP Debugging." echo "If you are unsure about the values, just leave them blank and we will do our best guess to set defaults." echo "You can always change them later." @@ -29,19 +32,17 @@ while : ; do read -p "XDEBUG_CONFIG: " CONFIG_PUB_XDEBUG_CONFIG[$COUNT] XDEBUG_CONFIG_DEFAULT="remote_port=9000 remote_autostart=1" CONFIG_PUB_XDEBUG_CONFIG[$COUNT]="${CONFIG_PUB_XDEBUG_CONFIG[$COUNT]:-${XDEBUG_CONFIG_DEFAULT}}" - if [ ${CONFIG_BUILD_PROFILE} == 'customer-environment' ]; then - read -p "DATABASE_BACKUP: " CONFIG_PUB_DATABASE_BACKUP[$COUNT] - fi + # Asking for verification. echo "Are the following values correct:" echo " - Publisher$COUNT Hostname: ${CONFIG_PUB_HOSTNAME[$COUNT]}" echo " - Acquia Content Client Name: ${CONFIG_PUB_ACH_CLIENT_NAME[$COUNT]}" - echo " - PHP_IDE_CONFIG: ${CONFIG_PUB_PHP_IDE_CONFIG[$COUNT]}" - echo " - XDEBUG_CONFIG: \"${CONFIG_PUB_XDEBUG_CONFIG[$COUNT]}\"" if [ ${CONFIG_BUILD_PROFILE} == 'customer-environment' ]; then echo " - DATABASE_BACKUP: \"${CONFIG_PUB_DATABASE_BACKUP[$COUNT]}\"" fi + echo " - PHP_IDE_CONFIG: ${CONFIG_PUB_PHP_IDE_CONFIG[$COUNT]}" + echo " - XDEBUG_CONFIG: \"${CONFIG_PUB_XDEBUG_CONFIG[$COUNT]}\"" read -p "(y/n)? " line [[ ! $line =~ ^[Yy]$ ]] || break done @@ -50,11 +51,11 @@ echo "Saving Publisher$COUNT configuration..." echo "# Publisher$COUNT." >> ${SETUP_FILE} echo "CONFIG_PUB_HOSTNAME[${COUNT}]=\"${CONFIG_PUB_HOSTNAME[${COUNT}]}\";" >> ${SETUP_FILE} echo "CONFIG_PUB_ACH_CLIENT_NAME[${COUNT}]=\"${CONFIG_PUB_ACH_CLIENT_NAME[${COUNT}]}\";" >> ${SETUP_FILE} -echo "CONFIG_PUB_PHP_IDE_CONFIG[${COUNT}]=\"${CONFIG_PUB_PHP_IDE_CONFIG[${COUNT}]}\";" >> ${SETUP_FILE} -echo "CONFIG_PUB_XDEBUG_CONFIG[${COUNT}]=\"${CONFIG_PUB_XDEBUG_CONFIG[${COUNT}]}\";" >> ${SETUP_FILE} if [ ${CONFIG_BUILD_PROFILE} == 'customer-environment' ]; then echo "CONFIG_PUB_DATABASE_BACKUP[${COUNT}]=\"${CONFIG_PUB_DATABASE_BACKUP[${COUNT}]}\";" >> ${SETUP_FILE} fi +echo "CONFIG_PUB_PHP_IDE_CONFIG[${COUNT}]=\"${CONFIG_PUB_PHP_IDE_CONFIG[${COUNT}]}\";" >> ${SETUP_FILE} +echo "CONFIG_PUB_XDEBUG_CONFIG[${COUNT}]=\"${CONFIG_PUB_XDEBUG_CONFIG[${COUNT}]}\";" >> ${SETUP_FILE} echo "CONFIG_PUB_BINDING_PORT[${COUNT}]=\"${CONFIG_PUB_BINDING_PORT[${COUNT}]}\";" >> ${SETUP_FILE} echo "CONFIG_PUB_IP_ADDRESS[${COUNT}]=\"${CONFIG_PUB_IP_ADDRESS[${COUNT}]}\";" >> ${SETUP_FILE} echo "" >> ${SETUP_FILE} diff --git a/bin/include/setup_subscriber.sh b/bin/include/setup_subscriber.sh index d786a44..a3b0586 100755 --- a/bin/include/setup_subscriber.sh +++ b/bin/include/setup_subscriber.sh @@ -21,6 +21,9 @@ while : ; do CONFIG_SUB_HOSTNAME_DEFAULT="subscriber${COUNT}.ngrok.io" CONFIG_SUB_HOSTNAME[$COUNT]="${CONFIG_SUB_HOSTNAME[$COUNT]:-${CONFIG_SUB_HOSTNAME_DEFAULT}}" read -p "Insert your Acquia Content Client Name: " CONFIG_SUB_ACH_CLIENT_NAME[$COUNT] + if [ ${CONFIG_BUILD_PROFILE} == 'customer-environment' ]; then + read -p "DATABASE_BACKUP (full path): " CONFIG_SUB_DATABASE_BACKUP[$COUNT] + fi echo "The following are Environmental variables used for PHP Debugging." echo "If you are unsure about the values, just leave them blank and we will do our best guess to set defaults." echo "You can always change them later." @@ -30,19 +33,16 @@ while : ; do read -p "XDEBUG_CONFIG: " CONFIG_SUB_XDEBUG_CONFIG[$COUNT] XDEBUG_CONFIG_DEFAULT="remote_port=9000 remote_autostart=1" CONFIG_SUB_XDEBUG_CONFIG[$COUNT]="${CONFIG_SUB_XDEBUG_CONFIG[$COUNT]:-${XDEBUG_CONFIG_DEFAULT}}" - if [ ${CONFIG_BUILD_PROFILE} == 'customer-environment' ]; then - read -p "DATABASE_BACKUP: " CONFIG_SUB_DATABASE_BACKUP[$COUNT] - fi # Asking for verification. echo "Are the following values correct:" echo " - Subscriber$COUNT Hostname: ${CONFIG_SUB_HOSTNAME[$COUNT]}" echo " - Acquia Content Client Name: ${CONFIG_SUB_ACH_CLIENT_NAME[$COUNT]}" - echo " - PHP_IDE_CONFIG: ${CONFIG_SUB_PHP_IDE_CONFIG[$COUNT]}" - echo " - XDEBUG_CONFIG: \"${CONFIG_SUB_XDEBUG_CONFIG[$COUNT]}\"" if [ ${CONFIG_BUILD_PROFILE} == 'customer-environment' ]; then echo " - DATABASE_BACKUP: \"${CONFIG_SUB_DATABASE_BACKUP[$COUNT]}\"" fi + echo " - PHP_IDE_CONFIG: ${CONFIG_SUB_PHP_IDE_CONFIG[$COUNT]}" + echo " - XDEBUG_CONFIG: \"${CONFIG_SUB_XDEBUG_CONFIG[$COUNT]}\"" read -p "(y/n)? " line [[ ! $line =~ ^[Yy]$ ]] || break done @@ -51,11 +51,11 @@ echo "Saving Subscriber$COUNT configuration..." echo "# Subscriber$COUNT." >> ${SETUP_FILE} echo "CONFIG_SUB_HOSTNAME[${COUNT}]=\"${CONFIG_SUB_HOSTNAME[${COUNT}]}\";" >> ${SETUP_FILE} echo "CONFIG_SUB_ACH_CLIENT_NAME[${COUNT}]=\"${CONFIG_SUB_ACH_CLIENT_NAME[${COUNT}]}\";" >> ${SETUP_FILE} -echo "CONFIG_SUB_PHP_IDE_CONFIG[${COUNT}]=\"${CONFIG_SUB_PHP_IDE_CONFIG[${COUNT}]}\";" >> ${SETUP_FILE} -echo "CONFIG_SUB_XDEBUG_CONFIG[${COUNT}]=\"${CONFIG_SUB_XDEBUG_CONFIG[${COUNT}]}\";" >> ${SETUP_FILE} if [ ${CONFIG_BUILD_PROFILE} == 'customer-environment' ]; then echo "CONFIG_SUB_DATABASE_BACKUP[${COUNT}]=\"${CONFIG_SUB_DATABASE_BACKUP[${COUNT}]}\";" >> ${SETUP_FILE} fi +echo "CONFIG_SUB_PHP_IDE_CONFIG[${COUNT}]=\"${CONFIG_SUB_PHP_IDE_CONFIG[${COUNT}]}\";" >> ${SETUP_FILE} +echo "CONFIG_SUB_XDEBUG_CONFIG[${COUNT}]=\"${CONFIG_SUB_XDEBUG_CONFIG[${COUNT}]}\";" >> ${SETUP_FILE} echo "CONFIG_SUB_BINDING_PORT[${COUNT}]=\"${CONFIG_SUB_BINDING_PORT[${COUNT}]}\";" >> ${SETUP_FILE} echo "CONFIG_SUB_IP_ADDRESS[${COUNT}]=\"${CONFIG_SUB_IP_ADDRESS[${COUNT}]}\";" >> ${SETUP_FILE} echo "" >> ${SETUP_FILE} diff --git a/bin/profiles/customer-environment.sh b/bin/profiles/customer-environment.sh index cc7b027..0028643 100644 --- a/bin/profiles/customer-environment.sh +++ b/bin/profiles/customer-environment.sh @@ -27,15 +27,15 @@ echo "Done." echo "Building Drupal project in folder '${BASE_ROOT}'..." git clone --branch ${GIT_BRANCH} --single-branch --depth=1 ${GIT_REPOSITORY} ${BASE_ROOT} echo "Done." -echo "Adding Drupal contrib modules..." +# echo "Adding Drupal contrib modules..." cd $BASE_ROOT || exit # DO NOT MODIFY THIS LIST OF PACKAGES. -COMPOSER_MEMORY_LIMIT=-1 composer require drupal/environment_indicator \ - drupal/admin_toolbar \ +# COMPOSER_MEMORY_LIMIT=-1 composer require drupal/environment_indicator \ +# drupal/admin_toolbar \ # ------------------------------------------------------------- -echo "Done." +# echo "Done." # Finding the DOCROOT... # @TODO: Find a better way to find out the docroot. From 3382ecdab64ccd4a616eebefb3a30df970ff795f Mon Sep 17 00:00:00 2001 From: Alejandro Barrios Date: Fri, 14 May 2021 16:51:15 -0400 Subject: [PATCH 05/13] LCH-5000: Really fix for build_code script --- bin/commands/internal/go.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/commands/internal/go.sh b/bin/commands/internal/go.sh index a38e475..cdb35fb 100755 --- a/bin/commands/internal/go.sh +++ b/bin/commands/internal/go.sh @@ -39,8 +39,8 @@ echo "" source $SCRIPT_DIRECTORY/../../../setup_options.sh # Building Source code. -if [ "${CONFIG_BUILD_PROFILE}" == 'customer-environment' ] ; then - bash $SCRIPT_DIRECTORY/build_code.sh ${CONFIG_BUILD_CODE_REPOSITORY} ${CONFIG_BUILD_CODE_BRANCH} ${CONFIG_BUILD_DRUPAL_CORE} ${CONFIG_BUILD_PROFILE} +if [ ${CONFIG_BUILD_PROFILE} == 'customer-environment' ]; then + bash $SCRIPT_DIRECTORY/build_code.sh ${CONFIG_BUILD_CODE_REPOSITORY} ${CONFIG_BUILD_CODE_BRANCH} DRUPAL ${CONFIG_BUILD_PROFILE} else # By default just use the 'default' profile. bash $SCRIPT_DIRECTORY/build_code.sh ${CONFIG_BUILD_CODE_SOURCE} ${CONFIG_BUILD_CODE_BRANCH} ${CONFIG_BUILD_DRUPAL_CORE} ${CONFIG_BUILD_PROFILE} From 253d21a87387de69d656ad4de272f103277804db Mon Sep 17 00:00:00 2001 From: Alejandro Barrios Date: Fri, 14 May 2021 20:21:25 -0400 Subject: [PATCH 06/13] LCH-5000: Adding backups volume --- bin/templates/default/publisher.tpl.sh | 2 ++ bin/templates/default/subscriber.tpl.sh | 2 ++ bin/templates/nfs/network_volume.tpl.sh | 6 ++++++ bin/templates/nfs/publisher.tpl.sh | 6 ++++++ bin/templates/nfs/subscriber.tpl.sh | 6 ++++++ 5 files changed, 22 insertions(+) diff --git a/bin/templates/default/publisher.tpl.sh b/bin/templates/default/publisher.tpl.sh index 1d45e34..5195cfd 100644 --- a/bin/templates/default/publisher.tpl.sh +++ b/bin/templates/default/publisher.tpl.sh @@ -18,10 +18,12 @@ cat << EOF - SITE_ROLE=publisher - PERSISTENT=true - ACH_CLIENT_NAME=${CONFIG_PUB_ACH_CLIENT_NAME[$COUNT]} + - DATABASE_BACKUP=${CONFIG_PUB_DATABASE_BACKUP[$COUNT]} - PHP_IDE_CONFIG=${CONFIG_PUB_PHP_IDE_CONFIG[$COUNT]} - XDEBUG_CONFIG=${CONFIG_PUB_XDEBUG_CONFIG[$COUNT]} volumes: - ./html:/var/www/html + - ./backups:/var/www/backups ports: - ${CONFIG_PUB_BINDING_PORT[${COUNT}]}:80 networks: diff --git a/bin/templates/default/subscriber.tpl.sh b/bin/templates/default/subscriber.tpl.sh index 453e204..a1187d7 100644 --- a/bin/templates/default/subscriber.tpl.sh +++ b/bin/templates/default/subscriber.tpl.sh @@ -18,10 +18,12 @@ cat << EOF - SITE_ROLE=subscriber - PERSISTENT=true - ACH_CLIENT_NAME=${CONFIG_SUB_ACH_CLIENT_NAME[$COUNT]} + - DATABASE_BACKUP=${CONFIG_SUB_DATABASE_BACKUP[$COUNT]} - PHP_IDE_CONFIG=${CONFIG_SUB_PHP_IDE_CONFIG[$COUNT]} - XDEBUG_CONFIG=${CONFIG_SUB_XDEBUG_CONFIG[$COUNT]} volumes: - ./html:/var/www/html + - ./backups:/var/www/backups ports: - ${CONFIG_SUB_BINDING_PORT[${COUNT}]}:80 networks: diff --git a/bin/templates/nfs/network_volume.tpl.sh b/bin/templates/nfs/network_volume.tpl.sh index b2d0932..3b42900 100644 --- a/bin/templates/nfs/network_volume.tpl.sh +++ b/bin/templates/nfs/network_volume.tpl.sh @@ -21,4 +21,10 @@ volumes: type: "nfs" o: "addr=host.docker.internal,hard,nolock,rw" device: ":/System/Volumes/Data/${CONFIG_VOLUME_DEVICE_PATH}/html" + backups: + driver: local + driver_opts: + type: "nfs" + o: "addr=host.docker.internal,hard,nolock,rw" + device: ":/System/Volumes/Data/${CONFIG_VOLUME_DEVICE_PATH}/backups" EOF \ No newline at end of file diff --git a/bin/templates/nfs/publisher.tpl.sh b/bin/templates/nfs/publisher.tpl.sh index 56fa1bf..f7bf685 100644 --- a/bin/templates/nfs/publisher.tpl.sh +++ b/bin/templates/nfs/publisher.tpl.sh @@ -18,6 +18,7 @@ cat << EOF - SITE_ROLE=publisher - PERSISTENT=true - ACH_CLIENT_NAME=${CONFIG_PUB_ACH_CLIENT_NAME[$COUNT]} + - DATABASE_BACKUP=${CONFIG_PUB_DATABASE_BACKUP[$COUNT]} - PHP_IDE_CONFIG=${CONFIG_PUB_PHP_IDE_CONFIG[$COUNT]} - XDEBUG_CONFIG=${CONFIG_PUB_XDEBUG_CONFIG[$COUNT]} volumes: @@ -26,6 +27,11 @@ cat << EOF target: /var/www/html volume: nocopy: true + - type: volume + source: backups + target: /var/www/backups + volume: + nocopy: true ports: - ${CONFIG_PUB_BINDING_PORT[${COUNT}]}:80 networks: diff --git a/bin/templates/nfs/subscriber.tpl.sh b/bin/templates/nfs/subscriber.tpl.sh index a2a3c0c..c2735a6 100644 --- a/bin/templates/nfs/subscriber.tpl.sh +++ b/bin/templates/nfs/subscriber.tpl.sh @@ -18,6 +18,7 @@ cat << EOF - SITE_ROLE=subscriber - PERSISTENT=true - ACH_CLIENT_NAME=${CONFIG_SUB_ACH_CLIENT_NAME[$COUNT]} + - DATABASE_BACKUP=${CONFIG_SUB_DATABASE_BACKUP[$COUNT]} - PHP_IDE_CONFIG=${CONFIG_SUB_PHP_IDE_CONFIG[$COUNT]} - XDEBUG_CONFIG=${CONFIG_SUB_XDEBUG_CONFIG[$COUNT]} volumes: @@ -26,6 +27,11 @@ cat << EOF target: /var/www/html volume: nocopy: true + - type: volume + source: backups + target: /var/www/backups + volume: + nocopy: true ports: - ${CONFIG_SUB_BINDING_PORT[${COUNT}]}:80 networks: From d7d4d371e6156e117f5fc60367bd30dd6047806d Mon Sep 17 00:00:00 2001 From: Alejandro Barrios Date: Fri, 14 May 2021 20:29:57 -0400 Subject: [PATCH 07/13] LCH-5000: Fixing user input to backup files --- backups/.gitignore | 4 ++++ bin/include/setup_publisher.sh | 2 +- bin/include/setup_subscriber.sh | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 backups/.gitignore diff --git a/backups/.gitignore b/backups/.gitignore new file mode 100644 index 0000000..6af79d9 --- /dev/null +++ b/backups/.gitignore @@ -0,0 +1,4 @@ +# Please put all database backups inside this directory. +* +# Ignore (but don't delete) this line +!.gitignore diff --git a/bin/include/setup_publisher.sh b/bin/include/setup_publisher.sh index 34d7424..fce8904 100755 --- a/bin/include/setup_publisher.sh +++ b/bin/include/setup_publisher.sh @@ -21,7 +21,7 @@ while : ; do CONFIG_PUB_HOSTNAME[$COUNT]="${CONFIG_PUB_HOSTNAME[$COUNT]:-${CONFIG_PUB_HOSTNAME_DEFAULT}}" read -p "Insert your Acquia Content Client Name: " CONFIG_PUB_ACH_CLIENT_NAME[$COUNT] if [ ${CONFIG_BUILD_PROFILE} == 'customer-environment' ]; then - read -p "DATABASE_BACKUP (full path): " CONFIG_PUB_DATABASE_BACKUP[$COUNT] + read -p "DATABASE_BACKUP (filename inside 'backups' directory): " CONFIG_PUB_DATABASE_BACKUP[$COUNT] fi echo "The following are Environmental variables used for PHP Debugging." echo "If you are unsure about the values, just leave them blank and we will do our best guess to set defaults." diff --git a/bin/include/setup_subscriber.sh b/bin/include/setup_subscriber.sh index a3b0586..0a8fc2e 100755 --- a/bin/include/setup_subscriber.sh +++ b/bin/include/setup_subscriber.sh @@ -22,7 +22,7 @@ while : ; do CONFIG_SUB_HOSTNAME[$COUNT]="${CONFIG_SUB_HOSTNAME[$COUNT]:-${CONFIG_SUB_HOSTNAME_DEFAULT}}" read -p "Insert your Acquia Content Client Name: " CONFIG_SUB_ACH_CLIENT_NAME[$COUNT] if [ ${CONFIG_BUILD_PROFILE} == 'customer-environment' ]; then - read -p "DATABASE_BACKUP (full path): " CONFIG_SUB_DATABASE_BACKUP[$COUNT] + read -p "DATABASE_BACKUP (filename inside 'backups' directory): " CONFIG_SUB_DATABASE_BACKUP[$COUNT] fi echo "The following are Environmental variables used for PHP Debugging." echo "If you are unsure about the values, just leave them blank and we will do our best guess to set defaults." From 5b4a66cd886271b6ba1ab1c0d68252e043187a91 Mon Sep 17 00:00:00 2001 From: Alejandro Barrios Date: Fri, 14 May 2021 21:38:03 -0400 Subject: [PATCH 08/13] LCH-5000: Import existing databases and set up Content Hub. --- bin/profiles/customer-environment.sh | 10 ++++ config/patches/no-client-cdf-update.patch | 12 ++++ scripts/site_installation.sh | 72 +++++++++++++---------- 3 files changed, 62 insertions(+), 32 deletions(-) create mode 100644 config/patches/no-client-cdf-update.patch diff --git a/bin/profiles/customer-environment.sh b/bin/profiles/customer-environment.sh index 0028643..4e4609c 100644 --- a/bin/profiles/customer-environment.sh +++ b/bin/profiles/customer-environment.sh @@ -1,5 +1,7 @@ #!/bin/bash +SCRIPT_DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + # Build Code base. # Project Document Base Root Folder. @@ -50,6 +52,14 @@ fi chmod -R 777 ${DOCROOT}/sites +# Apply Content Hub patch. +PATCH_FILE="${SCRIPT_DIRECTORY}/../../config/patches/no-client-cdf-update.patch" +ACH_FOLDER=`find ./ -iname acquia_contenthub` +cd ${ACH_FOLDER} || exit + +echo "Applying patch 'config/patches/no-client-cdf-update.patch'..." +patch -p1 < $PATCH_FILE + # Configure Coding Standards # ./vendor/bin/phpcs --config-set installed_paths vendor/drupal/coder/coder_sniffer echo "Done." diff --git a/config/patches/no-client-cdf-update.patch b/config/patches/no-client-cdf-update.patch new file mode 100644 index 0000000..8b9d297 --- /dev/null +++ b/config/patches/no-client-cdf-update.patch @@ -0,0 +1,12 @@ +diff --git a/src/Client/ClientFactory.php b/src/Client/ClientFactory.php +index 7cca5507..d2c947ee 100755 +--- a/src/Client/ClientFactory.php ++++ b/src/Client/ClientFactory.php +@@ -254,6 +254,7 @@ class ClientFactory { + * @throws \ReflectionException + */ + public function updateClientCdf() { ++ return true; + /** @var \Acquia\ContentHubClient\CDF\ClientCDFObject $remote_cdf */ + $remote_cdf = $this->client->getEntity($this->settings->getUuid()); + // Don't update the ClientCDF if the remote object matches the local one. diff --git a/scripts/site_installation.sh b/scripts/site_installation.sh index 162921e..3469804 100755 --- a/scripts/site_installation.sh +++ b/scripts/site_installation.sh @@ -42,7 +42,6 @@ else echo "Installing Drupal for site ${HOSTNAME}." mkdir /var/www/html/${DOCROOT}/sites/${HOSTNAME} chmod -R 777 /var/www/html/${DOCROOT}/sites/${HOSTNAME} - # chown -R nginx:nginx /var/www/html/${DOCROOT}/sites/${HOSTNAME} cd /var/www/html/${DOCROOT} || return; mkdir -p ./sites/${HOSTNAME}/files @@ -63,41 +62,50 @@ else sed -i "s/ Date: Fri, 14 May 2021 22:03:00 -0400 Subject: [PATCH 09/13] LCH-5000: Only install minimal profile when provided a backup --- scripts/site_installation.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/site_installation.sh b/scripts/site_installation.sh index 3469804..6bc5e99 100755 --- a/scripts/site_installation.sh +++ b/scripts/site_installation.sh @@ -49,6 +49,10 @@ else chmod 777 ./sites/${HOSTNAME}/settings.php # Site installation. + if [ "${DATABASE_BACKUP}" ]; then + # If we are provided a backup then install the minimal profile as we will override with db backup. + profile='minimal' + fi ../vendor/drush/drush/drush si -y $profile install_configure_form.enable_update_status_emails=NULL -y --account-name=${site_admin} --account-pass=${site_password} --account-mail=${site_mail} --site-mail=${site_mail} --site-name=${HOSTNAME} --sites-subdir=${HOSTNAME} --db-url=${DB_URL} DRUSH="/var/www/html/vendor/bin/drush -l ${HOSTNAME}" echo "Done." @@ -62,6 +66,7 @@ else sed -i "s/ Date: Mon, 17 May 2021 14:57:01 -0400 Subject: [PATCH 10/13] LCH-5000: Allow for building environment without providing any git repo/branch because codebase is already in place. --- bin/commands/internal/setup.sh | 7 +++--- bin/profiles/customer-environment.sh | 33 ++++++++++++++-------------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/bin/commands/internal/setup.sh b/bin/commands/internal/setup.sh index 3334d00..2bec316 100755 --- a/bin/commands/internal/setup.sh +++ b/bin/commands/internal/setup.sh @@ -87,11 +87,12 @@ done case $CONFIG_BUILD_PROFILE in "customer-environment") # This is the "Customer Environment" Profile. - echo "To replicate a Customer Environment, please provide the Git Repository and branch/tag to clone it from..." + echo "To replicate a Customer Environment, please provide the Git Repository and branch/tag to clone it from." + echo "If you already have the code deployed in 'html' directory, leave 'Git Repository' and 'branch/tag' blank." echo "" while : ; do - read -p "Insert the Customer's Git Repository: " CONFIG_BUILD_CODE_REPOSITORY - read -p "Insert the branch/tag name: " CONFIG_BUILD_CODE_BRANCH + read -p "Insert the Customer's Git Repository (blank if deployed in 'html'): " CONFIG_BUILD_CODE_REPOSITORY + read -p "Insert the branch/tag name (blank if deployed in 'html'): " CONFIG_BUILD_CODE_BRANCH echo "Are the following values correct:" echo " - Customer's Git Repository = ${CONFIG_BUILD_CODE_REPOSITORY}" echo " - Branch/tag name = ${CONFIG_BUILD_CODE_BRANCH}" diff --git a/bin/profiles/customer-environment.sh b/bin/profiles/customer-environment.sh index 4e4609c..57e51f5 100644 --- a/bin/profiles/customer-environment.sh +++ b/bin/profiles/customer-environment.sh @@ -11,24 +11,25 @@ BASE_ROOT=html GIT_REPOSITORY="${1:-'NONE'}" GIT_BRANCH="${2:-'NONE'}" -if [ $GIT_REPOSITORY == 'NONE' ] || [ $GIT_BRANCH == 'NONE' ] ; then - echo "Not enough information provided to build Codebase from Customer's Git Repository." -fi - -echo "Building Codebase from Customer Repository using GIT REPOSITORY = '${GIT_REPOSITORY}' and GIT BRANCH = '${GIT_BRANCH}'." -echo "---------------------------------------------------" -if [ -d "$BASE_ROOT" ]; then - echo "Cleaning up existing directory $BASE_ROOT" - chmod -R 777 $BASE_ROOT - rm -Rf $BASE_ROOT +if [ $GIT_REPOSITORY != 'NONE' ] && [ $GIT_BRANCH != 'NONE' ] ; then + echo "Using existing codebase from '${BASE_ROOT}'." + echo "---------------------------------------------------" else - echo "Creating directory $BASE_ROOT" - mkdir $BASE_ROOT + echo "Building Codebase from Customer Repository using GIT REPOSITORY = '${GIT_REPOSITORY}' and GIT BRANCH = '${GIT_BRANCH}'." + echo "---------------------------------------------------" + if [ -d "$BASE_ROOT" ]; then + echo "Cleaning up existing directory $BASE_ROOT" + chmod -R 777 $BASE_ROOT + rm -Rf $BASE_ROOT + else + echo "Creating directory $BASE_ROOT" + mkdir $BASE_ROOT + fi + echo "Done." + echo "Building Drupal project in folder '${BASE_ROOT}'..." + git clone --branch ${GIT_BRANCH} --single-branch --depth=1 ${GIT_REPOSITORY} ${BASE_ROOT} + echo "Done." fi -echo "Done." -echo "Building Drupal project in folder '${BASE_ROOT}'..." -git clone --branch ${GIT_BRANCH} --single-branch --depth=1 ${GIT_REPOSITORY} ${BASE_ROOT} -echo "Done." # echo "Adding Drupal contrib modules..." cd $BASE_ROOT || exit From 970f88043a8c1e2aad39d277c1d325299ad4e154 Mon Sep 17 00:00:00 2001 From: Alejandro Barrios Date: Mon, 17 May 2021 15:34:20 -0400 Subject: [PATCH 11/13] LCH-5000: Fixing setting up NONE git repo --- bin/commands/internal/setup.sh | 2 ++ bin/profiles/customer-environment.sh | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/commands/internal/setup.sh b/bin/commands/internal/setup.sh index 2bec316..8a85df7 100755 --- a/bin/commands/internal/setup.sh +++ b/bin/commands/internal/setup.sh @@ -99,6 +99,8 @@ case $CONFIG_BUILD_PROFILE in read -p "(y/n)? " line [[ ! $line =~ ^[Yy]$ ]] || break done + CONFIG_BUILD_CODE_REPOSITORY="${CONFIG_BUILD_CODE_REPOSITORY:-NONE}" + CONFIG_BUILD_CODE_BRANCH="${CONFIG_BUILD_CODE_BRANCH:-NONE}" echo "Saving Customer Environment information..." echo "# Build Site Codebase." >> ${SETUP_FILE} echo "CONFIG_BUILD_PROFILE=\"${CONFIG_BUILD_PROFILE}\";" >> ${SETUP_FILE} diff --git a/bin/profiles/customer-environment.sh b/bin/profiles/customer-environment.sh index 57e51f5..e768182 100644 --- a/bin/profiles/customer-environment.sh +++ b/bin/profiles/customer-environment.sh @@ -11,7 +11,7 @@ BASE_ROOT=html GIT_REPOSITORY="${1:-'NONE'}" GIT_BRANCH="${2:-'NONE'}" -if [ $GIT_REPOSITORY != 'NONE' ] && [ $GIT_BRANCH != 'NONE' ] ; then +if [ $GIT_REPOSITORY == 'NONE' ] || [ $GIT_BRANCH == 'NONE' ] ; then echo "Using existing codebase from '${BASE_ROOT}'." echo "---------------------------------------------------" else From 3f6483c0ef0fc99f58ff76ecc74658e199ef9077 Mon Sep 17 00:00:00 2001 From: Alejandro Barrios Date: Tue, 18 May 2021 09:21:31 -0400 Subject: [PATCH 12/13] LCH-5000: Using port 9003 for Xdebug connections --- README.md | 2 +- bin/include/setup_publisher.sh | 2 +- bin/include/setup_subscriber.sh | 2 +- bin/templates/_examples/docker-compose-nfs-disabled.yml | 4 ++-- bin/templates/_examples/docker-compose-nfs_enabled.yml | 4 ++-- config/00_xdebug.conf | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 1263b39..1be82b4 100644 --- a/README.md +++ b/README.md @@ -200,7 +200,7 @@ lines: - ACH_HOSTNAME=https://plexus-dev.content-hub.acquia.com # These are your Xdebug parameters. - PHP_IDE_CONFIG=serverName=content-hub-farm_subscriber1_2 - - XDEBUG_CONFIG=remote_port=9000 remote_autostart=1 + - XDEBUG_CONFIG=remote_port=9003 remote_autostart=1 volumes: - html:/var/www/html ports: diff --git a/bin/include/setup_publisher.sh b/bin/include/setup_publisher.sh index fce8904..e174fef 100755 --- a/bin/include/setup_publisher.sh +++ b/bin/include/setup_publisher.sh @@ -30,7 +30,7 @@ while : ; do PHP_IDE_CONFIG_DEFAULT="serverName=${CONTENT_HUB_FARM}_publisher${COUNT}_1" CONFIG_PUB_PHP_IDE_CONFIG[$COUNT]="${CONFIG_PUB_PHP_IDE_CONFIG[$COUNT]:-${PHP_IDE_CONFIG_DEFAULT}}" read -p "XDEBUG_CONFIG: " CONFIG_PUB_XDEBUG_CONFIG[$COUNT] - XDEBUG_CONFIG_DEFAULT="remote_port=9000 remote_autostart=1" + XDEBUG_CONFIG_DEFAULT="remote_port=9003 remote_autostart=1" CONFIG_PUB_XDEBUG_CONFIG[$COUNT]="${CONFIG_PUB_XDEBUG_CONFIG[$COUNT]:-${XDEBUG_CONFIG_DEFAULT}}" diff --git a/bin/include/setup_subscriber.sh b/bin/include/setup_subscriber.sh index 0a8fc2e..cd2b540 100755 --- a/bin/include/setup_subscriber.sh +++ b/bin/include/setup_subscriber.sh @@ -31,7 +31,7 @@ while : ; do PHP_IDE_CONFIG_DEFAULT="serverName=${CONTENT_HUB_FARM}_subscriber${COUNT}_1" CONFIG_SUB_PHP_IDE_CONFIG[$COUNT]="${CONFIG_SUB_PHP_IDE_CONFIG[$COUNT]:-${PHP_IDE_CONFIG_DEFAULT}}" read -p "XDEBUG_CONFIG: " CONFIG_SUB_XDEBUG_CONFIG[$COUNT] - XDEBUG_CONFIG_DEFAULT="remote_port=9000 remote_autostart=1" + XDEBUG_CONFIG_DEFAULT="remote_port=9003 remote_autostart=1" CONFIG_SUB_XDEBUG_CONFIG[$COUNT]="${CONFIG_SUB_XDEBUG_CONFIG[$COUNT]:-${XDEBUG_CONFIG_DEFAULT}}" # Asking for verification. diff --git a/bin/templates/_examples/docker-compose-nfs-disabled.yml b/bin/templates/_examples/docker-compose-nfs-disabled.yml index 0363d95..c7b50a2 100644 --- a/bin/templates/_examples/docker-compose-nfs-disabled.yml +++ b/bin/templates/_examples/docker-compose-nfs-disabled.yml @@ -31,7 +31,7 @@ services: - PERSISTENT=true - ACH_CLIENT_NAME=publisher1-docker - PHP_IDE_CONFIG="serverName=content-hub-farm_publisher_1" - - XDEBUG_CONFIG=remote_port=9000 remote_autostart=1 + - XDEBUG_CONFIG=remote_port=9003 remote_autostart=1 volumes: - ./html:/var/www/html ports: @@ -51,7 +51,7 @@ services: - PERSISTENT=true - ACH_CLIENT_NAME=subscriber1-docker - PHP_IDE_CONFIG=serverName=content-hub-farm_subscriber1_1 - - XDEBUG_CONFIG=remote_port=9000 remote_autostart=1 + - XDEBUG_CONFIG=remote_port=9003 remote_autostart=1 volumes: - ./html:/var/www/html ports: diff --git a/bin/templates/_examples/docker-compose-nfs_enabled.yml b/bin/templates/_examples/docker-compose-nfs_enabled.yml index 5925382..4867ccd 100644 --- a/bin/templates/_examples/docker-compose-nfs_enabled.yml +++ b/bin/templates/_examples/docker-compose-nfs_enabled.yml @@ -31,7 +31,7 @@ services: - PERSISTENT=true - ACH_CLIENT_NAME=publisher1-docker - PHP_IDE_CONFIG="serverName=content-hub-farm_publisher_1" - - XDEBUG_CONFIG=remote_port=9000 remote_autostart=1 + - XDEBUG_CONFIG=remote_port=9003 remote_autostart=1 volumes: - type: volume source: nfsmount @@ -55,7 +55,7 @@ services: - PERSISTENT=true - ACH_CLIENT_NAME=subscriber1-docker - PHP_IDE_CONFIG=serverName=content-hub-farm_subscriber1_1 - - XDEBUG_CONFIG=remote_port=9000 remote_autostart=1 + - XDEBUG_CONFIG=remote_port=9003 remote_autostart=1 volumes: - type: volume source: nfsmount diff --git a/config/00_xdebug.conf b/config/00_xdebug.conf index 995cc3e..667a914 100644 --- a/config/00_xdebug.conf +++ b/config/00_xdebug.conf @@ -16,7 +16,7 @@ xdebug.remote_addr_header = host.docker.internal # --------------------------------------------------------------------------------------------------------------------- # If values are changed, you would need to rebuild the containers. -xdebug.remote_port = 9000 +xdebug.remote_port = 9003 # Setting up remote session to a max of 20min. Also check PHP and Nginx timeouts. xdebug.remote_timeout = 1200 From bc1373135ea6cb725b68521879db7e08dd3369ba Mon Sep 17 00:00:00 2001 From: Alejandro Barrios Date: Mon, 24 May 2021 17:40:07 -0400 Subject: [PATCH 13/13] LCH-5000: Adding DOCROOT detection to commands --- bin/commands/container/export-db.sh | 27 +++++++++++++++++++-------- bin/commands/container/test.sh | 17 ++++++++++++++--- bin/commands/internal/phpcbf.sh | 13 ++++++++++++- bin/commands/internal/phpcs.sh | 13 ++++++++++++- scripts/phpunit.sh | 17 ++++++++++++++--- 5 files changed, 71 insertions(+), 16 deletions(-) diff --git a/bin/commands/container/export-db.sh b/bin/commands/container/export-db.sh index 84c577a..2d43b92 100755 --- a/bin/commands/container/export-db.sh +++ b/bin/commands/container/export-db.sh @@ -1,5 +1,16 @@ #!/bin/bash +# Finding the DOCROOT... +# @TODO: Find a better way to find out the docroot. +if [ -d "html/docroot" ] +then + echo "Using directory 'docroot' as the DOCROOT..." + DOCROOT='docroot'; +else + echo "Using directory 'web' as the DOCROOT..." + DOCROOT='web'; +fi + # Provide help if "--help" is requested. if [[ $2 == "--help" ]]; then echo "" @@ -40,9 +51,9 @@ case "${FILE}" in # If it's gzipped. export_cmd() { if [ $PV ] ; then - docker exec -t -w /var/www/html/web ${CONTAINER} /usr/local/bin/drush.sh sql-dump | pv | gzip > ${TARGET_FILE} + docker exec -t -w /var/www/html/${DOCROOT} ${CONTAINER} /usr/local/bin/drush.sh sql-dump | pv | gzip > ${TARGET_FILE} else - docker exec -t -w /var/www/html/web ${CONTAINER} /usr/local/bin/drush.sh sql-dump | gzip > ${TARGET_FILE} + docker exec -t -w /var/www/html/${DOCROOT} ${CONTAINER} /usr/local/bin/drush.sh sql-dump | gzip > ${TARGET_FILE} fi } ;; @@ -51,9 +62,9 @@ case "${FILE}" in TARGET_FILE="${FILE%.*}.sql.gz" export_cmd() { if [ $PV ] ; then - docker exec -t -w /var/www/html/web ${CONTAINER} /usr/local/bin/drush.sh sql-dump | pv | gzip > ${TARGET_FILE} + docker exec -t -w /var/www/html/${DOCROOT} ${CONTAINER} /usr/local/bin/drush.sh sql-dump | pv | gzip > ${TARGET_FILE} else - docker exec -t -w /var/www/html/web ${CONTAINER} /usr/local/bin/drush.sh sql-dump | gzip > ${TARGET_FILE} + docker exec -t -w /var/www/html/${DOCROOT} ${CONTAINER} /usr/local/bin/drush.sh sql-dump | gzip > ${TARGET_FILE} fi } ;; @@ -61,9 +72,9 @@ case "${FILE}" in # it's a normal sql. export_cmd() { if [ $PV ] ; then - docker exec -t -w /var/www/html/web ${CONTAINER} /usr/local/bin/drush.sh sql-dump | pv > ${TARGET_FILE} + docker exec -t -w /var/www/html/${DOCROOT} ${CONTAINER} /usr/local/bin/drush.sh sql-dump | pv > ${TARGET_FILE} else - docker exec -t -w /var/www/html/web ${CONTAINER} /usr/local/bin/drush.sh sql-dump > ${TARGET_FILE} + docker exec -t -w /var/www/html/${DOCROOT} ${CONTAINER} /usr/local/bin/drush.sh sql-dump > ${TARGET_FILE} fi } ;; @@ -72,9 +83,9 @@ case "${FILE}" in TARGET_FILE="${FILE}.sql.gz" export_cmd() { if [ $PV ] ; then - docker exec -t -w /var/www/html/web ${CONTAINER} /usr/local/bin/drush.sh sql-dump | pv | gzip > ${TARGET_FILE} + docker exec -t -w /var/www/html/${DOCROOT} ${CONTAINER} /usr/local/bin/drush.sh sql-dump | pv | gzip > ${TARGET_FILE} else - docker exec -t -w /var/www/html/web ${CONTAINER} /usr/local/bin/drush.sh sql-dump | gzip > ${TARGET_FILE} + docker exec -t -w /var/www/html/${DOCROOT} ${CONTAINER} /usr/local/bin/drush.sh sql-dump | gzip > ${TARGET_FILE} fi } ;; diff --git a/bin/commands/container/test.sh b/bin/commands/container/test.sh index a69c8f1..9b32850 100755 --- a/bin/commands/container/test.sh +++ b/bin/commands/container/test.sh @@ -3,14 +3,25 @@ # Executes a phpunit test in the docker container. CONTAINER=$1 +# Finding the DOCROOT... +# @TODO: Find a better way to find out the docroot. +if [ -d "html/docroot" ] +then + echo "Using directory 'docroot' as the DOCROOT..." + DOCROOT='docroot'; +else + echo "Using directory 'web' as the DOCROOT..." + DOCROOT='web'; +fi + # Eliminating first argument to pass to command script. args="" for i in "$@" ; do if [ "$i" != "$1" ]; then - # Removing "html/web/" from the arguments. - i=${i//html\/web\//} + # Removing "html/${DOCROOT}/" from the arguments. + i=${i//html\/${DOCROOT}\//} args="${args} $i" fi done # Executing phpunit test. -docker exec -t -w /var/www/html/web $CONTAINER /usr/local/bin/phpunit.sh $args +docker exec -t -w /var/www/html/${DOCROOT} $CONTAINER /usr/local/bin/phpunit.sh $args diff --git a/bin/commands/internal/phpcbf.sh b/bin/commands/internal/phpcbf.sh index 6d68a76..adb164e 100755 --- a/bin/commands/internal/phpcbf.sh +++ b/bin/commands/internal/phpcbf.sh @@ -1,6 +1,17 @@ #!/bin/bash +# Finding the DOCROOT... +# @TODO: Find a better way to find out the docroot. +if [ -d "html/docroot" ] +then + echo "Using directory 'docroot' as the DOCROOT..." + DOCROOT='docroot'; +else + echo "Using directory 'web' as the DOCROOT..." + DOCROOT='web'; +fi + # Runs phpcs on the acquia_contenthub module. echo "Fixing Coding Standards for 'acquia_contenthub' module..." cd html -./vendor/bin/phpcbf --standard=Drupal web/modules/contrib/acquia_contenthub/src web/modules/contrib/acquia_contenthub/tests +./vendor/bin/phpcbf --standard=Drupal ${DOCROOT}/modules/contrib/acquia_contenthub/src ${DOCROOT}/modules/contrib/acquia_contenthub/tests diff --git a/bin/commands/internal/phpcs.sh b/bin/commands/internal/phpcs.sh index 37dfc71..685d61b 100755 --- a/bin/commands/internal/phpcs.sh +++ b/bin/commands/internal/phpcs.sh @@ -1,6 +1,17 @@ #!/bin/bash +# Finding the DOCROOT... +# @TODO: Find a better way to find out the docroot. +if [ -d "html/docroot" ] +then + echo "Using directory 'docroot' as the DOCROOT..." + DOCROOT='docroot'; +else + echo "Using directory 'web' as the DOCROOT..." + DOCROOT='web'; +fi + # Runs phpcs on the acquia_contenthub module. echo "Checking Coding Standards for 'acquia_contenthub' module..." cd html -./vendor/bin/phpcs -n --standard=Drupal web/modules/contrib/acquia_contenthub/src +./vendor/bin/phpcs -n --standard=Drupal ${DOCROOT}/modules/contrib/acquia_contenthub/src diff --git a/scripts/phpunit.sh b/scripts/phpunit.sh index 3af4b19..874499e 100755 --- a/scripts/phpunit.sh +++ b/scripts/phpunit.sh @@ -1,16 +1,27 @@ #!/bin/bash +# Finding the DOCROOT... +# @TODO: Find a better way to find out the docroot. +if [ -d "/var/www/html/docroot" ] +then + echo "Using directory 'docroot' as the DOCROOT..." + DOCROOT='docroot'; +else + echo "Using directory 'web' as the DOCROOT..." + DOCROOT='web'; +fi + # Setting up variables. DB_NAME=$(echo "${HOSTNAME//[-._]}" | awk -F'.' '{print $1}') #PHPUNIT=/var/www/html/vendor/bin/phpunit PHPUNIT=../vendor/bin/phpunit -#PHPUNIT_XML="/var/www/html/web/core/phpunit-${DB_NAME}.xml" +#PHPUNIT_XML="/var/www/html/${DOCROOT}/core/phpunit-${DB_NAME}.xml" PHPUNIT_XML="./core/phpunit-${DB_NAME}.xml" # Executing PHPUnit tests. -echo "Running test from DOCROOT=\"/var/www/html/web\":" +echo "Running test from DOCROOT=\"/var/www/html/${DOCROOT}\":" command="$PHPUNIT --color=always --stop-on-failure -c $PHPUNIT_XML $@" echo "Executing: \$$command" echo "" -cd /var/www/html/web || return +cd /var/www/html/${DOCROOT} || return $PHPUNIT --color=always --stop-on-failure -c $PHPUNIT_XML "$@"