Created
November 4, 2020 21:16
-
-
Save AllieRays/30f9255cef00ef8bebfcec3313ae6b1c to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
# | |
# Factory Hook: post-staging-update | |
# factory-hooks/post-site-install/02-setup-cohesion.sh | |
# Run Site Studio commands after executing | |
SITEGROUP="$1" | |
ENVIRONMENT="$2" | |
DB_ROLE="$3" | |
DOMAIN="$4" | |
echo "sitegroup: $SITEGROUP" | |
echo "env: $ENVIRONMENT" | |
echo "db role: $DB_ROLE" | |
echo "domain: $DOMAIN" | |
# Drush executable: | |
drush="/mnt/www/html/$SITEGROUP.$ENVIRONMENT/vendor/bin/drush" | |
# Create and set Drush cache to unique local temporary storage per site. | |
# This approach isolates drush processes to completely avoid race conditions | |
# that persist after initial attempts at addressing in BLT: https://github.com/acquia/blt/pull/2922 | |
cache_dir=`/usr/bin/env php /mnt/www/html/$SITEGROUP.$ENVIRONMENT/vendor/acquia/blt/scripts/blt/drush/cache.php $SITEGROUP $ENVIRONMENT $DOMAIN` | |
echo "Generated temporary Drush cache directory: $cache_dir." | |
echo "Initializing Acquia Cohesion tasks on $DOMAIN domain in $ENVIRONMENT environment on the $SITEGROUP subscription." | |
# Import cohesion. | |
DRUSH_PATHS_CACHE_DIRECTORY="$cache_dir" /usr/local/php7.3/bin/php -d memory_limit=1024M $drush -l $DOMAIN cohesion:import | |
result=$? | |
# Import cohesion package. | |
DRUSH_PATHS_CACHE_DIRECTORY="$cache_dir" /usr/local/php7.3/bin/php -d memory_limit=1024M $drush -l $DOMAIN sync:import --overwrite-all --force | |
# Import SCC cohesion packages from installed modules. | |
DRUSH_PATHS_CACHE_DIRECTORY="$cache_dir" /usr/local/php7.3/bin/php -d memory_limit=1024M $drush -l $DOMAIN scc_cohesion:import | |
# Rebuild cohesion. | |
DRUSH_PATHS_CACHE_DIRECTORY="$cache_dir" /usr/local/php7.3/bin/php -d memory_limit=1024M $drush -l $DOMAIN cohesion:rebuild | |
# Clear the cache. | |
DRUSH_PATHS_CACHE_DIRECTORY="$cache_dir" /usr/local/php7.3/bin/php -d memory_limit=1024M $drush -l $DOMAIN cache:rebuild | |
# Clear the external cache (Varnish). | |
DRUSH_PATHS_CACHE_DIRECTORY="$cache_dir" /usr/local/php7.3/bin/php -d memory_limit=1024M $drush -l $DOMAIN cache:rebuild-external --yes | |
# Clean up the drush cache directory. | |
echo "Removing temporary drush cache files." | |
rm -rf "$cache_dir" | |
set +v | |
# @todo Exit with the status of the Drush commmand. If the exit status is non-zero, | |
# Site Factory will send a notification of a partiolly failed install and will | |
# stop executing any further post-site-install hook scripts that would be in | |
# this directory (and get executed in alphabetical order). | |
exit $result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi! I have some points, if you could help me to understand:
Why only save the result from the cohesion:import and not validate all the steps and throw errors before tried to other steps?
And I found an issue on the sync:import that he does not properly throw the exit code when fails to import a component.
Best regards,