From 00ce8ea02cdc74ad439963978ad81902995f5726 Mon Sep 17 00:00:00 2001 From: Dimitra Chatzichrysou <dimitra.chatzichrysou@cern.ch> Date: Wed, 24 Mar 2021 17:38:04 +0100 Subject: [PATCH] Add scripts for drupal operations --- scripts/check-if-installed..sh | 16 ++++++++++++++++ scripts/clear-cache.sh | 9 +++++++++ scripts/database-backup.sh | 9 +++++++++ scripts/database-restore.sh | 13 +++++++++++++ scripts/disable-maintenance-mode.sh | 10 ++++++++++ scripts/enable-maintenance-mode.sh | 10 ++++++++++ scripts/site-install.sh | 9 +++++++++ 7 files changed, 76 insertions(+) create mode 100644 scripts/check-if-installed..sh create mode 100755 scripts/clear-cache.sh create mode 100755 scripts/database-backup.sh create mode 100755 scripts/database-restore.sh create mode 100755 scripts/disable-maintenance-mode.sh create mode 100755 scripts/enable-maintenance-mode.sh create mode 100644 scripts/site-install.sh diff --git a/scripts/check-if-installed..sh b/scripts/check-if-installed..sh new file mode 100644 index 0000000..9f4787a --- /dev/null +++ b/scripts/check-if-installed..sh @@ -0,0 +1,16 @@ +#!/bin/bash +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/scripts/clear-cache.sh b/scripts/clear-cache.sh new file mode 100755 index 0000000..a8ce047 --- /dev/null +++ b/scripts/clear-cache.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -exu + +# Change working directory to the drupal code +cd /app + +# Clean cache +echo "Cleaning cache" +drush cr diff --git a/scripts/database-backup.sh b/scripts/database-backup.sh new file mode 100755 index 0000000..076a530 --- /dev/null +++ b/scripts/database-backup.sh @@ -0,0 +1,9 @@ +#!/bin/bash +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/scripts/database-restore.sh b/scripts/database-restore.sh new file mode 100755 index 0000000..74f838a --- /dev/null +++ b/scripts/database-restore.sh @@ -0,0 +1,13 @@ +#!/bin/bash +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/scripts/disable-maintenance-mode.sh b/scripts/disable-maintenance-mode.sh new file mode 100755 index 0000000..98f5653 --- /dev/null +++ b/scripts/disable-maintenance-mode.sh @@ -0,0 +1,10 @@ +#!/bin/bash +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/scripts/enable-maintenance-mode.sh b/scripts/enable-maintenance-mode.sh new file mode 100755 index 0000000..b1ebc31 --- /dev/null +++ b/scripts/enable-maintenance-mode.sh @@ -0,0 +1,10 @@ +#!/bin/bash +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/scripts/site-install.sh b/scripts/site-install.sh new file mode 100644 index 0000000..3b707db --- /dev/null +++ b/scripts/site-install.sh @@ -0,0 +1,9 @@ +#!/bin/bash +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 -- GitLab