-
Notifications
You must be signed in to change notification settings - Fork 6
/
drupal-update.sh
executable file
·57 lines (50 loc) · 1.72 KB
/
drupal-update.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
## Commands that must be run to update a drupal instance.
## Use as `./drupal-update.sh`
echo $BASH_VERSION
set -o errexit -euo pipefail -o noclobber -o nounset
ROOT="${BASH_SOURCE%/*}/web"
cd $ROOT;
echo "Current working directory is ${PWD}"
# Put the site in maintenance mode.
printf "Enabling maintenance mode...\n"
../vendor/drush/drush/drush cache:rebuild;
../vendor/drush/drush/drush state:set system.maintenance_mode 1 --input-format=integer;
# Clear cache
printf "Clearing cache...\n"
../vendor/drush/drush/drush cache:rebuild;
# Run db updates.
printf "Running database updates...\n"
../vendor/drush/drush/drush updb -y;
## CONFIG IMPORT
printf "Importing config...\n"
counter=1;
# Check that there's no remaining config diff.
until ../vendor/drush/drush/drush --quiet --no config:import &> /dev/null
do
if [ $counter -gt 5 ]; then
echo "Config successfully imported after #$counter tries"
break
fi
echo "Trying import: #$counter"
# This import is allowed to fail.
../vendor/drush/drush/drush config:import -y || true
((counter++))
sleep 1;
done
# Run config import a second time to avoid installed
# module config overriding saved config.
printf "Re-importing config...\n"
../vendor/drush/drush/drush config:import -y
# To doubly make sure drush registers features commands.
printf "Clearing drush caches...\n"
../vendor/drush/drush/drush cache:clear drush;
# Revert all features
printf "Reverting features...\n"
../vendor/drush/drush/drush features:import:all -y;
# Take the site out of maintenance mode.
printf "Disabling maintenance mode...\n"
../vendor/drush/drush/drush state:set system.maintenance_mode 0;
# Clear cache.
printf "Clearing final cache...\n"
../vendor/drush/drush/drush cache:rebuild;