Last active
May 26, 2026 14:44
-
-
Save efann/bcb7f60e111340466d65a2e793ece9e3 to your computer and use it in GitHub Desktop.
Simple bash script for updating Drupal 10 to Drupal 11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # License: Eclipse Public License - v 2.0 (https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html) | |
| # Updated on May 26, 2026 | |
| #------------------------------------------------------------------------------ | |
| function yesNoContinue { | |
| echo -e | |
| read -n 1 -p "Continue? (y/n): " choice | |
| if [[ ! "$choice" =~ ^[Yy]$ ]]; then | |
| echo -e "\nStopping script. . . .\n" | |
| exit 1 | |
| fi | |
| } | |
| #------------------------------------------------------------------------------ | |
| function checkThemes { | |
| echo -e "\n\nChecking for Adminimal theme which will not be ready for Drupal 11 in the near future." | |
| echo -e " We recommend using the Gin Admin Theme found at" | |
| echo -e " https://www.drupal.org/project/gin\n\n" | |
| results=$(composer show -N drupal/adminimal*)"\n"$(composer show -N drupal/seven*) | |
| if [[ "${results}" == *"drupal"* ]]; then | |
| echo -e "${results}\n\n" | |
| echo -e "Uninstall the following themes in the following order from the web GUI:\n" | |
| echo -e " Adminimal Child Theme" | |
| echo -e " Adminimal Theme" | |
| echo -e " Seven Theme" | |
| echo -e | |
| echo -e "Now from the command line, run the following:\n" | |
| echo -e " composer remove drupal/adminimal_theme" | |
| echo -e " which should remove both adminimal_theme and the seven theme" | |
| echo -e " rm -rf ./themes/custom/adminimal_child/" | |
| echo -e " as it wasn't installed using composer." | |
| echo -e "\n\nNow exiting so that you may resolve the above issues.\n\n" | |
| exit 1 | |
| else | |
| echo -e "\nThe Adminimal-related themes have been removed.\n\n" | |
| fi | |
| } | |
| #------------------------------------------------------------------------------ | |
| declare -r VENDOR_BIN_FOLDER="./vendor/bin" | |
| declare -r DRUSH="${VENDOR_BIN_FOLDER}/drush" | |
| "${DRUSH}" status | |
| checkThemes | |
| composer outdated "drupal/*" | |
| yesNoContinue | |
| #********************** | |
| echo -e "Removing other themes" | |
| "${DRUSH}" theme:uninstall bartik -y | |
| composer remove drupal/bartik | |
| echo -e "Removing devel module" | |
| "${DRUSH}" pm-uninstall devel -y | |
| composer remove drupal/devel | |
| echo -e "Removing other modules" | |
| "${DRUSH}" pm-uninstall color -y | |
| composer remove drupal/color | |
| "${DRUSH}" pm-uninstall js_cookie -y | |
| composer remove drupal/js_cookie | |
| "${DRUSH}" pm-uninstall quickedit -y | |
| composer remove drupal/quickedit | |
| "${DRUSH}" pm-uninstall rdf -y | |
| composer remove drupal/rdf | |
| "${DRUSH}" pm-uninstall legacy-project -y | |
| composer remove drupal/legacy-project | |
| echo -e "Installing drush 13" | |
| composer require 'drush/drush:^13' | |
| chmod +x ./vendor/bin/* | |
| chmod +x ./vendor/drush/drush/drush | |
| echo -e "\n\nShowing outdated status\n\n" | |
| composer outdated "drupal/*" | |
| echo -e "\n\nShowing composer why-not status\n\n" | |
| composer why-not drupal/core 11.3 | |
| yesNoContinue | |
| #********************** | |
| chmod u+w ./sites/default | |
| chmod u+w ./sites/default/*settings.php | |
| chmod u+w ./sites/default/*services.yml | |
| composer clear-cache | |
| # Need to update from 4.1 (Works with Drupal: ^10.3 || ^11 <11.2) | |
| # to | |
| # 5.0.12 (Works with Drupal: ^11.2) | |
| composer require 'drupal/gin:^5.0' --no-update | |
| composer require 'drupal/core-recommended:^11' 'drupal/core-composer-scaffold:^11' 'drupal/core-project-message:^11' --no-update | |
| composer remove drupal/core --no-update | |
| composer update --dry-run --with-all-dependencies | |
| echo -e "\n\nCompleted: composer update --dry-run\n\n" | |
| yesNoContinue | |
| #********************** | |
| composer update --with-all-dependencies | |
| composer install | |
| "${DRUSH}" cr | |
| "${DRUSH}" updatedb:status | |
| "${DRUSH}" updatedb -y | |
| echo -e "\n\nCompleted: If you get errors about legacy modules or themes, simply reinstall, then uninstall using drush, then remove using composer.\n" | |
| echo -e "For example, the bartik theme or drupal/tour\n" | |
| echo -e "\nAnd by removing the warnings about the modules/themes, database warnings disappear.\n\n" | |
| echo -e "\n\nNow run drupal-refresh.sh with -all option, which can be found in https://gist.github.com/efann\n\n" | |
| echo -e "\n\nWhen launching the website, if you get weird errors like TypeError: Cannot assign Symfony\Component\HttpFoundation\ParameterBag to property..." | |
| echo -e "Consider the solution found at https://www.drupal.org/project/bootstrap/issues/3522678" | |
| echo -e " drush sql-query \"SELECT * FROM key_value_expire WHERE collection LIKE 'theme:%:http';\"" | |
| echo -e " drush sql-query \"DELETE FROM key_value_expire WHERE collection LIKE 'theme:%:http';\"" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment