summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Drumm2010-06-16 00:39:01 (GMT)
committerNeil Drumm2010-06-16 00:39:01 (GMT)
commitd669cfa21158c454dbb2e692b736ea9a932b0404 (patch)
tree28c09eaaf633bd139f7f30c6f2962b54f6bd6252
parentc831b8b0319daafb5c35e2ca87708954c5db8051 (diff)
Aegir site alias cleanup.
-rw-r--r--platform/delete.provision.inc2
-rw-r--r--platform/deploy.provision.inc5
-rw-r--r--platform/install.provision.inc2
-rw-r--r--platform/migrate.provision.inc2
-rw-r--r--platform/provision_drupal.drush.inc34
-rw-r--r--platform/verify.provision.inc2
-rw-r--r--provision.environment.inc3
-rw-r--r--provision.file.inc7
8 files changed, 22 insertions, 35 deletions
diff --git a/platform/delete.provision.inc b/platform/delete.provision.inc
index 41c4e1a..761d0c6 100644
--- a/platform/delete.provision.inc
+++ b/platform/delete.provision.inc
@@ -21,7 +21,7 @@ function drush_provision_drupal_provision_delete() {
_provision_recursive_delete(d()->site_path);
// 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(), 'site'), drush_get_option('redirection'));
+ _provision_drupal_delete_aliases(d()->aliases);
}
elseif (d()->type === 'platform') {
if (provision_drupal_find_sites()) {
diff --git a/platform/deploy.provision.inc b/platform/deploy.provision.inc
index 6227119..6a93c6a 100644
--- a/platform/deploy.provision.inc
+++ b/platform/deploy.provision.inc
@@ -77,10 +77,9 @@ function drush_provision_drupal_pre_provision_deploy_rollback() {
}
function drush_provision_drupal_provision_deploy() {
- _provision_drupal_maintain_aliases(d()->uri);
+ _provision_drupal_maintain_aliases();
}
-
function drush_provision_drupal_post_provision_deploy() {
provision_prepare_environment();
_provision_drupal_create_settings_file();
@@ -92,7 +91,5 @@ function drush_provision_drupal_post_provision_deploy() {
drush_include_engine('drupal', 'deploy');
drush_set_option('packages', _scrub_object(provision_drupal_system_map()), 'site');
_provision_drupal_rebuild_caches();
- drush_set_option('aliases', drush_get_option('aliases'), 'site');
- drush_set_option('redirection', drush_get_option('redirection'), 'site');
}
}
diff --git a/platform/install.provision.inc b/platform/install.provision.inc
index 1b14207..071ec3c 100644
--- a/platform/install.provision.inc
+++ b/platform/install.provision.inc
@@ -61,13 +61,11 @@ function drush_provision_drupal_provision_install_rollback() {
}
}
-
/**
* Finish the installation, regenerate the caches on the site so that
* any changes to things such as available modules/ themes can take affect.
*/
function drush_provision_drupal_post_provision_install() {
- drush_set_option('aliases', drush_get_option('aliases'), 'site');
drush_set_option('installed', TRUE, 'site');
_provision_drupal_rebuild_caches();
drush_set_option('packages', _scrub_object(provision_drupal_system_map()), 'site');
diff --git a/platform/migrate.provision.inc b/platform/migrate.provision.inc
index 3ada16d..a593cb4 100644
--- a/platform/migrate.provision.inc
+++ b/platform/migrate.provision.inc
@@ -82,7 +82,7 @@ function drush_provision_drupal_post_provision_migrate() {
drush_set_option('installed', FALSE);
// 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'));
+ _provision_drupal_delete_aliases(d()->aliases);
_provision_recursive_delete(d()->site_path);
d()->service('http')->sync(d()->site_path);
}
diff --git a/platform/provision_drupal.drush.inc b/platform/provision_drupal.drush.inc
index c2a9d82..f574853 100644
--- a/platform/provision_drupal.drush.inc
+++ b/platform/provision_drupal.drush.inc
@@ -324,24 +324,20 @@ function _provision_drupal_get_cvs_versions($files) {
}
/**
- * Create and remove symlinks for each of the possible domain aliases of an existing site
+ * Create and remove symlinks for each of the possible domain aliases of an
+ * existing site.
*/
function _provision_drupal_maintain_aliases() {
if (d()->type === 'site') {
- // First we delete all the old aliases
- drush_set_option('aliases', drush_get_option('aliases'), 'site');
- _provision_drupal_delete_aliases(drush_get_option('aliases', array(), 'site'), false);
-
- if (!drush_get_option('redirection')) {
- $aliases = drush_get_option('aliases');
- if (!is_array($aliases)) {
- $aliases = explode(",", $aliases);
- }
- foreach($aliases as $alias) {
- if (trim($alias)) {
+ _provision_drupal_delete_aliases(d()->aliases);
+
+ if (!d()->redirection) {
+ foreach(d()->aliases as $alias) {
+ if ($alias = trim($alias)) {
provision_file()->symlink(d()->uri, d()->root . '/sites/' . $alias)
->succeed('Created symlink for alias @target')
->fail('Could not create symlink for alias @target');
+ d()->service('http')->sync(d()->root . '/sites/' . $alias);
}
}
}
@@ -351,21 +347,13 @@ function _provision_drupal_maintain_aliases() {
/**
* Delete a list of aliases
*/
-function _provision_drupal_delete_aliases($aliases, $silent = false) {
- if (!is_array($aliases)) {
- $aliases = explode(",", $aliases);
- }
- if ($silent) {
- $error = NULL;
- }
- else {
- $error = 'Could not remove symlink for alias @path';
- }
+function _provision_drupal_delete_aliases($aliases) {
foreach ($aliases as $alias) {
if ($alias = trim($alias)) {
provision_file()->unlink(d()->root . '/sites/' . $alias)
->succeed('Removed symlink for alias @path')
- ->fail($error);
+ ->fail('Could not remove symlink for alias @path');
+ d()->service('http')->sync(d()->root . '/sites/' . $alias);
}
}
}
diff --git a/platform/verify.provision.inc b/platform/verify.provision.inc
index bab5016..bfe8e43 100644
--- a/platform/verify.provision.inc
+++ b/platform/verify.provision.inc
@@ -78,8 +78,6 @@ class provisionConfig_global_settings extends provisionConfig {
function drush_provision_drupal_post_provision_verify() {
if (d()->type === 'site') {
_provision_drupal_rebuild_caches();
- drush_set_option('aliases', drush_get_option('aliases'), 'site');
- drush_set_option('redirection', drush_get_option('redirection'), 'site');
drush_set_option('installed', TRUE, 'site');
}
}
diff --git a/provision.environment.inc b/provision.environment.inc
index 55449c1..8a627b3 100644
--- a/provision.environment.inc
+++ b/provision.environment.inc
@@ -416,7 +416,6 @@ class provisionServer extends provisionEnvironment {
}
}
}
-
}
}
@@ -461,6 +460,7 @@ class provisionSite extends provisionEnvironment {
'--site_port' => 'site: port the site is hosted on; default 80',
'--language' => 'site: site language; default en',
'--aliases' => 'site: comma-separated URIs',
+ '--redirection' => 'site: boolean for whether --aliases should redirect; default false',
'--client_email' => 'site: email for the site owner',
'--profile' => 'site: Drupal profile to use; default default',
);
@@ -487,6 +487,7 @@ class provisionSite extends provisionEnvironment {
$this->setProperty('site_port', 80);
$this->setProperty('client_email');
$this->setProperty('aliases', array(), TRUE);
+ $this->setProperty('redirection', FALSE);
$this->setProperty('db_server', '@server_localhost');
$this->is_oid('db_server');
diff --git a/provision.file.inc b/provision.file.inc
index 0ce601d..2681764 100644
--- a/provision.file.inc
+++ b/provision.file.inc
@@ -116,7 +116,12 @@ class provisionFileSystem extends provisionChainedState {
function unlink($path) {
$this->_clear_state();
- $this->last_status = unlink($path);
+ if (file_exists($path) || is_link($path)) {
+ $this->last_status = unlink($path);
+ }
+ else {
+ $this->last_status = TRUE;
+ }
$this->tokens = array('@path' => $path);
return $this;