10

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.

7
$ 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.

| improve this answer | |
4

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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