I am working on decoupling the install task from the site creation process over at #2754069: API Only: Allow site nodes to specify "install_method", allowing something other than automated Drupal profile..

That issue is what is required to let us move forward with launching Drupal in anything other than the core LAMP stack, and is also required for us to start thinking about more native integration of other apps like Wordpress.

I've gotten the site's first verify task to put all the config into place and create the database. I can then install drupal with drush site-install or install.php.

I cannot, however, install it with drush provision-install or another install task, because of the classic obscure aegir error, PROVISION_SITE_INSTALLED.

So I dug in and found out why PROVISION_SITE_INSTALLED gets thrown. There are two functions in two different files.

It turns out that the script only checks for a readable sites/domain.com/settings.php file. it doesn't check anything else.

provision/platform/provision_drupal.drush.inc:

/**
 * Check that we are trying to install a new site , and a new site only
 */
function drush_provision_drupal_provision_install_validate() {
  if (!d()->uri) {
    return drush_set_error("PROVISION_URL_REQUIRED", dt("You need to specify a valid url to install a site"));
  }
  if (_provision_drupal_site_exists()) {
    return drush_set_error('PROVISION_SITE_INSTALLED', dt('This site has already been installed.'));
  }
}

And then a "helper" function (which is only ever used in drush_provision_drupal_provision_install_validate()) in

provision/platform/install.provision.inc:


/**
 * Test to see if the site settings.php exists
 *
 * @return
 *   If the file exists, return TRUE, else return FALSE.
 */
function _provision_drupal_site_exists() {
  return is_readable(d()->site_path . '/settings.php');
}

I am sure we have all seen this error. If you put an empty settings.php file in that location, aegir "thinks" the site is installed and complains to the user.

I propose we, instead, verify that a site was actually installed by testing drush bootstrap. We can also get rid of the unnecessary "helper function" _provision_drupal_site_exists();

New provision/platform/provision_drupal.drush.inc:

 */

/**
 * Check that we are trying to install a new site , and a new site only
 */
function drush_provision_drupal_provision_install_validate() {
  if (!d()->uri) {
    return drush_set_error("PROVISION_URL_REQUIRED", dt("You need to specify a valid url to install a site"));
  }
  if (drush_bootstrap_max() == DRUSH_BOOTSTRAP_DRUPAL_LOGIN) {
    return drush_set_error('PROVISION_SITE_INSTALLED', dt('This site has already been installed.'));
  }
}

I believe we should not just test connection to the database, but also try to make sure there is some data in the database.

It might not be best to test for DRUSH_BOOTSTRAP_DRUPAL_LOGIN. I do not yet know what would happen if there is an error in code or perhaps a bad database table, but fixing this check is going to be required for the efforts in #2754069: API Only: Allow site nodes to specify "install_method", allowing something other than automated Drupal profile..

Also note the much friendlier error message dt('This site has already been installed.').

CommentFileSizeAuthor
#2 2764245-provision-site-installed.patch1.28 KBJon Pugh
Members fund testing for the Drupal project. Drupal Association Learn more

Comments

Jon Pugh created an issue. See original summary.

Jon Pugh’s picture

Jon Pugh’s picture

Issue summary: View changes
helmo’s picture

Project: Hosting » Provision

Moving to the right queue.

I also opened a PR to try testing this... https://github.com/aegir-project/provision/pull/1/files
Travis support is not ready though.

Jon Pugh’s picture

Issue summary: View changes
Jon Pugh’s picture

helmo’s picture

Status: Needs review » Needs work