summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntoine Beaupré2010-02-11 15:25:03 -0500
committeranarcat2010-02-11 15:25:03 -0500
commit088d0e545954310cc9abba1a6a10d84f145e93c7 (patch)
treebb9fb3af8ab26259769bc13697c44f66c3068b03
parent011d18b3c5cfdc0a24fe1b2b0f98c72a8408fe50 (diff)
reimport mig5's dev-platform_management cleanlydev-platform_management
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.
-rw-r--r--db_server/delete.provision.inc9
-rw-r--r--platform/delete.provision.inc42
-rw-r--r--platform/provision_drupal.drush.inc5
-rw-r--r--provision.drush.inc17
-rw-r--r--web_server/delete.provision.inc14
-rw-r--r--web_server/provision_apache.drush.inc6
6 files changed, 74 insertions, 19 deletions
diff --git a/db_server/delete.provision.inc b/db_server/delete.provision.inc
index 67e2cf8..4f08888 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 1b15815..ba28f28 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 2de5e37..76e521e 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 e55cfbe..5a42d2b 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 8dca268..4a82bfa 100644
--- a/web_server/delete.provision.inc
+++ b/web_server/delete.provision.inc
@@ -1,7 +1,19 @@
<?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();
}
diff --git a/web_server/provision_apache.drush.inc b/web_server/provision_apache.drush.inc
index aed2e62..fc2d67b 100644
--- a/web_server/provision_apache.drush.inc
+++ b/web_server/provision_apache.drush.inc
@@ -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
*/