Is there any way to use Drush to determine if Drupal is installed, and have it return true or false? The boolean output would be used elsewhere in a bash script's logic.

Bonus: it needs to work for both Drupal 7 and Drupal 8.

4 Answers 4

$ cd /path/to/drupal6or7or8
$ drush status bootstrap | grep -q Successful

Then, $? will be 0 if Drupal has been installed, or 1 if there is no site, or it does not have a database, or the site has not been installed.

  • This does not work anymore with Drush 12. What is recommended now?
    – klausi
    Oct 3, 2023 at 13:22

In addition to @greg_1_anderson answer, I'd like to add that that is sensitive to locale problems. Successful will be translated in the output from Drush. To work around this problem, I'd suggest this somewhat dirty workaround:

drush status bootstrap | grep -q $(drush php-eval 'if (function_exists("t")) echo t("Successful");') &> /dev/null;

As mentioned above, $? will be 0 if installed, higher if not.


For anyone looking for a like for like replacement for drush status bootstrap in Drush 12:

drush status --field=bootstrap
  • Upvoted. This is the way. Returns "Successful" if successful, otherwise blank. Mar 12 at 4:27
  • This is the correct solution thanks Apr 2 at 13:15

As of Drush 12 drush status bootstrap does not work anymore.

You can check if there is something in the config table instead:

drush sql-query 'SELECT 1 FROM config LIMIT 0,1' > /dev/null 2>&1

Return value 0 means Drupal is installed.

  • 1
    SELECT 1 or selecting a specific column name should be faster than SELECT *. Nov 29, 2023 at 9:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.