Commit 575b6427 authored by Adrian Rossouw's avatar Adrian Rossouw

Pass the service request to the 'parent'. Still need to implement

the ability to redirect specific services to a different server.

also got verify working for servers and platforms, and started
the process of getting rid of drush_get_merged_options in config files.
parent 03194076
......@@ -38,7 +38,7 @@ class provisionService_db extends provisionService {
}
function verify() {
if (d($this->owner)->type === 'server') {
if (d()->type === 'server') {
$this->connect();
if ($this->can_create_database()) {
drush_log(dt('Provision can create new databases.'), 'message');
......
......@@ -6,11 +6,13 @@
class provisionService_http_apache extends provisionService_http {
function init() {
parent::init();
$this->setProperty('apache_site_conf_path', $this->config_path . '/vhost.d');
$this->setProperty('apache_platform_conf_path', $this->config_path . '/platform.d');
$this->apache_site_conf_path = $this->config_path . '/vhost.d';
$this->apache_platform_conf_path = $this->config_path . '/platform.d';
$this->apache_conf_path = $this->config_path . '/apache.d';
// Commands
$this->setProperty('restart_cmd', _provision_default_restart_cmd());
$this->setProperty('web_ports', array(80));
}
function create_site_config() {
......@@ -24,7 +26,7 @@ class provisionService_http_apache extends provisionService_http {
}
function create_platform_config() {
$config = new provisionConfig_apache_platform(drush_get_merged_options());
$config = new provisionConfig_apache_platform(array('d' => d()));
return $config->write();
}
......@@ -35,7 +37,7 @@ class provisionService_http_apache extends provisionService_http {
function create_server_config() {
$config = new provisionConfig_apache_server(drush_get_merged_options());
$config = new provisionConfig_apache_server(array('d' => d()));
return $config->write();
}
......@@ -46,11 +48,11 @@ class provisionService_http_apache extends provisionService_http {
}
function verify() {
switch (d($this->owner)->type) {
switch (d()->type) {
case 'server':
provision_service('file')->create_dir(drush_get_option('apache_site_conf_path'), dt("Virtual host configuration"), 0700);
provision_service('file')->create_dir(drush_get_option('apache_platform_conf_path'), dt("Platforms configuration"), 0700);
provision_service('file')->create_dir(drush_get_option('config_path') . '/apache.d' , dt("Apache configuration"), 0700);
provision_service('file')->create_dir($this->apache_site_conf_path, dt("Virtual host configuration"), 0700);
provision_service('file')->create_dir($this->apache_platform_conf_path, dt("Platforms configuration"), 0700);
provision_service('file')->create_dir($this->apache_conf_path , dt("Apache configuration"), 0700);
$this->create_server_config();
break;
......@@ -105,7 +107,7 @@ class provisionConfig_apache_server extends provisionConfig_apache {
public $description = 'apache server configuration file';
function filename() {
return $this->data['config_path'] . '/' . 'apache.conf';
return $this->data['d']->config_path . '/' . 'apache.conf';
}
function process() {
......@@ -119,7 +121,7 @@ class provisionConfig_apache_platform extends provisionConfig_apache {
public $description = 'apache platform configuration file';
function filename() {
return $this->data['platform_conf_path'] . '/platform_' . $this->data['platform-name'] . '.conf';
return $this->data['d']->server->apache_platform_conf_path . '/' . ltrim($this->data['d']->getName(), '@') . '.conf';
}
function process() {
......
<Directory <?php print $publish_path; ?>>
<Directory <?php print $d->root; ?>>
Order allow,deny
Allow from all
<?php print $extra_config; ?>
......
# Aegir web server configuration file
<?php if (is_array($web_ports)) :
foreach ($web_ports as $web_port) :?>
<?php if (is_array($d->web_ports)) :
foreach ($d->web_ports as $web_port) :?>
NameVirtualHost *:<?php print $web_port; ?>
<VirtualHost *:<?php print $web_port; ?>>
......@@ -23,11 +23,13 @@ endif;
</IfModule>
# virtual hosts
Include <?php print $config_path ?>/vhost.d/
Include <?php print $d->apache_site_conf_path ?>
# platforms
Include <?php print $config_path ?>/platform.d/
Include <?php print $d->apache_platform_conf_path ?>
# other configuration, not touched by aegir
Include <?php print $config_path ?>/apache.d/
Include <?php print $d->apache_conf_path ?>
<?php print $extra_config; ?>
......@@ -91,7 +91,7 @@ function drush_provision_drupal_post_provision_verify() {
* @see hook_provision_apache_dir_config()
*/
function provision_drupal_provision_apache_dir_config($data = null) {
$htaccess = file_get_contents(drush_get_option('publish_path') . '/.htaccess');
$htaccess = file_get_contents(drush_get_option('root') . '/.htaccess');
$htaccess .= <<<EOF
<IfModule mod_rewrite.c>
......
......@@ -54,11 +54,16 @@ function provision_environment_factory($name) {
class provisionEnvironment {
protected $name = null;
protected $properties = array();
protected $parent_key = null;
public $type = null;
protected $oid_map = array();
function getName() {
return $this->name;
}
/**
* Retrieve value from $properties array if property does not exist in class proper.
*
......@@ -155,7 +160,12 @@ class provisionEnvironment {
}
function service($service) {
return new provisionService_null($this->name);
if (!is_null($this->parent_key)) {
return $this->{$this->parent_key}->service($service);
}
else {
return new provisionService_null($this->name);
}
}
}
......@@ -252,6 +262,8 @@ class provisionServer extends provisionEnvironment {
class provisionPlatform extends provisionEnvironment {
function init() {
$this->parent_key = 'server';
parent::init();
$this->type = 'platform';
$this->setProperty('root', $_SERVER['PWD']);
......@@ -268,22 +280,16 @@ class provisionPlatform extends provisionEnvironment {
}
function verify() {
$this->web_server->service('http')->verify();
$this->server->verify();
}
function service($service) {
if ($service == 'http') {
return $this->web_server->service($service);
}
else {
return $this->server->service($service);
}
}
}
class provisionSite extends provisionEnvironment {
function init() {
$this->parent_key = 'platform';
parent::init();
$this->type = 'site';
$this->setProperty('uri');
......
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