Commit 5cb3a37c authored by Adrian Rossouw's avatar Adrian Rossouw

Fix site enable/ disable with the new provision.

parent 30cc2493
......@@ -20,7 +20,13 @@ class provisionService_http_apache extends provisionService_http {
}
function create_site_config() {
$config = new provisionConfig_apache_site($this->context, drush_get_context('site'));
if (d($this->context)->site_enabled) {
$config = new provisionConfig_apache_site($this->context, drush_get_context('site'));
}
else {
$config = new provisionConfig_apache_site_disabled($this->context, drush_get_context('site'));
}
$config->write();
}
......@@ -71,6 +77,9 @@ class provisionConfig_apache extends provisionConfig {
}
/**
* Apache server level configuration file class
*/
class provisionConfig_apache_server extends provisionConfig_apache {
public $template = 'server.tpl.php';
public $description = 'apache server configuration file';
......@@ -85,6 +94,9 @@ class provisionConfig_apache_server extends provisionConfig_apache {
}
}
/**
* Apache platform level configuration file class
*/
class provisionConfig_apache_platform extends provisionConfig_apache {
public $template = 'platform.tpl.php';
public $description = 'apache platform configuration file';
......@@ -99,6 +111,9 @@ class provisionConfig_apache_platform extends provisionConfig_apache {
}
}
/**
* Apache site level config class. Virtual host.
*/
class provisionConfig_apache_site extends provisionConfig_apache {
public $template = 'vhost.tpl.php';
public $description = 'apache site configuration file';
......@@ -117,3 +132,11 @@ class provisionConfig_apache_site extends provisionConfig_apache {
}
}
/**
* Apache configuration file class for disabled sites.
*/
class provisionConfig_apache_site_disabled extends provisionConfig_apache_site {
public $template = 'vhost_disabled.tpl.php';
}
<VirtualHost *:80>
<?php if ($site_mail) : ?>
ServerAdmin <?php print $site_mail; ?>
<?php if ($this->site_mail) : ?>
ServerAdmin <?php print $this->site_mail; ?>
<?php endif;?>
DocumentRoot <?php print $this->platform->root; ?>
DocumentRoot <?php print $this->root; ?>
ServerName <?php print $uri; ?>
ServerName <?php print $this->uri; ?>
<?php if (is_array($aliases)) :
foreach ($aliases as $alias) : ?>
<?php if (is_array($this->aliases)) :
foreach ($this->aliases as $alias) : ?>
ServerAlias <?php print $alias; ?>
<?php
endforeach;
......@@ -15,6 +15,6 @@
RewriteEngine on
# the ? at the end is to remove any query string in the original url
RewriteRule ^(.*)$ <?php print $redirect_url . '/' . $uri ?>?
RewriteRule ^(.*)$ <?php print $this->platform->server->web_disable_url . '/' . $this->uri ?>?
</VirtualHost>
......@@ -12,15 +12,20 @@
* Make a backup of the site before we mess with it
*/
function drush_provision_drupal_pre_provision_disable($backup_file = null) {
drush_set_option('force', true, 'process');
drush_invoke('provision-backup', $backup_file);
drush_unset_option('force', 'process');
if (d()->type == 'site') {
drush_set_option('force', true, 'process');
drush_invoke('provision-backup', $backup_file);
drush_unset_option('force', 'process');
d()->site_enabled = false;
}
}
/**
* Set the enabled property of the site to false
*/
function drush_provision_drupal_post_provision_disable() {
drush_set_option('enabled', FALSE, 'site');
if (d()->type == 'site') {
d()->write_alias();
}
}
......@@ -6,12 +6,16 @@
* Enable a site that has been disabled
*/
function drush_provision_drupal_provision_enable_validate() {
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_SITE);
if (d()->type == 'site') {
d()->site_enabled = true;
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_SITE);
}
}
function drush_provision_drupal_post_provision_enable() {
drush_set_option('enabled', TRUE, 'site');
if (d()->type == 'site') {
d()->write_alias();
}
}
......@@ -60,7 +60,7 @@
$conf['cache'] = 1;
$conf['clean_url'] = 1;
<?php if ($this->site_offline) : ?>
<?php if (!$this->site_enabled) : ?>
$conf['site_offline'] = 1;
<?php endif ?>
......
......@@ -433,6 +433,7 @@ class provisionSite extends provisionEnvironment {
$this->root = $this->platform->root;
$this->setProperty('uri');
$this->setProperty('site_enabled', true);
$this->setProperty('language', 'en');
$this->setProperty('site_port', 80);
$this->setProperty('client_email');
......
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