install.provision.inc 2.35 KB
Newer Older
1 2 3 4 5 6 7 8 9
<?php
/**
 * @file
 *   Provision hooks for the provision install command.
 */

/**
 * Provision install command
 *
10
 * These are the hooks that will be executed by the drush_invoke function
11 12 13 14 15 16
 * when doing a provision_install.
 */

/**
 * Check that we are trying to install a new site , and a new site only
 */
17 18
function drush_provision_drupal_provision_install_validate() {
  if (!drush_get_option('uri')) {
19 20
    return drush_set_error("PROVISION_URL_REQUIRED", dt("You need to specify a valid url to install a site"));
  }
21
  if (_provision_drupal_site_exists()) {
22
    return drush_set_error('PROVISION_SITE_INSTALLED');
23
  }
24 25 26 27 28
}

/**
 * Set up the directories and settings.php file that we need.
 */
29 30 31
function drush_provision_drupal_pre_provision_install() {
  // This is the actual drupal provisioning requirements. 
  _provision_drupal_create_directories();
32 33 34 35 36 37 38 39
}

/**
 * Install Drupal with the pre-configured settings, by calling an external script
 *
 * This is an external script so that php is running in it's own namespace, and
 * weird problems such as the multiple database connections don't confuse drupal.
 */
40
function drush_provision_drupal_provision_install() {
41
 // Requires at least the database settings to complete.
42
  provision_prepare_environment();
43
  _provision_drupal_create_settings_file();
44
  drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_SITE);
45

46
  drush_include_engine('drupal', 'install');
47
  drush_set_option('installed', TRUE, 'site');
48
  _provision_drupal_maintain_aliases();
49 50 51 52 53
}

/**
 * If the install went south, and the site is not PROVISION_SITE_INSTALLED, clean up behind ourselves
 */
54 55 56 57
function drush_provision_drupal_provision_install_rollback() {
  if (drush_get_option('uri')) {
    if (!_provision_drupal_site_installed()) {
      _provision_recursive_delete('sites/' drush_get_option('uri'));
58
    }
59 60
  } else {
    drush_set_error('PROVISION_FRAMEWORK_ERROR', dt('no url defined in %function', array('%function' => __FUNCTION__)));
61 62 63 64 65 66 67 68
  }
}


/**
 * Finish the installation, regenerate the caches on the site so that
 * any changes to things such as available modules/ themes can take affect.
 */
69
function drush_provision_drupal_post_provision_install() {
70
  drush_set_option('aliases', drush_get_option('aliases'), 'site');
71
  drush_set_option('installed', TRUE, 'site');
72
  _provision_drupal_rebuild_caches();
73
  drush_set_option('packages', _scrub_object(provision_drupal_system_map()), 'site');
74 75
}