Commit 5d9a1535 authored by drumm's avatar drumm

merge

parent 969b1471
......@@ -171,5 +171,10 @@ To read :
Include /var/aegir/config/apache.conf
You will also need to create the following directories :
/var/aegir/config/platform.d
/var/aegir/config/apache.d
Now log into Aegir, and verify the hostmaster platform. This will generate
the correct apache.conf file and restart apache.
......@@ -22,7 +22,12 @@ endif;
LoadModule rewrite_module modules/mod_rewrite.so
</IfModule>
# virtual hosts
Include <?php print $config_path ?>/vhost.d/
# platforms
Include <?php print $config_path ?>/platform.d/
# other configuration, not touched by aegir
Include <?php print $config_path ?>/apache.d/
<?php print $extra_config; ?>
......@@ -139,6 +139,7 @@ fi
msg "Creating basic directory structure"
mkdir -p $AEGIR_HOME/config/vhost.d
mkdir -p $AEGIR_HOME/config/platform.d
mkdir -p $AEGIR_HOME/config/apache.d
mkdir -p $AEGIR_HOME/backups
chmod 0711 $AEGIR_HOME/config
chmod 0700 $AEGIR_HOME/backups
......@@ -211,8 +212,12 @@ NameVirtualHost *:80
LoadModule rewrite_module modules/mod_rewrite.so
</IfModule>
# virtual hosts
Include $AEGIR_HOME/config/vhost.d/
# platforms
Include $AEGIR_HOME/config/platform.d/
# other configuration, not touched by aegir
Include $AEGIR_HOME/config/apache.d/
EOF
fi
>>>>>>> master
......
......@@ -425,10 +425,6 @@ function provision_find_packages() {
$packages['profiles'][$profile] = _provision_find_packages('profiles', $profile);
}
// Iterate through the sites, finding site specific packages
foreach (drush_get_option('sites', array()) as $site) {
$packages['sites'][$site] = _provision_find_packages('sites', $site);
}
return $packages;
}
......@@ -481,6 +477,11 @@ function provision_drupal_system_map() {
$packages['profiles'][$profile]->status = 1;
foreach (_provision_system_query("module") as $module) {
$frags = explode("/", $module->filename);
// ignore site-specific modules
if ($frags[0] == 'sites' && $frags[1] != 'all') {
continue;
}
$info_file = sprintf("%s/%s.info", dirname($module->filename), $module->name);
$module->info = provision_parse_info_file($info_file);
......@@ -494,7 +495,13 @@ function provision_drupal_system_map() {
drush_log(dt("Found !count modules", array('!count' => sizeof($packages['modules']))));
// XXX: mostly a copy-paste from above
foreach (_provision_system_query("theme") as $theme) {
$frags = explode("/", $theme->filename);
// ignore site-specific themes
if ($frags[0] == 'sites' && $frags[1] != 'all') {
continue;
}
$info_file = sprintf("%s/%s.info", dirname($theme->filename), $theme->name);
$theme->info = provision_parse_info_file($info_file);
_provision_cvs_deploy($theme);
......@@ -551,7 +558,7 @@ function _provision_drupal_find_modules($scope, $key = '') {
$source = str_replace("\r\n", "\n", $source);
$source = str_replace("\r", "\n", $source);
$function_matches = array();
preg_match_all('!function\s*&?([a-zA-Z0-9_]+)_update_([0-9]+)\(.*?\s*\{!', $source, $function_matches);
preg_match_all('!function\s*&?([a-zA-Z0-9_]+)_update_([0-9]+)\s*\(.*?\s*\{!', $source, $function_matches);
if (sizeof($function_matches[0])) {
$schema_version = max($function_matches[2]);
......
......@@ -88,9 +88,14 @@ function drush_provision_drupal_post_provision_verify($url = NULL) {
* @see hook_provision_apache_dir_config()
*/
function provision_drupal_provision_apache_dir_config($data = null) {
$htaccess = file_get_contents(dirname(__FILE__) . "/provision_drupal_htaccess.tpl.php");
$htaccess = file_get_contents(drush_get_option('publish_path') . '/.htaccess');
$htaccess .= <<<EOF
<IfModule mod_rewrite.c>
# allow files to be accessed without /sites/fqdn/
RewriteRule ^files/(.*)$ /sites/%{HTTP_HOST}/files/$1 [L]
</IfModule>
# Do not read the platform's .htaccess
AllowOverride none
......
<?php
/**
* Provision environment API
*
*
*/
/**
* Store and access environment objects by their alias name
*
*/
function & d($name = '@self', $object = null, $root_object = FALSE) {
static $instances = null;
static $default_instance = '@self';
if ($name) {
if ($root_object) {
$default_instance = $name;
}
if (is_object($object)) {
$instances[$name] = $object;
}
if (isset($instances[$name])) {
return $instances[$name];
}
}
return $instances[$default_instance];
}
/**
* Create a new environment object and cache it in the d() static cache function.
*/
function provision_environment_factory($name, $options, $root_object = FALSE) {
$classes = array('provisionServer', 'provisionPlatform', 'provisionSite');
if (provisionServer::evaluate($options)) {
$classname = array_shift($classes);
if (provisionPlatform::evaluate($options)) {
$classname = array_shift($classes);
if (provisionSite::evaluate($options)) {
$classname = array_shift($classes);
}
}
}
d($name, new $classname($name, $options), $root_object);
d($name)->init();
d($name)->clean();
return d($name);
}
/**
* Base environment class.
*
* Contains magic getter/setter functions
*/
class provisionEnvironment {
protected $options = array();
protected $properties = array();
protected $map = array();
protected $name = null;
protected $type = null;
/**
* Retrieve value from $properties array if property does not exist in class proper.
*/
function __get($name) {
if (array_key_exists($name, $this->properties)) {
return $this->properties[$name];
}
}
/**
* Store value in properties array if the property does not exist in class proper.
*
* Keep a map of what the $this->type is when the value is set, so we can retrieve
* specific values later.
*/
function __set($name, $value) {
if (!property_exists($this, $name)) {
$this->properties[$name] = $value;
$this->map[$name] = (array_key_exists($name, $this->map)) ? $this->map[$name] : $this->type;
}
else {
$this->$name = $value;
}
}
/**
* Check the properties array if the property does not exist in the class proper.
*/
function __isset($name) {
if (property_exists($this->properties, $name) || property_exists($this, $name)) {
return TRUE;
}
return FALSE;
}
/**
* Remove the value from the properties array if the property does not exist in the class proper.
*/
function __unset($name) {
if (property_exists($this->properties, $name)) {
unset($this->properties[$name]);
}
elseif (property_exists($this, $name)) {
unset($this->$name);
}
}
/**
* Constructor for the environment.
*/
function __construct($name, $options) {
$this->name = $name;
$this->options = $options;
unset($this->options['packages']);
}
/**
* Init stub function/
*/
function init() {
return true;
}
/**
* Check the $options property for a field, saving to the properties array.
*/
function setProperty($field, $default = null) {
if (isset($this->options[$field])) {
$this->$field = $this->options[$field];
}
else {
$this->$field = $default;
}
}
/**
* Alter the map array to move a value between stacks.
*/
function setMap($field, $context) {
$this->map[$field] = $context;
}
}
/**
* Server environment class.
*
* This class bootstraps the Service API by generating server
* objects for each of the available service types.
*/
class provisionServer extends provisionEnvironment {
protected $services = array();
public static function evaluate($options) {
return TRUE;
}
function init() {
parent::init();
$this->type = 'server';
$this->setProperty('remote_host', 'localhost');
$this->setProperty('script_user', get_current_user());
$this->setProperty('aegir_root', '/var/aegir');
$this->setProperty('backup_path', $this->aegir_root . '/backup');
$this->setProperty('config_path', $this->aegir_root . '/config');
$this->setProperty('alias_path', $this->config_path . '/drush.d');
$this->setProperty('master_url');
$this->load_services();
}
/**
* Iterate through the available service types and spawn a handler for each type.
*/
function load_services() {
$service_list = drush_command_invoke_all('provision_services');
foreach ($service_list as $service => $default) {
$this->spawn_service($service, $default);
}
}
/**
* Spawn an instance for a specific service type and associate it to the owner.
*/
function spawn_service($service, $default = null) {
$reflect = new reflectionClass('provisionService_' . $service);
$base_dir = dirname($reflect->getFilename());
$type_option = "$service-service-type";
$type = isset($this->options[$type_option]) ? $this->options[$type_option] : $default;
if ($type) {
$file = sprintf("%s/%s/%s_service.inc", $base_dir, $type, $type);
$className = sprintf("provisionService_%s_%s", $service, $type);
if (file_exists($file)) {
drush_log("Loading $type driver for the $service service");
include_once($file);
$object = new $className($this->name);
$object->init();
$this->services[$service] = $object;
}
}
else {
$this->services[$service] = new provisionService_null();
}
}
/**
* Retrieve a service of a specific type from the environment.
*/
function service($service) {
return $this->services[$service];
}
}
/**
* Class for the platform environment.
*/
class provisionPlatform extends provisionServer {
public static function evaluate($options) {
if ($options['root']) {
return true;
}
}
function init() {
parent::init();
$this->type = 'platform';
$this->setProperty('root', $_SERVER['PWD']);
// publish path can really be removed ...
$this->setProperty('publish_path', $this->root);
$this->setProperty('sites_path', $this->root . '/sites');
}
}
class provisionSite extends provisionPlatform {
public static function evaluate($options) {
if ($options['uri']) {
return true;
}
}
function init() {
parent::init();
$this->type = 'site';
$this->setProperty('uri');
$this->setProperty('site_url', str_replace(array('https://', 'http://'), '', $this->uri));
$this->setProperty('language', 'en');
$this->setProperty('aliases', array());
$this->setProperty('site_port', 80);
$this->setProperty('client_email');
// todo - turn into a re-usable mechanism for comma separated values
if ($this->options['aliases'] && !is_array($site_data['aliases'])) {
$this->aliases = explode(",", $site_data['aliases']);
}
else {
$this->aliases = array();
}
// this can potentially be handled by a drupal sub class
$this->setProperty('profile', 'default');
}
}
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