diff --git a/db_server/delete.provision.inc b/db_server/delete.provision.inc index 67e2cf89485f2a582f52351099e43bb773258328..4f0888836b978499a3113293e837d12c381f0973 100644 --- a/db_server/delete.provision.inc +++ b/db_server/delete.provision.inc @@ -2,7 +2,9 @@ function drush_provision_mysql_provision_delete_validate() { - provision_db_connect(); + if (PROVISION_CONTEXT_SITE) { + provision_db_connect(); + } } /** @@ -11,6 +13,7 @@ function drush_provision_mysql_provision_delete_validate() { * This will drop the database, revoke the privileges and flush the privileges. */ function drush_provision_mysql_provision_delete($url = NULL) { - return _provision_mysql_destroy_site_db(drush_get_option('db_name'), drush_get_option('db_user'), drush_get_option('db_passwd')); + if (PROVISION_CONTEXT_SITE) { + return _provision_mysql_destroy_site_db(drush_get_option('db_name'), drush_get_option('db_user'), drush_get_option('db_passwd')); + } } - diff --git a/platform/delete.provision.inc b/platform/delete.provision.inc index 1b1581521f91fa8991faaabc4c5d595a181f3ef1..ba28f281b8e60f287a20b4c401d132cd6bbe90d5 100644 --- a/platform/delete.provision.inc +++ b/platform/delete.provision.inc @@ -2,29 +2,45 @@ function drush_provision_drupal_provision_delete_validate($url = NULL, $backup_file = NULL) { - _provision_drupal_valid_site(); + if (PROVISION_CONTEXT_SITE) { + _provision_drupal_valid_site(); + } } - /** * Before starting to delete the site, make a backup */ -function drush_provision_drupal_pre_provision_delete($url, $backup_file = NULL) { - drush_set_option('force', true, 'process'); - drush_invoke("provision-backup", $url, $backup_file); - drush_unset_option('force', 'process'); +function drush_provision_drupal_pre_provision_delete($url = NULL, $backup_file = NULL) { + if (PROVISION_CONTEXT_SITE) { + drush_set_option('force', true, 'process'); + drush_invoke("provision-backup", $url, $backup_file); + drush_unset_option('force', 'process'); + } } /** - * Remove any directories for the site in sites + * If we're deleting a site, remove any directories for the site in sites folder + * If we're deleting a platform, remove the whole platform * This can't be rolled back. so won't even try. */ -function drush_provision_drupal_provision_delete($url) { - _provision_recursive_delete(drush_get_option('sites_path') . "/$url"); - // we remove the aliases even if redirection is enabled as a precaution - // if redirection is enabled, keep silent about errors - _provision_drupal_delete_aliases(drush_get_option('aliases', array()), drush_get_option('redirection')); - drush_set_option('installed', FALSE, 'site'); +function drush_provision_drupal_provision_delete($url = NULL) { + if (PROVISION_CONTEXT_SITE) { + _provision_recursive_delete(drush_get_option('sites_path') . "/$url"); + // we remove the aliases even if redirection is enabled as a precaution + // if redirection is enabled, keep silent about errors + _provision_drupal_delete_aliases(drush_get_option('aliases', array()), drush_get_option('redirection')); + drush_set_option('installed', FALSE, 'site'); + } + if (PROVISION_CONTEXT_PLATFORM) { + $sites = provision_drupal_find_sites(); + if($sites) { + drush_set_error(dt('Existing sites were found on this platform. These sites will need to be deleted before this platform can be deleted.')); + } + else { + $drupal_root = drush_get_context('DRUSH_DRUPAL_ROOT'); + _provision_recursive_delete($drupal_root); + } + } } diff --git a/platform/provision_drupal.drush.inc b/platform/provision_drupal.drush.inc index 2de5e375bdda6724c8a267b3f2168dcb78c3b989..76e521ee7e353fbfaea2503e8a4fe380623d48fd 100644 --- a/platform/provision_drupal.drush.inc +++ b/platform/provision_drupal.drush.inc @@ -87,7 +87,10 @@ function provision_drupal_drush_exit($url = NULL) { } } else { - _provision_generate_config(); + // Generate a drushrc.php for the platform unless it's being deleted + if (!preg_match("/^provision-delete/", $command[0])) { + _provision_generate_config(); + } } } } diff --git a/provision.drush.inc b/provision.drush.inc index e55cfbe4bbd14b1b8cfa8fc1cab3766a0b2ebd0b..5a42d2b562b0e19c378ba2f8143451af05ecf0b5 100644 --- a/provision.drush.inc +++ b/provision.drush.inc @@ -22,13 +22,18 @@ * or used for an upgrade. * disable - Disable an installed Drupal site. Changes the virtual host config file so that it redirects to provision_disabled_site_redirect_url * enable - Re-enable a site that has already been disabled. Recreates the virtual host file. - * delete - Generates a back up of the site, and then removes all references to it. + * delete - In a site context: generates a back up of the site, and then removes all references to it. + * In a platform context: removes the platform and its vhost config from the server if no sites are currently running on it * restore - Revert to a previous backup of the site. * * deploy - Accepts a site package (backup) as argument, and redeploys it, running the upgrade processes on it. * Uses hook_provision_pre_upgrade(), hook_provision_upgrade() and hook_provision_post_upgrade() hooks, * and allows clean roll back if any errors occur. Will include stringent checking of module versions, * and allow unit tests to be run. + * lock - Lock a platform so that sites cannot be provisioned on it. This does not disable or delete the platform + * nor any sites currently provisioned on it. + * unlock - Unlock a platform so that sites can be provisioned on it. + * * login_reset - Generate a one-time login reset URL. * * Not implemented yet : @@ -98,6 +103,16 @@ function provision_drush_command() { 'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT ); + $items['provision-lock'] = array( + 'description' => 'Lock a platform from having any other sites provisioned on it.', + 'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT + ); + + $items['provision-unlock'] = array( + 'description' => 'Unlock a platform so that sites can be provisioned on it.', + 'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT + ); + $items['provision-verify'] = array( 'arguments' => array('domain.com' => dt('The domain of the site to verify).')), 'description' => 'Verify that the provisioning framework is correctly installed.', diff --git a/web_server/delete.provision.inc b/web_server/delete.provision.inc index 8dca268de919a4d6b725c1c9d64f3b3719882da2..4a82bfa847aa9256d345d3c5ffe8ba9a2be940d0 100644 --- a/web_server/delete.provision.inc +++ b/web_server/delete.provision.inc @@ -1,7 +1,19 @@