diff --git a/db/db.drush.inc b/db/db.drush.inc index 8df2c23736eb6dfd57799e01d265480fa6e144e7..bc1f94843fa9a370340e001eb427a07520c81d10 100644 --- a/db/db.drush.inc +++ b/db/db.drush.inc @@ -30,6 +30,8 @@ function db_drush_help($section) { class provisionService_db extends provisionService { + protected $service = 'db'; + static function option_documentation() { return array( '--master_db' => 'server with db: Master database connection info, {type}://{user}:{password}@{host}', diff --git a/http/apache/apache_service.inc b/http/apache/apache_service.inc index d58663f27e83ef9db62b2d7a660c1c2172970b57..8d2ddd80f79b8a831474ce0794ae7ded15a9426a 100644 --- a/http/apache/apache_service.inc +++ b/http/apache/apache_service.inc @@ -1,11 +1,28 @@ <?php class provisionService_http_apache extends provisionService_http { - static function option_documentation() { - return array_merge(parent::option_documentation(), array( - '--restart_cmd' => 'server with apache: shell command to restart the server; working default will be attepted', - '--web_ports' => 'server with apache: array of ports to make available; default 80', - )); + protected $has_restart_cmd = TRUE; + + function 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 init() { @@ -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_platform_conf_path = $this->server->config_path . '/platform.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 { function config_data() { return array( 'server' => $this->server, + 'http_port' => $this->server->http_port, 'apache_site_conf_path' => $this->server->apache_site_conf_path, 'apache_platform_conf_path' => $this->server->apache_platform_conf_path, 'apache_conf_path' => $this->server->apache_conf_path @@ -89,7 +103,7 @@ class provisionService_http_apache extends provisionService_http { function parse_configs() { // This is required to be configurable, due to the fact that different // 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))); } else { @@ -152,7 +166,7 @@ class provisionConfig_apache_site extends provisionConfig_apache { public $description = 'apache site configuration file'; 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() { diff --git a/http/apache/server.tpl.php b/http/apache/server.tpl.php index 8528a8ef77b378a27efe813bf46387655f9b9905..174b01384d486be51f1173a0231d38917596b7be 100644 --- a/http/apache/server.tpl.php +++ b/http/apache/server.tpl.php @@ -1,18 +1,12 @@ # Aegir web server configuration file -<?php if (is_array($server->web_ports)) : - foreach ($server->web_ports as $web_port) :?> - NameVirtualHost *:<?php print $web_port; ?> - - <VirtualHost *:<?php print $web_port; ?>> - ServerName default - Redirect 404 / - </VirtualHost> - -<?php -endforeach; -endif; -?> +NameVirtualHost *:<?php print $web_port; ?> + +<VirtualHost *:<?php print $web_port; ?>> + ServerName default + Redirect 404 / +</VirtualHost> + <IfModule !env_module> LoadModule env_module modules/mod_env.so diff --git a/http/http.drush.inc b/http/http.drush.inc index eaf99115e76e9a9e4dbce827673d2146da8c873b..4301ea45ebd9a95c5472de112e6ab8a00037784c 100644 --- a/http/http.drush.inc +++ b/http/http.drush.inc @@ -8,13 +8,9 @@ function http_provision_services() { } class provisionService_http extends provisionService { - 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', - ); - } + public $service = 'http'; + + protected $has_port = TRUE; function init() { parent::init(); @@ -31,6 +27,19 @@ class provisionService_http extends provisionService { $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() { switch (d()->type) { case 'server': diff --git a/provision.drush.inc b/provision.drush.inc index 52ca751464dd0aa6cb33192e909d44301a00a9ac..afdb8c32764b54a62da75a20241d197a63882bc1 100644 --- a/provision.drush.inc +++ b/provision.drush.inc @@ -229,28 +229,6 @@ function drush_provision_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() { $info = posix_getgrgid(posix_getgid()); $common_groups = array( diff --git a/provision.service.inc b/provision.service.inc index f683212a40dfd01d92c2553fa03c83dd09810b66..5637feb6d2f6fb677deb06cc455097374026b69d 100644 --- a/provision.service.inc +++ b/provision.service.inc @@ -8,6 +8,34 @@ require_once DRUSH_BASE_PATH . '/commands/core/rsync.core.inc'; class provisionService extends provisionChainedState { protected $server = '@server_master'; 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) { $this->server = d($server); @@ -25,10 +53,6 @@ class provisionService extends provisionChainedState { return TRUE; } - function init() { - return TRUE; - } - /** * Return service-specific configuration options for help. *