install.provision.inc 1.96 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
<?php
/**
 * @file
 *   Provision hooks for the provision install command.
 */

/**
 * Provision install command
 *
 * These are the hooks that will be executed by the provision_invoke function
 * when doing a provision_install.
 */

/**
 * Check that we are trying to install a new site , and a new site only
 */
function provision_drupal_provision_install_validate() {
18
  if (drush_get_option('installed')) {
19
    drush_set_error('PROVISION_SITE_INSTALLED');
20
  }
21 22 23 24 25
}

/**
 * Set up the directories and settings.php file that we need.
 */
26
function provision_drupal_provision_pre_install($url) {
27
 // This is the actual drupal provisioning requirements. 
28
 _provision_drupal_create_directories($url);
29 30 31 32 33 34 35 36
}

/**
 * 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.
 */
37
function provision_drupal_provision_install($url) {
38
 // Requires at least the database settings to complete.
39
  _provision_drupal_create_settings_file($url);
40
  drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_SITE);
41
  provision_platform_include(dirname(__FILE__), 'install');
42
  drush_set_option('installed', TRUE, 'site');
43 44 45 46 47
}

/**
 * If the install went south, and the site is not PROVISION_SITE_INSTALLED, clean up behind ourselves
 */
48
function provision_drupal_provision_install_rollback($url) {
49
  if (!(drush_get_error() & PROVISION_SITE_INSTALLED)) {
50 51 52 53 54 55 56 57 58
    _provision_recursive_delete("sites/$url");
  }
}


/**
 * Finish the installation, regenerate the caches on the site so that
 * any changes to things such as available modules/ themes can take affect.
 */
59 60 61
function provision_drupal_provision_post_install($url) {
  drush_set_option('installed', TRUE, 'site');
  _provision_drupal_maintain_aliases($url);
62
  provision_path("chmod", "./sites/$url/settings.php", 0440, dt("Secured settings.php with safe permissions"));
63
  _provision_drupal_rebuild_caches($url);
64 65
}