Commit 088d0e54 authored by anarcat's avatar anarcat Committed by anarcat

reimport mig5's dev-platform_management cleanly

this branch was originally forked off an old git repository from when we
were still on CVS. it was never rebased properly off the new repository
and therefore had a complete duplicate of the history, so I had to
delete the branch and reimported it as a single patch since it's not so
big.
parent 011d18b3
......@@ -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'));
}
}
......@@ -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);
}
}
}
......@@ -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();
}
}
}
}
......
......@@ -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.',
......
<?php
function drush_provision_apache_provision_delete($url = NULL) {
_provision_apache_delete_vhost_config($url);
if (PROVISION_CONTEXT_SITE) {
_provision_apache_delete_vhost_config($url);
}
if (PROVISION_CONTEXT_PLATFORM) {
$options = drush_get_merged_options();
$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 {
_provision_apache_delete_config('platform_' . $options['platform'] . '.conf');
}
}
return _provision_apache_restart_apache();
}
......@@ -216,6 +216,12 @@ function _provision_apache_create_config($file, $data, $template) {
}
}
function _provision_apache_delete_config($file) {
provision_path("unlink", drush_get_option('vhost_path') ."/" . $file, TRUE, dt("Removed apache platform vhost configuration"));
}
/**
* Restart Apache
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment