Commit 757625c9 authored by Adrian Rossouw's avatar Adrian Rossouw

Seem to have excised enough of the ports stuff...

parent aac08b4a
...@@ -30,6 +30,8 @@ function db_drush_help($section) { ...@@ -30,6 +30,8 @@ function db_drush_help($section) {
class provisionService_db extends provisionService { class provisionService_db extends provisionService {
protected $service = 'db';
static function option_documentation() { static function option_documentation() {
return array( return array(
'--master_db' => 'server with db: Master database connection info, {type}://{user}:{password}@{host}', '--master_db' => 'server with db: Master database connection info, {type}://{user}:{password}@{host}',
......
<?php <?php
class provisionService_http_apache extends provisionService_http { class provisionService_http_apache extends provisionService_http {
static function option_documentation() { protected $has_restart_cmd = TRUE;
return array_merge(parent::option_documentation(), array(
'--restart_cmd' => 'server with apache: shell command to restart the server; working default will be attepted', function default_restart_cmd() {
'--web_ports' => 'server with apache: array of ports to make available; default 80', $command = '/usr/sbin/apachectl'; // A proper default for most of the world
)); foreach (explode(':', $_SERVER['PATH']) as $path) {
$options[] = "$path/apache2ctl";
$options[] = "$path/apachectl";
}
// Try to detect the apache restart command.
$options[] = '/usr/local/sbin/apachectl'; // freebsd
$options[] = '/usr/sbin/apache2ctl'; // debian + apache2
$options[] = '/usr/apache2/2.2/bin'; // Solaris
$options[] = $command;
foreach ($options as $test) {
if (is_executable($test)) {
$command = $test;
break;
}
}
return "sudo $command graceful";
} }
function init() { function init() {
...@@ -13,10 +30,6 @@ class provisionService_http_apache extends provisionService_http { ...@@ -13,10 +30,6 @@ class provisionService_http_apache extends provisionService_http {
$this->server->apache_site_conf_path = $this->server->config_path . '/vhost.d'; $this->server->apache_site_conf_path = $this->server->config_path . '/vhost.d';
$this->server->apache_platform_conf_path = $this->server->config_path . '/platform.d'; $this->server->apache_platform_conf_path = $this->server->config_path . '/platform.d';
$this->server->apache_conf_path = $this->server->config_path . '/apache.d'; $this->server->apache_conf_path = $this->server->config_path . '/apache.d';
// Commands
$this->server->setProperty('restart_cmd', _provision_default_restart_cmd());
$this->server->setProperty('web_ports', array(80));
} }
/** /**
...@@ -33,6 +46,7 @@ class provisionService_http_apache extends provisionService_http { ...@@ -33,6 +46,7 @@ class provisionService_http_apache extends provisionService_http {
function config_data() { function config_data() {
return array( return array(
'server' => $this->server, 'server' => $this->server,
'http_port' => $this->server->http_port,
'apache_site_conf_path' => $this->server->apache_site_conf_path, 'apache_site_conf_path' => $this->server->apache_site_conf_path,
'apache_platform_conf_path' => $this->server->apache_platform_conf_path, 'apache_platform_conf_path' => $this->server->apache_platform_conf_path,
'apache_conf_path' => $this->server->apache_conf_path 'apache_conf_path' => $this->server->apache_conf_path
...@@ -89,7 +103,7 @@ class provisionService_http_apache extends provisionService_http { ...@@ -89,7 +103,7 @@ class provisionService_http_apache extends provisionService_http {
function parse_configs() { function parse_configs() {
// This is required to be configurable, due to the fact that different // This is required to be configurable, due to the fact that different
// hosts might need to do this differently. // hosts might need to do this differently.
if ($this->server->shell_exec($this->server->restart_cmd)) { if ($this->server->shell_exec($this->server->http_restart_cmd)) {
drush_log(dt('Apache on %server has been restarted', array('%server' => $this->server->remote_host))); drush_log(dt('Apache on %server has been restarted', array('%server' => $this->server->remote_host)));
} }
else { else {
...@@ -152,7 +166,7 @@ class provisionConfig_apache_site extends provisionConfig_apache { ...@@ -152,7 +166,7 @@ class provisionConfig_apache_site extends provisionConfig_apache {
public $description = 'apache site configuration file'; public $description = 'apache site configuration file';
function filename() { function filename() {
return $this->data['apache_site_conf_path'] . '/' . $this->uri . '_' . $this->site_port; return $this->data['apache_site_conf_path'] . '/' . $this->uri . '_' . $this->data['http_port'];
} }
function process() { function process() {
......
# Aegir web server configuration file # Aegir web server configuration file
<?php if (is_array($server->web_ports)) : NameVirtualHost *:<?php print $web_port; ?>
foreach ($server->web_ports as $web_port) :?>
NameVirtualHost *:<?php print $web_port; ?> <VirtualHost *:<?php print $web_port; ?>>
ServerName default
<VirtualHost *:<?php print $web_port; ?>> Redirect 404 /
ServerName default </VirtualHost>
Redirect 404 /
</VirtualHost>
<?php
endforeach;
endif;
?>
<IfModule !env_module> <IfModule !env_module>
LoadModule env_module modules/mod_env.so LoadModule env_module modules/mod_env.so
......
...@@ -8,13 +8,9 @@ function http_provision_services() { ...@@ -8,13 +8,9 @@ function http_provision_services() {
} }
class provisionService_http extends provisionService { class provisionService_http extends provisionService {
static function option_documentation() { public $service = 'http';
return array(
'--web_group' => 'server with http: OS group for permissions; working default will be attepted', protected $has_port = TRUE;
'--web_disable_url' => 'server with http: URL disabled sites are redirected to; default {master_url}/hosting/disabled',
'--web_maintenence_url' => 'server with http: URL maintenance sites are redirected to; default {master_url}/hosting/maintenance',
);
}
function init() { function init() {
parent::init(); parent::init();
...@@ -31,6 +27,19 @@ class provisionService_http extends provisionService { ...@@ -31,6 +27,19 @@ class provisionService_http extends provisionService {
$this->server->setProperty('web_maintenence_url', $this->server->master_url .'/hosting/maintenance'); $this->server->setProperty('web_maintenence_url', $this->server->master_url .'/hosting/maintenance');
} }
function default_port() {
return 80;
}
static function option_documentation() {
return array(
'--web_group' => 'server with http: OS group for permissions; working default will be attepted',
'--web_disable_url' => 'server with http: URL disabled sites are redirected to; default {master_url}/hosting/disabled',
'--web_maintenence_url' => 'server with http: URL maintenance sites are redirected to; default {master_url}/hosting/maintenance',
);
}
function verify() { function verify() {
switch (d()->type) { switch (d()->type) {
case 'server': case 'server':
......
...@@ -229,28 +229,6 @@ function drush_provision_verify() { ...@@ -229,28 +229,6 @@ function drush_provision_verify() {
d()->verify(); d()->verify();
} }
function _provision_default_restart_cmd() {
$command = '/usr/sbin/apachectl'; // A proper default for most of the world
foreach (explode(':', $_SERVER['PATH']) as $path) {
$options[] = "$path/apache2ctl";
$options[] = "$path/apachectl";
}
// Try to detect the apache restart command.
$options[] = '/usr/local/sbin/apachectl'; // freebsd
$options[] = '/usr/sbin/apache2ctl'; // debian + apache2
$options[] = '/usr/apache2/2.2/bin'; // Solaris
$options[] = $command;
foreach ($options as $test) {
if (is_executable($test)) {
$command = $test;
break;
}
}
return "sudo $command graceful";
}
function _provision_default_web_group() { function _provision_default_web_group() {
$info = posix_getgrgid(posix_getgid()); $info = posix_getgrgid(posix_getgid());
$common_groups = array( $common_groups = array(
......
...@@ -8,6 +8,34 @@ require_once DRUSH_BASE_PATH . '/commands/core/rsync.core.inc'; ...@@ -8,6 +8,34 @@ require_once DRUSH_BASE_PATH . '/commands/core/rsync.core.inc';
class provisionService extends provisionChainedState { class provisionService extends provisionChainedState {
protected $server = '@server_master'; protected $server = '@server_master';
public $context; public $context;
protected $service = null;
protected $has_restart_cmd = FALSE;
protected $has_port = FALSE;
// All services have the ability to have an associated restart command and listen port.
function init() {
if (!is_null($this->service)) {
if ($this->has_port) {
$this->server->setProperty($this->service . '_port', $this->default_port());
}
if ($this->has_restart_cmd) {
$this->server->setProperty($this->service . '_restart_cmd', $this->default_restart_cmd());
}
}
return TRUE;
}
function default_port() {
return false;
}
function default_restart_cmd() {
return false;
}
function __construct($server) { function __construct($server) {
$this->server = d($server); $this->server = d($server);
...@@ -25,10 +53,6 @@ class provisionService extends provisionChainedState { ...@@ -25,10 +53,6 @@ class provisionService extends provisionChainedState {
return TRUE; return TRUE;
} }
function init() {
return TRUE;
}
/** /**
* Return service-specific configuration options for help. * Return service-specific configuration options for help.
* *
......
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