|
| 1 | +#!/usr/bin/env bash |
| 2 | +set -e |
| 3 | + |
| 4 | +# To be precise on the error message that matches the error this should address. |
| 5 | +ERROR_MESSAGE=$(drush watchdog:show --severity=Error --filter="InvalidArgumentException: A valid cache entry key is required" | awk '{print $6}') |
| 6 | + |
| 7 | +# If error message equals to "No such file or directory", then exit. |
| 8 | +if [[ $ERROR_MESSAGE == *'InvalidArgumentException'* ]]; then |
| 9 | + |
| 10 | + # Install Drupal Console. |
| 11 | + drupal_console_installed() { |
| 12 | + composer show 'drupal/console' | grep -q '/var/www/drupal/vendor/drupal/console' |
| 13 | + } |
| 14 | + if drupal_console_installed; then |
| 15 | + echo 'Package installed' |
| 16 | + else |
| 17 | + composer require drupal/console:~1.0 --prefer-dist --optimize-autoloader -W |
| 18 | + fi |
| 19 | + |
| 20 | + # Reinstall views |
| 21 | + enabled_view=`/var/www/drupal/vendor/drupal/console/bin/drupal debug:views --status='Enabled' | cut -d ' ' -f 2 | tail -n +2` |
| 22 | + for dis_view in $enabled_view; do |
| 23 | + echo "Disabling view $dis_view" |
| 24 | + /var/www/drupal/vendor/drupal/console/bin/drupal views:disable $dis_view |
| 25 | + done |
| 26 | + |
| 27 | + for en_view in $enabled_view; do |
| 28 | + echo "Reenabling view $en_view" |
| 29 | + /var/www/drupal/vendor/drupal/console/bin/drupal views:enable $en_view |
| 30 | + done |
| 31 | + |
| 32 | + # Install devel. |
| 33 | + devel_installed() { |
| 34 | + composer show 'drupal/devel' | grep -q '/var/www/drupal/web/modules/contrib/devel' |
| 35 | + } |
| 36 | + if devel_installed; then |
| 37 | + echo 'Package installed' |
| 38 | + else |
| 39 | + composer require 'drupal/devel:^4.1' -W |
| 40 | + fi |
| 41 | + drush pm:enable -y devel |
| 42 | + |
| 43 | + echo -e "\n\nThis will likely throw an error, but that's okay. It's just a patch.\n\n" |
| 44 | + { # try |
| 45 | + drush dev:reinstall -y islandora |
| 46 | + } || { # catch |
| 47 | + echo -e "\nIgnore these errors. This will fail if any content is already created.\n\n" |
| 48 | + } |
| 49 | + |
| 50 | + # Clear caches |
| 51 | + /var/www/drupal/vendor/drupal/console/bin/drupal cache:rebuild |
| 52 | + /var/www/drupal/vendor/drupal/console/bin/drupal cr all |
| 53 | + /var/www/drupal/vendor/drupal/console/bin/drupal node:access:rebuild |
| 54 | + drush cron |
| 55 | +fi |
0 commit comments