| 1 |
<?php
|
| 2 |
/**
|
| 3 |
* @file
|
| 4 |
* Provision hooks for the provision install command.
|
| 5 |
*/
|
| 6 |
|
| 7 |
/**
|
| 8 |
* Provision install command
|
| 9 |
*
|
| 10 |
* These are the hooks that will be executed by the drush_invoke function
|
| 11 |
* when doing a provision_install.
|
| 12 |
*/
|
| 13 |
|
| 14 |
/**
|
| 15 |
* Check that we are trying to install a new site , and a new site only
|
| 16 |
*/
|
| 17 |
function drush_provision_drupal_provision_install_validate($url) {
|
| 18 |
if (!$url) {
|
| 19 |
return drush_set_error("PROVISION_URL_REQUIRED", dt("You need to specify a valid url to install a site"));
|
| 20 |
}
|
| 21 |
if (drush_get_option('installed')) {
|
| 22 |
drush_set_error('PROVISION_SITE_INSTALLED');
|
| 23 |
}
|
| 24 |
}
|
| 25 |
|
| 26 |
/**
|
| 27 |
* Set up the directories and settings.php file that we need.
|
| 28 |
*/
|
| 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 |
* Install Drupal with the pre-configured settings, by calling an external script
|
| 36 |
*
|
| 37 |
* This is an external script so that php is running in it's own namespace, and
|
| 38 |
* weird problems such as the multiple database connections don't confuse drupal.
|
| 39 |
*/
|
| 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 |
* If the install went south, and the site is not PROVISION_SITE_INSTALLED, clean up behind ourselves
|
| 53 |
*/
|
| 54 |
function drush_provision_drupal_provision_install_rollback($url) {
|
| 55 |
if (!drush_cmp_error('PROVISION_SITE_INSTALLED')) {
|
| 56 |
if ($url) {
|
| 57 |
_provision_recursive_delete("sites/$url");
|
| 58 |
} else {
|
| 59 |
drush_set_error('PROVISION_FRAMEWORK_ERROR', dt('no url defined in %function', array('%function' => __FUNCTION__)));
|
| 60 |
}
|
| 61 |
}
|
| 62 |
}
|
| 63 |
|
| 64 |
|
| 65 |
/**
|
| 66 |
* Finish the installation, regenerate the caches on the site so that
|
| 67 |
* any changes to things such as available modules/ themes can take affect.
|
| 68 |
*/
|
| 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 |
#_provision_drupal_rebuild_caches($url);
|
| 74 |
#drush_set_option('packages', _scrub_object(provision_drupal_system_map()), 'site');
|
| 75 |
}
|
| 76 |
|