install.provision.inc 2.45 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 19 20
function drush_provision_drupal_provision_install_validate($url) {
  if (!$url) {
    return drush_set_error("PROVISION_URL_REQUIRED", dt("You need to specify a valid url to install a site"));
  }
mig5's avatar
mig5 committed
21 22
  if (_provision_drupal_site_installed($url)) {
    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
function drush_provision_drupal_pre_provision_install($url) {
30
 // This is the actual drupal provisioning requirements. 
31
 _provision_drupal_create_directories($url);
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($url) {
41
 // Requires at least the database settings to complete.
42
  provision_prepare_environment();
43
  _provision_drupal_create_settings_file($url);
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($url);
49 50 51 52 53
}

/**
 * If the install went south, and the site is not PROVISION_SITE_INSTALLED, clean up behind ourselves
 */
54
function drush_provision_drupal_provision_install_rollback($url) {
mig5's avatar
mig5 committed
55 56
  if ($url) {
    if (!_provision_drupal_site_installed($url)) {
57 58
      _provision_recursive_delete("sites/$url");
    }
mig5's avatar
mig5 committed
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($url) {
70
  drush_set_option('aliases', drush_get_option('aliases'), 'site');
71
  drush_set_option('installed', TRUE, 'site');
72
  provision_path("chmod", "./sites/$url/settings.php", 0440, dt("Secured settings.php with safe permissions"));
73 74
  #_provision_drupal_rebuild_caches($url);
  #drush_set_option('packages', _scrub_object(provision_drupal_system_map()), 'site');
75 76
}