Commit 334d7df2 authored by Jon Pugh's avatar Jon Pugh

Merge branch '7.x-3.x' of git.drupal.org:project/provision into 3016995-file-path-properties

parents ea5f05df 0dc24e83
<?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; ?>'
......@@ -160,7 +160,6 @@ if (isset($_SERVER['db_name'])) {
/**
* Load services definition file.
*/
$settings['container_yamls'][] = __DIR__ . '/aegir.services.yml';
$settings['container_yamls'][] = __DIR__ . '/services.yml';
/**
......
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1
mQINBE6UpTYBEACl8WyZrrcbMe4wfFQW2HMJP9PrDolioDlZZDpC9VesU2E1WFTW
jOZQY33HG/89evHLWg78JVo57z+OgmFS4bv7aGoynId5KfSF/azI9ibRCWMXHBa+
Mp8Pk+ufb3InYe7thOJQ9q1DGf/jg42+a31rpsiW58+HGACn3fIhdU8MhVcZ45NS
gVJI0yeOnacpvtMCmQwTZdhmG4d9hV7RcaN46fWz1Ys0qPJ3PGaRK7R4Qb6/+hPg
p9tvfjyUw0e6dWmAgHkoo54mpiYdPgD6+S7nuqbeFGzai1GVcwCH9Ec6/E9L4wnD
c0rvstyyBlaGyPSakViw46ZbE2VQK/uPEciqBmJUm8Yzh3uOhk5ufS11hC4S3F/t
VeJWZwIEBQGX0a81eMDtu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ZnkAxPcm6rb//OEP99iX9R
LMwXV3EGKPmTED4=
=T1Aq
=CdGR
-----END PGP PUBLIC KEY BLOCK-----
aegir3-provision (3.182) testing; urgency=medium
* Mini-release to update the bundled dehydrated lib for LetsEncrypt.
-- Herman van Rink <helmo@initfour.nl> Tue, 08 Oct 2019 21:50:20 +0200
aegir3-provision (3.181ubuntu1) testing; urgency=medium
* New mini-release required for update to Debian repo PGP key (https://www.drupal.org/project/hostmaster/issues/3085544)
-- Colan Schwartz <13228-colan@users.noreply.gitlab.com> Fri, 04 Oct 2019 16:16:36 -0400
aegir3-provision (3.180) unstable; urgency=medium
* Bugfixes and UI improvements, see http://aegir.readthedocs.org/en/3.x/release-notes/3.18
......
......@@ -25,16 +25,21 @@ function drush_provision_drupal_provision_install_validate() {
drush_log(dt('Forcing reinstall...'), 'ok');
// Load the current database name from drushrc.php.
// I cannot find another way to find the current db_name!
require_once(d()->site_path . '/drushrc.php');
$old_db_name = $options['db_name'];
if (d()->service('db')->database_exists($old_db_name)) {
d()->service('db')->drop_database($old_db_name);
drush_log(dt('Dropped database @database.', array(
'@database' => $old_db_name,
)), 'ok');
// Drop the database if we can figure out what it is.
// If last install failed, the database and the site folder is deleted.
if (file_exists(d()->site_path . '/drushrc.php')) {
// Load the current database name from drushrc.php.
// I cannot find another way to find the current db_name!
require_once(d()->site_path . '/drushrc.php');
$old_db_name = $options['db_name'];
if (d()->service('db')->database_exists($old_db_name)) {
d()->service('db')->drop_database($old_db_name);
drush_log(dt('Dropped database @database.', array(
'@database' => $old_db_name,
)), 'ok');
}
}
// Destroy site_path.
......@@ -46,7 +51,9 @@ function drush_provision_drupal_provision_install_validate() {
// Check again if site does not exist after the forced reinstall.
if (_provision_drupal_site_exists()) {
return drush_set_error('PROVISION_SITE_INSTALLED');
return drush_set_error('PROVISION_SITE_INSTALLED', dt('The file !file still exists. Provision was unable to delete it.', array(
'!file' => d()->site_path . '/settings.php',
)));
}
}
}
......
......@@ -178,12 +178,8 @@ function provision_drupal_fetch_site($alias = NULL) {
* Generate a settings file for the site.
*/
function _provision_drupal_create_settings_file() {
$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();
$config = new Provision_Config_Drupal_Settings(d()->name, drush_get_context('site'));
$config->write();
}
/**
......@@ -659,6 +655,9 @@ function provision_parse_info_file($filename) {
* The real credentials are stored in the Apache vhost of the relevant site, to prevent leaking of
* sensitive data to site administrators with PHP access who might otherwise access such credentials
* potentially of other sites' settings.php in a multisite set-up.
*
* Fire hook_provision_prepare_environment() so other scripts can react to this
* step and add more information or take other actions.
*/
function provision_prepare_environment() {
$fields = array('db_type', 'db_host', 'db_user', 'db_passwd', 'db_name', 'db_port');
......@@ -670,6 +669,11 @@ function provision_prepare_environment() {
if (drush_drupal_major_version() >= 7) {
$_SERVER['db_type'] = ($_SERVER['db_type'] == 'mysqli') ? 'mysql' : $_SERVER['db_type'];
}
// Invoke provision_prepare_environment: Allow other scripts to react to the
// preparation of the environment variables.
drush_command_invoke_all('provision_prepare_environment');
}
......
......@@ -178,5 +178,14 @@ function drush_provision_drupal_post_provision_verify() {
_provision_client_create_symlink();
drush_include_engine('drupal', 'cron_key');
# Cleanup useless `aegir.services.yml` files.
# See: https://www.drupal.org/project/provision/issues/3066538
$path = d()->site_path . '/aegir.services.yml';
if (provision_file()->exists($path)->status()) {
provision_file()->unlink($path)
->succeed('Cleaned up unused Aegir services.yml file.')
->fail('Failed to clean up unused Aegir services.yml file.', 'PROVISION_DELETE_AEGIR_SERVICES_YML_FAILED');
}
}
}
......@@ -317,6 +317,31 @@ function hook_provision_config_variables_alter(&$variables, $template, $config)
}
}
/**
* Implements hook_provision_platform_sync_path_alter().
*
* Changes the sync_path to ensure that composer-built platforms get all of the
* code moved to remote servers.
*
* @see provision_git_provision_platform_sync_path_alter()
*`
* @param $sync_path
* If the site is hosted on a remote server, this is the path that will be
* rsync'd over.
*/
function hook_provision_platform_sync_path_alter(&$sync_path) {
$repo_path = d()->platform->repo_path;
if ($repo_path != d()->root) {
$sync_path = $repo_path;
if (!file_exists($repo_path)) {
return drush_set_error('PROVISION_ERROR', dt("Platform !path does not exist.", array(
'!path' => $repo_path,
)));
}
}
}
/**
* Alter the array of directories to create.
*
......@@ -418,3 +443,34 @@ function hook_provision_mysql_regex_alter(&$regexes) {
'#/\*!50001 CREATE ALGORITHM=UNDEFINED \*/#' => "/*!50001 CREATE */",
);
}
/**
* Implements hook_provision_prepare_environment()
*
* React to the setting up of $_SERVER variables such as db_name and db_passwd.
*
* Runs right after writing sites/$URI/drushrc.php.
* Database credentials are available in the $_SERVER variables.
*
* @see provision_prepare_environment()
*/
function hook_provision_prepare_environment() {
// Write a .env file in the root of the project with the Drupal DB credentials.
// This file could be used by other tools to access the site's database.
$file_name = d()->root . '/.env';
$file_contents = <<<ENV
MYSQL_DATABASE={$_SERVER['db_name']}
MYSQL_USER={$_SERVER['db_name']}
MYSQL_PASSWORD={$_SERVER['db_name']}
ENV;
// Make writable, then write the file.
if (file_exists($file_name) && !is_writable($file_name)) {
provision_file()->chmod($file_name, 0660);
}
file_put_contents($file_name, $file_contents);
// Hide sensitive information from any other users.
provision_file()->chmod($file_name, 0400);
}
\ No newline at end of file
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