@@ -35,6 +35,14 @@ VORTEX_PROVISION_USE_MAINTENANCE_MODE="${VORTEX_PROVISION_USE_MAINTENANCE_MODE:-
3535# state before any updates ran (for example, DB caching in CI).
3636VORTEX_PROVISION_POST_OPERATIONS_SKIP=" ${VORTEX_PROVISION_POST_OPERATIONS_SKIP:- 0} "
3737
38+ # Provision database dump file.
39+ # If not set, it will be auto-discovered from the VORTEX_DB_DIR directory using
40+ # the VORTEX_DB_FILE name.
41+ VORTEX_PROVISION_DB=" ${VORTEX_PROVISION_DB:- } "
42+
43+ # Directory with custom provision scripts.
44+ VORTEX_PROVISION_SCRIPTS_DIR=" ${VORTEX_PROVISION_SCRIPTS_DIR:- ./ scripts/ custom} "
45+
3846# Name of the webroot directory with Drupal codebase.
3947WEBROOT=" ${WEBROOT:- web} "
4048
@@ -74,15 +82,19 @@ yesno() { [ "${1}" = "1" ] && echo "Yes" || echo "No"; }
7482
7583info " Started site provisioning."
7684
77- [ " ${VORTEX_PROVISION_SKIP} " = " 1" ] && pass " Skipped site provisioning as VORTEX_PROVISION_SKIP is set to 1. " && exit 0
78-
79- # Normalize the provision type.
80- VORTEX_PROVISION_TYPE= ${VORTEX_PROVISION_TYPE :- ' database ' }
81- case ${VORTEX_PROVISION_TYPE} in database | profile) ;; * ) VORTEX_PROVISION_TYPE= ' database ' ;; esac
85+ if [ " ${VORTEX_PROVISION_SKIP} " = " 1" ]; then
86+ pass " Skipped site provisioning as VORTEX_PROVISION_SKIP is set to 1. "
87+ info " Finished site provisioning. "
88+ exit 0
89+ fi
8290
83- # # Convert DB dir starting with './' to a full path.
91+ # Convert DB dir starting with './' to a full path.
8492[ " ${VORTEX_DB_DIR# ./ } " != " ${VORTEX_DB_DIR} " ] && VORTEX_DB_DIR=" $( pwd) ${VORTEX_DB_DIR# .} "
8593
94+ if [ -z " ${VORTEX_PROVISION_DB} " ]; then
95+ VORTEX_PROVISION_DB=" ${VORTEX_PROVISION_DB:- " ${VORTEX_DB_DIR} /${VORTEX_DB_FILE} " } "
96+ fi
97+
8698drush_version=" $( drush --version | cut -d' ' -f4) "
8799drupal_version=" $( drush status --field=drupal-version 2> /dev/null || echo " Unknown" ) "
88100site_is_installed=" $( drush status --fields=bootstrap 2> /dev/null | grep -q " Successful" && echo " 1" || echo " 0" ) "
@@ -92,9 +104,11 @@ if [ -z "${DRUPAL_CONFIG_PATH}" ]; then
92104 DRUPAL_CONFIG_PATH=" $( drush php:eval ' print realpath(\Drupal\Core\Site\Settings::get("config_sync_directory"));' ) "
93105 [ ! -d " ${DRUPAL_CONFIG_PATH} " ] && fail " Config directory \" ${DRUPAL_CONFIG_PATH:- <empty>} \" does not exist." && exit 1
94106fi
95-
96107site_has_config=" $( test " $( ls -1 ${DRUPAL_CONFIG_PATH} /* .yml 2> /dev/null | wc -l | tr -d ' ' ) " -gt 0 && echo " 1" || echo " 0" ) "
97108
109+ # Normalize the provision type.
110+ [ " ${VORTEX_PROVISION_TYPE} " = " profile" ] || VORTEX_PROVISION_TYPE=database
111+
98112# ###############################################################################
99113# Print provisioning information.
100114# ###############################################################################
@@ -107,7 +121,7 @@ note "Public files path : ${DRUPAL_PUBLIC_FILES-<empty>}"
107121note " Private files path : ${DRUPAL_PRIVATE_FILES-<empty>} "
108122note " Temporary files path : ${DRUPAL_TEMPORARY_FILES-<empty>} "
109123note " Config files path : ${DRUPAL_CONFIG_PATH} "
110- note " DB dump file path : ${VORTEX_DB_DIR} / ${VORTEX_DB_FILE} ($( [ -f " ${VORTEX_DB_DIR} / ${VORTEX_DB_FILE }" ] && echo " present" || echo " absent" ) )"
124+ note " DB dump file path : ${VORTEX_PROVISION_DB} ($( [ -f " ${VORTEX_PROVISION_DB } " ] && echo " present" || echo " absent" ) )"
111125if [ -n " ${VORTEX_DB_IMAGE:- } " ]; then
112126 note " DB dump container image : ${VORTEX_DB_IMAGE} "
113127fi
@@ -128,17 +142,17 @@ echo
128142# Provision site by importing the database from the dump file.
129143#
130144provision_from_db () {
131- if [ ! -f " ${VORTEX_DB_DIR} / ${VORTEX_DB_FILE }" ]; then
145+ if [ ! -f " ${VORTEX_PROVISION_DB } " ]; then
132146 echo
133147 fail " Unable to import database from file."
134- note " Dump file ${VORTEX_DB_DIR} / ${VORTEX_DB_FILE } does not exist."
148+ note " Dump file ${VORTEX_PROVISION_DB } does not exist."
135149 note " Site content was not changed."
136150 exit 1
137151 fi
138152
139153 drush sql:drop
140154
141- drush sql:cli < " ${VORTEX_DB_DIR} / ${VORTEX_DB_FILE }"
155+ drush sql:cli < " ${VORTEX_PROVISION_DB } "
142156
143157 pass " Imported database from the dump file."
144158}
@@ -177,7 +191,7 @@ provision_from_profile() {
177191# sufficient output for debugging.
178192if [ " ${VORTEX_PROVISION_TYPE} " = " database" ]; then
179193 info " Provisioning site from the database dump file."
180- note " Dump file path: ${VORTEX_DB_DIR} / ${VORTEX_DB_FILE }"
194+ note " Dump file path: ${VORTEX_PROVISION_DB } "
181195
182196 if [ " ${site_is_installed} " = " 1" ]; then
183197 note " Existing site was found when provisioning from the database dump file."
@@ -292,10 +306,10 @@ else
292306fi
293307
294308# Run custom provision scripts.
295- # The files should be located in "./scripts/custom/" directory
296- # and must have "provision-" prefix and ".sh" extension.
297- if [ -d " ./scripts/custom " ]; then
298- for file in ./scripts/custom /provision-* .sh; do
309+ # The files should be located in VORTEX_PROVISION_SCRIPTS_DIR directory,
310+ # must have "provision-" prefix and ".sh" extension.
311+ if [ -d " ${VORTEX_PROVISION_SCRIPTS_DIR} " ]; then
312+ for file in " ${VORTEX_PROVISION_SCRIPTS_DIR} " /provision-* .sh; do
299313 if [ -f " ${file} " ]; then
300314 task " Running custom post-install script '${file} '."
301315 echo
0 commit comments