Commit 5c6f9360 authored by colan's avatar colan

Issue #3036890 by colan, ergonlogic, llamech: Merge branch '3036890-simplify-subdirs' into 7.x-3.x

parents 6a88fc00 75f7a53f
<?php
/**
* @file
* Provides the Provision_Config_Drupal_Services class.
*/
class Provision_Config_Drupal_Services extends Provision_Config {
public $template = 'aegir.services.tpl.php';
public $description = 'Drupal aegir.services.yml file';
protected $mode = 0440;
function filename() {
return $this->site_path . '/aegir.services.yml';
}
function process() {
$this->version = provision_version();
$this->cookie_domain = $this->getCookieDomain();
$this->group = $this->platform->server->web_group;
}
/**
* Extract our cookie domain from the URI.
*/
protected function getCookieDomain() {
$uri = explode('.', $this->uri);
# Leave base domain; only strip out subdomains.
if (count($uri) > 2) {
$uri[0] = '';
}
return implode('.', $uri);
}
}
---
# This file was automatically generated by Aegir <?php print $this->version; ?>
# on <?php print date('r'); ?>.
parameters:
session.storage.options:
cookie_domain: '<?php print $this->cookie_domain; ?>'
......@@ -23,6 +23,7 @@ print '<?php' ?>
*/
if (isset($_SERVER['SITE_SUBDIR']) && isset($_SERVER['RAW_HOST'])) {
$base_url = 'http://' . $_SERVER['RAW_HOST'] . '/' . $_SERVER['SITE_SUBDIR'];
ini_set('session.cookie_path', '/' . $_SERVER['SITE_SUBDIR'] . '/');
}
<?php endif; ?>
......@@ -163,6 +164,7 @@ if (isset($_SERVER['db_name'])) {
/**
* Load services definition file.
*/
$settings['container_yamls'][] = __DIR__ . '/aegir.services.yml';
$settings['container_yamls'][] = __DIR__ . '/services.yml';
/**
......
......@@ -19,10 +19,10 @@ class Provision_Config_Drushrc_Alias extends Provision_Config_Drushrc {
function __construct($context, $data = array()) {
parent::__construct($context, $data);
if (is_array($data['aliases'])) {
if (isset($data['aliases']) && is_array($data['aliases'])) {
$data['aliases'] = array_unique($data['aliases']);
}
if (is_array($data['drush_aliases'])) {
if (isset($data['drush_aliases']) && is_array($data['drush_aliases'])) {
$data['drush_aliases'] = array_unique($data['drush_aliases']);
}
......
......@@ -1109,9 +1109,11 @@ location ^~ /<?php print $subdir; ?> {
fastcgi_param db_host <?php print urlencode($db_host); ?>;
fastcgi_param db_port <?php print urlencode($db_port); ?>;
fastcgi_param HTTP_HOST <?php print $this->uri; ?>;
fastcgi_param HTTP_HOST $host;
fastcgi_param RAW_HOST $host;
fastcgi_param SITE_SUBDIR <?php print $subdir; ?>;
fastcgi_param SCRIPT_URL /<?php print $subdir; ?>/;
fastcgi_param SCRIPT_URI $scheme://$host/<?php print $subdir; ?>/;
fastcgi_param MAIN_SITE_NAME <?php print $this->uri; ?>;
fastcgi_param REDIRECT_STATUS 200;
......@@ -1119,6 +1121,8 @@ location ^~ /<?php print $subdir; ?> {
set $real_fastcgi_script_name index.php;
fastcgi_param SCRIPT_FILENAME <?php print "{$this->root}"; ?>/$real_fastcgi_script_name;
fastcgi_param SCRIPT_NAME /<?php print $subdir; ?>/$real_fastcgi_script_name;
fastcgi_param PHP_SELF /<?php print $subdir; ?>/$real_fastcgi_script_name;
add_header Cache-Control "no-store, no-cache, must-revalidate, post-check=0, pre-check=0";
tcp_nopush off;
......
......@@ -366,8 +366,14 @@ function install_main() {
$client_email = install_validate_client_email(drush_get_option('client_email', FALSE));
$account = install_create_admin_user($client_email);
$onetime = user_pass_reset_url($account);
// Store the one time login link in an option so the front end can direct the user to their new site.
// If a redirect is defined, the symlink to the alias needs to exist before
// we generate the login link, below.
_provision_drupal_maintain_aliases();
// Store the one time login link in an option so the front end can direct the
// user to their new site.
$onetime = provision_generate_login_reset();
drush_set_option('login_link', $onetime . '/login');
drush_log(dt('Login url: !onetime', array('!onetime' => $onetime . '/login')), 'success');
......
......@@ -158,10 +158,16 @@ function install_main() {
_provision_drupal_create_directories();
$account = user_load(1);
$onetime = user_pass_reset_url($account);
// Store the one time login link in an option so the front end can direct the user to their new site.
drush_set_option('login_link', $onetime . '/login');
drush_log(dt('Login url: !onetime', array('!onetime' => $onetime . '/login')), 'success');
// If a redirect is defined, the symlink to the alias needs to exist before
// we generate the login link, below.
_provision_drupal_maintain_aliases();
// Store the one time login link in an option so the front end can direct the
// user to their new site.
$onetime = provision_generate_login_reset();
drush_set_option('login_link', $onetime);
drush_log(dt('Login url: !onetime', array('!onetime' => $onetime)), 'success');
if (drush_get_option('client_email', FALSE)) {
install_send_welcome_mail($url, $account, $install_locale, $client_email, $onetime);
......
......@@ -159,8 +159,13 @@ function install_main() {
$account = user_load(1);
$onetime = user_pass_reset_url($account);
// Store the one time login link in an option so the front end can direct the user to their new site.
// If a redirect is defined, the symlink to the alias needs to exist before
// we generate the login link, below.
_provision_drupal_maintain_aliases();
// Store the one time login link in an option so the front end can direct the
// user to their new site.
$onetime = provision_generate_login_reset();
drush_set_option('login_link', $onetime);
drush_log(dt('Login url: !onetime', array('!onetime' => $onetime)), 'message');
......
......@@ -168,8 +168,12 @@ function provision_drupal_fetch_site($alias = NULL) {
* Generate a settings file for the site.
*/
function _provision_drupal_create_settings_file() {
$config = new Provision_Config_Drupal_Settings(d()->name, drush_get_context('site'));
$config->write();
$name = d()->name;
$context = drush_get_context('site');
$settings = new Provision_Config_Drupal_Settings($name, $context);
$settings->write();
$services = new Provision_Config_Drupal_Services($name, $context);
$services->write();
}
/**
......
......@@ -15,9 +15,9 @@
* Generate a one-time login reset url
*/
function drush_provision_drupal_provision_login_reset() {
// pass the login link to the front end
drush_set_option('browser', FALSE);
$onetime = drush_user_login();
drush_set_option('login_link', $onetime);
drush_log(dt('Login url: !onetime', array('!onetime' => $onetime)), 'success');
$uri = d()->redirection ?: d()->uri;
$result = drush_invoke_process(d()->name, 'user-login', array(), array('uri' => $uri, 'no-browser' => TRUE));
drush_set_option('login_link', $result['output']);
drush_log(dt('Login url: !onetime', array('!onetime' => $result['output'])), 'success');
}
......@@ -491,3 +491,12 @@ function provision_hosting_feature_enabled($feature) {
return array_key_exists($feature, $features) && $features[$feature];
}
/**
* Generate one-time login link
*/
function provision_generate_login_reset() {
$uri = d()->redirection ?: d()->uri;
$result = drush_invoke_process(d()->name, 'user-login', array(), array('uri' => $uri, 'no-browser' => TRUE));
return $result['output'];
}
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