Drush enable all inactive modules

I’ve been using make files a lot lately and when ever I’m ready to release an updated file I like to verify that all the project versions are up to date.
To leverage Drupal’s update functionality each project needs to be enabled. So I typically generate a new site from the make file and enable all the projects with drush. The key to that is the combination of commands:

drush en `drush pm-list --status="disabled,not installed" --pipe`

Here I’m enabling a list of module; specifically drush’s list of disabled and not installed modules.

drush pm-list --status="disabled,not installed"

That code gets you part of the way there. The addition of this:

--pipe

makes it a script-able list. Then when I surround that with back-ticks and feed it to

drush en `...`

I’m in business.

Here’s the break down of the drush commands I run in shell on my local machine:

  1. Create a site:
    drush quick-drupal {directory} --makefile={makefile.make}

    or

    drush make {makefile.make} {directory}
  2. Check for updates:
    drush pm-update #or drush up

    This will show me what projects need updates from the get-go.

  3. Then I list all the disabled or not installed projects:
    drush pm-list --status="disabled,not installed";
  4. Next I enable most disabled, not installed modules removing some known trouble makers from the list and replacing others; Notably the google_analytics needs to be referenced as googleanalytics:
    drush en `drush pm-list --status="disabled,not installed" --pipe | sed 's/migrate_example_oracle//g' | sed 's/services_oauth//g' | sed 's/rules_link_i18n//g' | sed 's/rules_i18n//g' | sed 's/ctools_plugin_example//g' | sed 's/google_analytics/googleanalytics/g'`;
  5. Then I dutifully acknowledge the prompts to download required modules and enable these.
  6. Rinse and repeat; Here I run that cmd again as some dependencies may still be disabled, not installed:
    drush en `drush pm-list --status="disabled,not installed" --pipe | sed 's/migrate_example_oracle//g' | sed 's/services_oauth//g' | sed 's/rules_link_i18n//g' | sed 's/rules_i18n//g' | sed 's/ctools_plugin_example//g' | sed 's/google_analytics/googleanalytics/g'`;
  7. Now I list all the disabled or not installed projects once more to see if we’ve taken care of everything: drush pm-list –status=”disabled,not installed”; # list disabled, not installed modules
  8. And finally I run
    drush update

    to see what updates are available. A nice little trick to use is to append –pipe so you only get the updates and you are not prompted to actually update the modules.

    drush up --pipe; # See what updates are required with newly enabled modules

    This works for me because I only want a clean list of up updates to make to my make file. I don’t need to update the disposable test site.

  9. Last I update the make file and release it

Here’s the list of commands in one fell swoop:

drush up; # See what updates are required with installed modules - update make file accordingly

drush pm-list --status="disabled,not installed"; # list disabled, not installed modules

drush en `drush pm-list --status="disabled,not installed" --pipe | sed 's/migrate_example_oracle//g' | sed 's/services_oauth//g' | sed 's/rules_link_i18n//g' | sed 's/rules_i18n//g' | sed 's/ctools_plugin_example//g' | sed 's/google_analytics/googleanalytics/g'`; # enable most disabled, not installed modules

drush en `drush pm-list --status="disabled,not installed" --pipe | sed 's/migrate_example_oracle//g' | sed 's/services_oauth//g' | sed 's/rules_link_i18n//g' | sed 's/rules_i18n//g' | sed 's/ctools_plugin_example//g' | sed 's/google_analytics/googleanalytics/g'`; # Run it again as some dependencies may still be disabled, not installed

drush pm-list --status="disabled,not installed"; # list disabled, not installed modules

drush up --pipe; # See what updates are required with newly enabled modules
Comments
Leave a Comment