import.provision.inc 1.97 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
<?php

/**
 * Provision import command
 *
 * Import existing drupal sites
 */


/**
 * Import the information about the existing site, and return it in the $data context array
 */
13
function drush_provision_drupal_provision_import() {
14 15 16 17 18 19 20 21 22
  if (d()->type === 'site') {
    drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_FULL);
    drush_include_engine('drupal', 'import', drush_drupal_major_version());
    drush_set_option('installed', TRUE, 'site');
  }
}

function drush_provision_drupal_post_provision_import() {
  if (d()->type === 'site') {
23 24 25 26 27 28 29 30 31
    if (drush_drupal_major_version() == 6) {
      d()->profile = drush_set_option('profile', drush_get_option('profile', 'default', 'site'));
    }
    elseif (drush_drupal_major_version() == 7) {
      d()->profile = drush_set_option('profile', drush_get_option('profile', 'standard', 'site'));
    }
    elseif (drush_drupal_major_version() >= 8) {
      d()->profile = drush_set_option('profile', \Drupal\Core\Site\Settings::get('install_profile', 'standard'), 'site');
    }
32
    d()->language = drush_set_option('language', drush_get_option('language', 'en', 'site'));
33
    d()->aliases = drush_set_option('aliases', provision_drupal_find_aliases());
34 35
    d()->write_alias();

36 37 38
    // set this in the site options too so it recurrs.
    drush_set_option('aliases', drush_get_option('aliases'),  'site');

39 40 41
    // generate the drushrc
    provision_save_site_data();

42 43 44
    // Do not automatically save the drushrc at the end of the command.
    drush_set_option('provision_save_config', false);

45
    // We still run this extra backend sub-task to properly register packages etc.
46
    provision_backend_invoke(d()->name, 'provision-verify');
47 48 49 50
    sleep(5); // A small trick to avoid high load and race conditions.

    // We run this extra verify via frontend to avoid issue #1004526.
    provision_backend_invoke('@hostmaster', 'hosting-task', array(d()->name, 'verify'), array('force' => TRUE));
omega8cc's avatar
omega8cc committed
51

52
    drush_include_engine('drupal', 'cron_key');
53 54

    provision_reload_config('site');
55
  }
56 57
}