Commit 2b9c1c96 authored by Adrian Rossouw's avatar Adrian Rossouw Committed by adrian
Browse files

Fix the aliases functionality.

parent a86743d1
...@@ -40,6 +40,7 @@ function provision_drupal_provision_install($url) { ...@@ -40,6 +40,7 @@ function provision_drupal_provision_install($url) {
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_SITE); drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_SITE);
drush_include_engine('drupal', 'install'); drush_include_engine('drupal', 'install');
drush_set_option('installed', TRUE, 'site'); drush_set_option('installed', TRUE, 'site');
_provision_drupal_maintain_aliases($url);
} }
/** /**
...@@ -61,8 +62,8 @@ function provision_drupal_provision_install_rollback($url) { ...@@ -61,8 +62,8 @@ function provision_drupal_provision_install_rollback($url) {
* 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 provision_drupal_post_provision_install($url) { function provision_drupal_post_provision_install($url) {
drush_set_option('aliases', drush_get_option('aliases'), 'site');
drush_set_option('installed', TRUE, 'site'); drush_set_option('installed', TRUE, 'site');
_provision_drupal_maintain_aliases($url);
provision_path("chmod", "./sites/$url/settings.php", 0440, dt("Secured settings.php with safe permissions")); provision_path("chmod", "./sites/$url/settings.php", 0440, dt("Secured settings.php with safe permissions"));
_provision_drupal_rebuild_caches($url); _provision_drupal_rebuild_caches($url);
drush_set_option('packages', _scrub_object(provision_drupal_system_map()), 'site'); drush_set_option('packages', _scrub_object(provision_drupal_system_map()), 'site');
......
...@@ -352,17 +352,22 @@ function _provision_drupal_get_cvs_versions($files) { ...@@ -352,17 +352,22 @@ function _provision_drupal_get_cvs_versions($files) {
function _provision_drupal_maintain_aliases($url) { function _provision_drupal_maintain_aliases($url) {
if (PROVISION_CONTEXT_SITE) { if (PROVISION_CONTEXT_SITE) {
$old_aliases = drush_get_option('aliases', array(), 'site'); $old_aliases = drush_get_option('aliases', array(), 'site');
/**
* First we remove all the old aliases if (!is_array($old_aliases)) {
*/ $old_aliases = explode(",", $old_aliases);
if (is_array($old_aliases)) {
_provision_drupal_delete_aliases($old_aliases);
} }
/**
* First we remove all the old aliases
*/
_provision_drupal_delete_aliases($old_aliases);
$aliases = drush_get_option('aliases'); $aliases = explode("," , drush_get_option('aliases'));
if (is_array($aliases)) { if (!is_array($aliases)) {
foreach($aliases as $alias) { $aliases = explode(",", $aliases);
}
foreach($aliases as $alias) {
if (trim($alias)) {
provision_path("symlink", $url, drush_get_option('docroot_path') . "/sites/" . $alias, provision_path("symlink", $url, drush_get_option('docroot_path') . "/sites/" . $alias,
dt("Created symlink for alias @alias", array("@alias" => $alias)), dt("Created symlink for alias @alias", array("@alias" => $alias)),
dt("Could not create symlink for alias @alias", array("@alias" => $alias))); dt("Could not create symlink for alias @alias", array("@alias" => $alias)));
...@@ -376,9 +381,11 @@ function _provision_drupal_maintain_aliases($url) { ...@@ -376,9 +381,11 @@ function _provision_drupal_maintain_aliases($url) {
*/ */
function _provision_drupal_delete_aliases($aliases) { function _provision_drupal_delete_aliases($aliases) {
foreach ($aliases as $alias) { foreach ($aliases as $alias) {
provision_path("unlink", drush_get_option('docroot_path') . "/sites/" . $alias, TRUE, if (trim($alias)) {
dt("Removed symlink for alias @alias", array("@alias" => $alias)), provision_path("unlink", drush_get_option('docroot_path') . "/sites/" . $alias, TRUE,
dt("Could not remove symlink for alias @alias", array("@alias" => $alias))); dt("Removed symlink for alias @alias", array("@alias" => $alias)),
dt("Could not remove symlink for alias @alias", array("@alias" => $alias)));
}
} }
} }
......
...@@ -48,6 +48,7 @@ function provision_drupal_provision_verify($url = null) { ...@@ -48,6 +48,7 @@ function provision_drupal_provision_verify($url = null) {
function provision_drupal_post_provision_verify($url = NULL) { function provision_drupal_post_provision_verify($url = NULL) {
if (PROVISION_CONTEXT_SITE) { if (PROVISION_CONTEXT_SITE) {
_provision_drupal_rebuild_caches($url); _provision_drupal_rebuild_caches($url);
drush_set_option('aliases', drush_get_option('aliases'), 'site');
drush_set_option('installed', TRUE, 'site'); drush_set_option('installed', TRUE, 'site');
} }
} }
......
...@@ -83,6 +83,10 @@ function _provision_apache_create_vhost_config($url, $template = NULL) { ...@@ -83,6 +83,10 @@ function _provision_apache_create_vhost_config($url, $template = NULL) {
if (is_null($template)) { if (is_null($template)) {
$template = _provision_apache_default_template(); $template = _provision_apache_default_template();
} }
if (!is_array($options['aliases'])) {
$options['aliases'] = explode(",", $options['aliases']);
}
$options['extra_config'] = "# Extra configuration from modules:\n"; $options['extra_config'] = "# Extra configuration from modules:\n";
$options['extra_config'] .= join("\n", drush_command_invoke_all('provision_apache_vhost_config', $url, $options)); $options['extra_config'] .= join("\n", drush_command_invoke_all('provision_apache_vhost_config', $url, $options));
return _provision_apache_create_config($url, $options, $template); return _provision_apache_create_config($url, $options, $template);
......
...@@ -7,9 +7,12 @@ ...@@ -7,9 +7,12 @@
ServerName <?php print $site_url; ?> ServerName <?php print $site_url; ?>
<?php if (is_array($aliases)) : <?php if (is_array($aliases)) :
foreach ($aliases as $alias_url) : ?> foreach ($aliases as $alias_url) :
ServerAlias <?php print $alias_url; ?> if (trim($alias_url)) : ?>
ServerAlias <?php print $alias_url; ?>
<?php <?php
endif;
endforeach; endforeach;
endif; ?> endif; ?>
......
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