diff --git a/drupal-operations-scripts/check-if-installed.sh b/drupal-operations-scripts/check-if-installed.sh new file mode 100755 index 0000000000000000000000000000000000000000..61f95ec7d29ab8980b71fcfec0212b2a3d7dd565 --- /dev/null +++ b/drupal-operations-scripts/check-if-installed.sh @@ -0,0 +1,16 @@ +#!/bin/sh +set -exu + +# Change working directory to the drupal code +cd /app + +# Check if Drupal site is installed +echo "Checking if Drupal site is installed" +drush status bootstrap | grep -q Successful + +# Make sure we get a successful response + if [$? -ne 0]; then + echo "Drupal is not installed" >&2 + exit 1 + fi + exit 0 diff --git a/drupal-operations-scripts/clear-cache.sh b/drupal-operations-scripts/clear-cache.sh new file mode 100755 index 0000000000000000000000000000000000000000..c25d751627aa9c87f3149eec1422307ffa9ea030 --- /dev/null +++ b/drupal-operations-scripts/clear-cache.sh @@ -0,0 +1,9 @@ +#!/bin/sh +set -exu + +# Change working directory to the drupal code +cd /app + +# Clean cache +echo "Cleaning cache" +drush cr diff --git a/drupal-operations-scripts/clone.sh b/drupal-operations-scripts/clone.sh new file mode 100755 index 0000000000000000000000000000000000000000..65499ecd9cfc1a44309240ce0b05249f0fcdad1c --- /dev/null +++ b/drupal-operations-scripts/clone.sh @@ -0,0 +1,10 @@ +#!/bin/sh +set -exu + +# Change working directory to the drupal code +cd /app + +# Clone data from source to destination +rsync -av /drupal-data-source/ /drupal-data +/scripts/database-restore.sh +/scripts/clear-cache.sh diff --git a/drupal-operations-scripts/database-backup.sh b/drupal-operations-scripts/database-backup.sh new file mode 100755 index 0000000000000000000000000000000000000000..9d2a22045f55e298c23b8c1a1a858202dffa6898 --- /dev/null +++ b/drupal-operations-scripts/database-backup.sh @@ -0,0 +1,9 @@ +#!/bin/sh +set -exu + +# Change working directory to the drupal code +cd /app + +# Database backup +echo "Database backup" +drush sql-dump > /drupal-data/dbdump.sql diff --git a/drupal-operations-scripts/database-restore.sh b/drupal-operations-scripts/database-restore.sh new file mode 100755 index 0000000000000000000000000000000000000000..a067561d8af5711f9d0e7d0b28dba7f60bba5931 --- /dev/null +++ b/drupal-operations-scripts/database-restore.sh @@ -0,0 +1,13 @@ +#!/bin/sh +set -exu + +# Change working directory to the drupal code +cd /app + +# Database drop +echo "Database drop" +drush sql-drop -y + +# Database restore +echo "Database restore" +`drush sql-connect` < /drupal-data/dbdump.sql diff --git a/drupal-operations-scripts/disable-maintenance-mode.sh b/drupal-operations-scripts/disable-maintenance-mode.sh new file mode 100755 index 0000000000000000000000000000000000000000..b13076cb92475d04d526559cbfd071fc6051c2b6 --- /dev/null +++ b/drupal-operations-scripts/disable-maintenance-mode.sh @@ -0,0 +1,10 @@ +#!/bin/sh +set -exu + +# Change working directory to the drupal code +cd /app + +# Disable maintenance mode +echo "Disabling maintenance mode" +drush state:set system.maintenance_mode 0 --input-format=integer +drush cache:rebuild diff --git a/drupal-operations-scripts/enable-maintenance-mode.sh b/drupal-operations-scripts/enable-maintenance-mode.sh new file mode 100755 index 0000000000000000000000000000000000000000..744fe0f6a2de1c3d143bdb23713824a4c1e8b609 --- /dev/null +++ b/drupal-operations-scripts/enable-maintenance-mode.sh @@ -0,0 +1,10 @@ +#!/bin/sh +set -exu + +# Change working directory to the drupal code +cd /app + +# Enable maintenance mode +echo "Enabling maintenance mode" +drush state:set system.maintenance_mode 1 --input-format=integer +drush cache:rebuild diff --git a/drupal-operations-scripts/site-install.sh b/drupal-operations-scripts/site-install.sh new file mode 100755 index 0000000000000000000000000000000000000000..8cd6ba6dcfa0756c575596815514774052957d96 --- /dev/null +++ b/drupal-operations-scripts/site-install.sh @@ -0,0 +1,9 @@ +#!/bin/sh +set -exu + +# Change working directory to the drupal code +cd /app + +# Install Drupal site +echo "Installing Drupal site" +drush site-install -y --config-dir=../config/sync --account-name=admin --account-pass=pass --account-mail=admin@example.com diff --git a/generate-pipeline.sh b/generate-pipeline.sh index e1785dc213e0dff5ee028b7dc0a70505ed6e77de..839460352f03e0dabb1d918cd4fd74872b1807bd 100755 --- a/generate-pipeline.sh +++ b/generate-pipeline.sh @@ -69,9 +69,6 @@ job_site_${versionName##*/}: - export drushVersion=`/yq e .variables.drushVersion $versionName` - wget https://gitlab.cern.ch/drupal/paas/composer-drupal-project/-/archive/\${drupalDistroRefspec}/composer-drupal-project-\${drupalDistroRefspec}.tar; - tar xf composer-drupal-project-\${drupalDistroRefspec}.tar; - - wget https://gitlab.cern.ch/drupal/paas/drupal-operations/-/archive/master/drupal-operations-master.tar?path=scripts - - tar xf drupal-operations-master.tar?path=scripts - - mv drupal-operations-master-scripts/scripts drupal-operations-scripts - mv composer-drupal-project-\${drupalDistroRefspec} cern-drupal-distribution; - /kaniko/executor --context \$CI_PROJECT_DIR --dockerfile \$CI_PROJECT_DIR/Dockerfile --destination \$CI_REGISTRY_IMAGE/site-builder-base:${versionName##*/}\$IMAGE_DESTINATION_EXTENSION