Commit d669cfa2 authored by drumm's avatar drumm Committed by Neil Drumm

Aegir site alias cleanup.

parent c831b8b0
...@@ -21,7 +21,7 @@ function drush_provision_drupal_provision_delete() { ...@@ -21,7 +21,7 @@ function drush_provision_drupal_provision_delete() {
_provision_recursive_delete(d()->site_path); _provision_recursive_delete(d()->site_path);
// we remove the aliases even if redirection is enabled as a precaution // we remove the aliases even if redirection is enabled as a precaution
// if redirection is enabled, keep silent about errors // 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') { elseif (d()->type === 'platform') {
if (provision_drupal_find_sites()) { if (provision_drupal_find_sites()) {
......
...@@ -77,10 +77,9 @@ function drush_provision_drupal_pre_provision_deploy_rollback() { ...@@ -77,10 +77,9 @@ function drush_provision_drupal_pre_provision_deploy_rollback() {
} }
function drush_provision_drupal_provision_deploy() { function drush_provision_drupal_provision_deploy() {
_provision_drupal_maintain_aliases(d()->uri); _provision_drupal_maintain_aliases();
} }
function drush_provision_drupal_post_provision_deploy() { function drush_provision_drupal_post_provision_deploy() {
provision_prepare_environment(); provision_prepare_environment();
_provision_drupal_create_settings_file(); _provision_drupal_create_settings_file();
...@@ -92,7 +91,5 @@ function drush_provision_drupal_post_provision_deploy() { ...@@ -92,7 +91,5 @@ function drush_provision_drupal_post_provision_deploy() {
drush_include_engine('drupal', 'deploy'); drush_include_engine('drupal', 'deploy');
drush_set_option('packages', _scrub_object(provision_drupal_system_map()), 'site'); drush_set_option('packages', _scrub_object(provision_drupal_system_map()), 'site');
_provision_drupal_rebuild_caches(); _provision_drupal_rebuild_caches();
drush_set_option('aliases', drush_get_option('aliases'), 'site');
drush_set_option('redirection', drush_get_option('redirection'), 'site');
} }
} }
...@@ -61,13 +61,11 @@ function drush_provision_drupal_provision_install_rollback() { ...@@ -61,13 +61,11 @@ function drush_provision_drupal_provision_install_rollback() {
} }
} }
/** /**
* Finish the installation, regenerate the caches on the site so that * Finish the installation, regenerate the caches on the site so that
* any changes to things such as available modules/ themes can take affect. * any changes to things such as available modules/ themes can take affect.
*/ */
function drush_provision_drupal_post_provision_install() { function drush_provision_drupal_post_provision_install() {
drush_set_option('aliases', drush_get_option('aliases'), 'site');
drush_set_option('installed', TRUE, 'site'); drush_set_option('installed', TRUE, 'site');
_provision_drupal_rebuild_caches(); _provision_drupal_rebuild_caches();
drush_set_option('packages', _scrub_object(provision_drupal_system_map()), 'site'); drush_set_option('packages', _scrub_object(provision_drupal_system_map()), 'site');
......
...@@ -82,7 +82,7 @@ function drush_provision_drupal_post_provision_migrate() { ...@@ -82,7 +82,7 @@ function drush_provision_drupal_post_provision_migrate() {
drush_set_option('installed', FALSE); drush_set_option('installed', FALSE);
// we remove the aliases even if redirection is enabled as a precaution // we remove the aliases even if redirection is enabled as a precaution
// if redirection is enabled, keep silent about errors // 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); _provision_recursive_delete(d()->site_path);
d()->service('http')->sync(d()->site_path); d()->service('http')->sync(d()->site_path);
} }
......
...@@ -324,24 +324,20 @@ function _provision_drupal_get_cvs_versions($files) { ...@@ -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() { function _provision_drupal_maintain_aliases() {
if (d()->type === 'site') { if (d()->type === 'site') {
// First we delete all the old aliases _provision_drupal_delete_aliases(d()->aliases);
drush_set_option('aliases', drush_get_option('aliases'), 'site');
_provision_drupal_delete_aliases(drush_get_option('aliases', array(), 'site'), false); if (!d()->redirection) {
foreach(d()->aliases as $alias) {
if (!drush_get_option('redirection')) { if ($alias = trim($alias)) {
$aliases = drush_get_option('aliases');
if (!is_array($aliases)) {
$aliases = explode(",", $aliases);
}
foreach($aliases as $alias) {
if (trim($alias)) {
provision_file()->symlink(d()->uri, d()->root . '/sites/' . $alias) provision_file()->symlink(d()->uri, d()->root . '/sites/' . $alias)
->succeed('Created symlink for alias @target') ->succeed('Created symlink for alias @target')
->fail('Could not create 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() { ...@@ -351,21 +347,13 @@ function _provision_drupal_maintain_aliases() {
/** /**
* Delete a list of aliases * Delete a list of aliases
*/ */
function _provision_drupal_delete_aliases($aliases, $silent = false) { function _provision_drupal_delete_aliases($aliases) {
if (!is_array($aliases)) {
$aliases = explode(",", $aliases);
}
if ($silent) {
$error = NULL;
}
else {
$error = 'Could not remove symlink for alias @path';
}
foreach ($aliases as $alias) { foreach ($aliases as $alias) {
if ($alias = trim($alias)) { if ($alias = trim($alias)) {
provision_file()->unlink(d()->root . '/sites/' . $alias) provision_file()->unlink(d()->root . '/sites/' . $alias)
->succeed('Removed symlink for alias @path') ->succeed('Removed symlink for alias @path')
->fail($error); ->fail('Could not remove symlink for alias @path');
d()->service('http')->sync(d()->root . '/sites/' . $alias);
} }
} }
} }
......
...@@ -78,8 +78,6 @@ class provisionConfig_global_settings extends provisionConfig { ...@@ -78,8 +78,6 @@ class provisionConfig_global_settings extends provisionConfig {
function drush_provision_drupal_post_provision_verify() { function drush_provision_drupal_post_provision_verify() {
if (d()->type === 'site') { if (d()->type === 'site') {
_provision_drupal_rebuild_caches(); _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'); drush_set_option('installed', TRUE, 'site');
} }
} }
......
...@@ -416,7 +416,6 @@ class provisionServer extends provisionEnvironment { ...@@ -416,7 +416,6 @@ class provisionServer extends provisionEnvironment {
} }
} }
} }
} }
} }
...@@ -461,6 +460,7 @@ class provisionSite extends provisionEnvironment { ...@@ -461,6 +460,7 @@ class provisionSite extends provisionEnvironment {
'--site_port' => 'site: port the site is hosted on; default 80', '--site_port' => 'site: port the site is hosted on; default 80',
'--language' => 'site: site language; default en', '--language' => 'site: site language; default en',
'--aliases' => 'site: comma-separated URIs', '--aliases' => 'site: comma-separated URIs',
'--redirection' => 'site: boolean for whether --aliases should redirect; default false',
'--client_email' => 'site: email for the site owner', '--client_email' => 'site: email for the site owner',
'--profile' => 'site: Drupal profile to use; default default', '--profile' => 'site: Drupal profile to use; default default',
); );
...@@ -487,6 +487,7 @@ class provisionSite extends provisionEnvironment { ...@@ -487,6 +487,7 @@ class provisionSite extends provisionEnvironment {
$this->setProperty('site_port', 80); $this->setProperty('site_port', 80);
$this->setProperty('client_email'); $this->setProperty('client_email');
$this->setProperty('aliases', array(), TRUE); $this->setProperty('aliases', array(), TRUE);
$this->setProperty('redirection', FALSE);
$this->setProperty('db_server', '@server_localhost'); $this->setProperty('db_server', '@server_localhost');
$this->is_oid('db_server'); $this->is_oid('db_server');
......
...@@ -116,7 +116,12 @@ class provisionFileSystem extends provisionChainedState { ...@@ -116,7 +116,12 @@ class provisionFileSystem extends provisionChainedState {
function unlink($path) { function unlink($path) {
$this->_clear_state(); $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); $this->tokens = array('@path' => $path);
return $this; return $this;
......
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