Commit 2062e9b9 authored by anarcat's avatar anarcat Committed by anarcat

Merge branch 'master' of ceres.koumbit.net:/var/aegir/.drush/provision

parents 899e4fc1 a48cda86
......@@ -21,7 +21,9 @@ function drush_provision_drupal_pre_provision_delete($url, $backup_file = NULL)
*/
function drush_provision_drupal_provision_delete($url) {
_provision_recursive_delete(drush_get_option('sites_path') . "/$url");
_provision_drupal_delete_aliases(drush_get_option('aliases', array()));
// 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');
}
......
......@@ -30,7 +30,7 @@ function drush_provision_drupal_provision_migrate_validate($url = null, $platfor
/**
* Make a backup before making any changes, and add extract the file we are restoring from
*/
function drush_provision_drupal_pre_provision_migrate($url, $platform) {
function drush_provision_drupal_pre_provision_migrate($url, $platform = null) {
/* Set offline mode to true and re-generate the settings.php. This will write a
* $conf['site_offline'] = 1; to the settings.php
*/
......@@ -44,7 +44,7 @@ function drush_provision_drupal_pre_provision_migrate($url, $platform) {
* Remove the extracted site directory
* Restore the vhost conf per the original platform
*/
function drush_provision_drupal_pre_provision_migrate_rollback($url, $platform) {
function drush_provision_drupal_pre_provision_migrate_rollback($url, $platform = null) {
// Set site_offline to false and regenerate the config
drush_log(dt("Bringing site out of maintenance"));
drush_set_option('site_offline', 0);
......@@ -68,7 +68,9 @@ function drush_provision_drupal_provision_migrate($url, $platform) {
*/
function drush_provision_drupal_post_provision_migrate($url) {
drush_set_option('installed', FALSE);
_provision_drupal_delete_aliases(drush_get_option('aliases', array()));
// 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_recursive_delete(drush_get_option('sites_path') ."/$url");
}
......
......@@ -378,7 +378,7 @@ function _provision_drupal_maintain_aliases($url) {
if (PROVISION_CONTEXT_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'));
_provision_drupal_delete_aliases(drush_get_option('aliases', array(), 'site'), false);
if (!drush_get_option('redirection')) {
$aliases = drush_get_option('aliases');
......@@ -399,15 +399,19 @@ function _provision_drupal_maintain_aliases($url) {
/**
* Delete a list of aliases
*/
function _provision_drupal_delete_aliases($aliases) {
function _provision_drupal_delete_aliases($aliases, $silent = false) {
if (!is_array($aliases)) {
$aliases = explode(",", $aliases);
}
if ($silent) {
$error = NULL;
} else {
$error = dt("Could not remove symlink for alias @alias", array("@alias" => $alias));
}
foreach ($aliases as $alias) {
if ($alias = trim($alias)) {
provision_path("unlink", drush_get_option('docroot_path') . "/sites/" . $alias, TRUE,
dt("Removed symlink for alias @alias", array("@alias" => $alias)),
dt("Could not remove symlink for alias @alias", array("@alias" => $alias)));
dt("Removed symlink for alias @alias", array("@alias" => $alias)), $error);
}
}
}
......
......@@ -21,8 +21,13 @@
*/
function provision_ssl_provision_apache_vhost_config($url, $options) {
if (!empty($options['ssl'])) {
if ($options['ssl_redirect'] && provision_path('exists', drush_get_option('vhost_path') . '/' . $url . '_80', FALSE, NULL, dt("The redirection port is not available, no redirection installed"))) {
if ($options['ssl_redirect']) {
// That's pretty bad, but if we *don't* do that, the vhost is never updated after the first write
// XXX: we need a better way to identify if this is legit
provision_path('exists', drush_get_option('vhost_path') . '/' . $url . '_80', FALSE, NULL, dt("Overwriting existing vhost %url:80 with redirection", array('%url' => $url)));
$newoptions = $options;
// in the redirection template, the ServerName is the first alias in the list
array_push($newoptions['aliases'], $options['site_url']);
$newoptions['site_port'] = 80;
_provision_apache_create_config($url . '_80', $newoptions, _provision_apache_redirect_template());
}
......
......@@ -3,14 +3,17 @@
ServerAdmin <?php print $site_mail; ?>
<?php endif;?>
ServerName <?php print $site_url; ?>
<?php if (is_array($aliases) && count($aliases)): ?>
ServerName <?php print array_pop($aliases); ?>
<?php if (is_array($aliases)) :
foreach ($aliases as $alias) : ?>
ServerAlias <?php print $alias; ?>
<?php
endforeach;
endif; ?>
<?php if (count($aliases)): ?>
ServerAlias <?php print join(" ", $aliases); ?>
<?php endif; ?>
<?php else:
# this should never happen and has the potential of creating an infinite redirection loop
?>
ServerName <?php print $site_url ?>
<?php endif; ?>
<?php if ($ssl_redirect): ?>
RedirectMatch permanent ^(.*) https://<?php print $site_url ?>$1
......
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