Skip to content

Commit

Permalink
Fixing local settings files. (#364)
Browse files Browse the repository at this point in the history
Moving default settings files out of template.
  • Loading branch information
grasmash authored Sep 8, 2016
1 parent 5d6ef84 commit 27136a9
Show file tree
Hide file tree
Showing 23 changed files with 165 additions and 786 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ before_install:
- echo 'variables_order = "EGPCS"' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
# Ensure that always_populate_raw_post_data PHP setting: Not set to -1 does not happen.
- echo "always_populate_raw_post_data = -1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
# Increase PHP memory limit.
- echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- git config --global user.name "Travis-CI"
- git config --global user.email "noreply@travis-ci.org"
- mysql -e 'CREATE DATABASE drupal;'
Expand Down Expand Up @@ -90,6 +92,8 @@ script:
- cd ../blt
# Run 'blt' phpunit tests, excluding deploy-push tests.
- phpunit tests/phpunit --group blt --exclude-group deploy-push
# Execute 'blt update' just to ensure that there isn't a non-zero exit code.
# - blt update

deploy:
provider: script
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Use the following commands to create a testable BLT-created project alongside BL

```
git clone https://github.com/acquia/blt.git
composer install --working-dir=blt
cp -R blt/blt-project .
cd blt-project
git init
Expand Down
2 changes: 0 additions & 2 deletions phing/tasks/blt.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@
<fileset dir="${repo.root}">
<include name="composer.json" />
<include name="README.md" />
<include name="docroot/sites/*/settings.php" />
<include name="docroot/sites/*/settings/**/*" />
<include name="docroot/sites/*/local.drushrc.php" />
<include name="readme/**/*" />
<include name="scripts/git-hooks/*" />
Expand Down
5 changes: 0 additions & 5 deletions phing/tasks/filesets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@
<patternset refid="files.php"/>
</fileset>

<!-- @todo Add multisite subdirs. -->
<fileset dir="${docroot}/sites/default/settings" id="files.php.custom.settings" expandsymboliclinks="true">
<patternset refid="files.php"/>
</fileset>

<fileset dir="${repo.root}/tests" id="files.php.tests" expandsymboliclinks="true">
<patternset refid="files.php"/>
</fileset>
Expand Down
40 changes: 28 additions & 12 deletions phing/tasks/setup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,34 +61,47 @@
<echo>Making ${docroot}/sites/default/settings.php writable.</echo>
<chmod mode="0755" failonerror="false" file="${docroot}/sites/default/settings.php"/>
<echo>Ensuring that blt.settings.php is required by settings.php</echo>
<exec dir="${docroot}/sites/default" command="grep blt.settings.php settings.php || echo 'require DRUPAL_ROOT . &quot;/sites/default/settings/blt.settings.php&quot;;' >> settings.php" logoutput="true" checkreturn="true" level="info"/>
<exec dir="${docroot}/sites/default" command="grep blt.settings.php settings.php || echo 'require DRUPAL_ROOT . &quot;/../vendor/acquia/blt/settings/blt.settings.php&quot;;' >> settings.php" logoutput="true" checkreturn="true" level="info"/>

<echo>Generating local settings files.</echo>
<!--@todo Check that install_profile is set in settings.php.-->

<if>
<not>
<available file="${repo.root}/project.local.yml" type="file" />
</not>
<not><available file="${repo.root}/project.local.yml" type="file" /></not>
<then>
<copy file="${repo.root}/example.project.local.yml" tofile="${repo.root}/project.local.yml" />
</then>
</if>

<if>
<not>
<available file="${docroot}/sites/${multisite.name}/settings/local.settings.php" type="file" />
</not>
<not><available file="${docroot}/sites/${multisite.name}/settings/local.settings.php" type="file" /></not>
<then>
<copy file="${docroot}/sites/${multisite.name}/settings/default.local.settings.php" tofile="${docroot}/sites/${multisite.name}/settings/local.settings.php" />
<if>
<available file="${docroot}/sites/${multisite.name}/settings/default.local.settings.php" type="file" />
<then>
<copy file="${docroot}/sites/${multisite.name}/settings/default.local.settings.php" tofile="${docroot}/sites/${multisite.name}/settings/local.settings.php" />
</then>
<else>
<copy file="${blt.root}/settings/default.local.settings.php" tofile="${docroot}/sites/${multisite.name}/settings/default.local.settings.php" />
<copy file="${blt.root}/settings/default.local.settings.php" tofile="${docroot}/sites/${multisite.name}/settings/local.settings.php" />
</else>
</if>
</then>
</if>

<if>
<not>
<available file="${docroot}/sites/${multisite.name}/local.drushrc.php" type="file" />
</not>
<not><available file="${docroot}/sites/${multisite.name}/local.drushrc.php" type="file" /></not>
<then>
<copy file="${docroot}/sites/${multisite.name}/default.local.drushrc.php" tofile="${docroot}/sites/${multisite.name}/local.drushrc.php"/>
<if>
<available file="${docroot}/sites/${multisite.name}/default.local.drushrc.php" type="file" />
<then>
<copy file="${docroot}/sites/${multisite.name}/default.local.drushrc.php" tofile="${docroot}/sites/${multisite.name}/local.drushrc.php" />
</then>
<else>
<copy file="${blt.root}/settings/default.local.drushrc.php" tofile="${docroot}/sites/${multisite.name}/default.local.drushrc.php" />
<copy file="${blt.root}/settings/default.local.drushrc.php" tofile="${docroot}/sites/${multisite.name}/local.drushrc.php" />
</else>
</if>
</then>
</if>

Expand All @@ -109,6 +122,9 @@
description="Installs a specific Drupal site."
depends="setup:drupal:settings, setup:hash-salt, configure">

<echo>Printing drush status.</echo>
<drush command="status" alias="${drush.alias}"/>

<echo>Installing Drupal.</echo>
<drush command="site-install" assume="yes" verbose="TRUE" alias="${drush.alias}">
<option name="site-name">"${project.human_name}"</option>
Expand Down
1 change: 0 additions & 1 deletion phing/tasks/validate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
<phplint>
<fileset refid="files.php.custom.modules"/>
<fileset refid="files.php.custom.themes"/>
<fileset refid="files.php.custom.settings"/>
<fileset refid="files.php.tests"/>
</phplint>
</target>
Expand Down
1 change: 1 addition & 0 deletions scripts/blt/convert-to-composer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "* Restart your terminal session to register your new blt alias."
echo "* Review your codebase and commit the desired changes."
echo " * If you have a custom Phing build file, you will likely need to update it and add it to project.yml under the 'import' key. See readme/extending-blt.md."
echo " * If you had custom files in docroot/sites/default/settings, you will need to restore them."
echo " * If you are not using Lightning, remove lightning-specific target-hooks from project.yml."
# link to online docs

Expand Down
8 changes: 8 additions & 0 deletions scripts/blt/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
# This script will be run every single time that `blt update` is executed.

rm -rf build
rm -rf docroot/sites/default/settings/base.settings.php
rm -rf docroot/sites/default/settings/blt.settings.php
rm -rf docroot/sites/default/settings/cache.settings.php
rm -rf docroot/sites/default/settings/filesystem.settings.php
rm -rf docroot/sites/default/settings/logging.settings.php
rm -rf docroot/sites/default/settings/travis.settings.php
rm -rf docroot/sites/default/settings/pipelines.settings.php
rm -rf docroot/sites/default/settings/tugboat.settings.php
rm -rf tests/phpunit/blt
rm -rf scripts/blt
rm -rf scripts/drupal
Expand Down
File renamed without changes.
122 changes: 122 additions & 0 deletions settings/blt.settings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<?php

/*******************************************************************************
* Setup BLT utility variables.
******************************************************************************/

/**
* Host detection.
*/
if (!empty($_SERVER['HTTP_X_FORWARDED_HOST'])) {
$forwarded_host = $_SERVER['HTTP_X_FORWARDED_HOST'];
}
elseif(!empty($_SERVER['HTTP_HOST'])) {
$forwarded_host = $_SERVER['HTTP_HOST'];
}
else {
$forwarded_host = NULL;
}

$server_protocol = empty($_SERVER['HTTPS']) ? 'http' : 'https';
$forwarded_protocol = !empty($_ENV['HTTP_X_FORWARDED_PROTO']) ? $_ENV['HTTP_X_FORWARDED_PROTO'] : $server_protocol;

/**
* Environment detection.
*
* Note that the values of enviromental variables are set differently on Acquia
* Cloud Free tier vs Acquia Cloud Professional and Enterprise.
*/
$ah_env = isset($_ENV['AH_SITE_ENVIRONMENT']) ? $_ENV['AH_SITE_ENVIRONMENT'] : NULL;
$ah_group = isset($_ENV['AH_SITE_GROUP']) ? $_ENV['AH_SITE_GROUP'] : NULL;
$is_ah_env = (bool) $ah_env;
$is_ah_prod_env = ($ah_env == 'prod' || $ah_env == '01live');
$is_ah_stage_env = ($ah_env == 'test' || $ah_env == '01test');
$is_ah_dev_cloud = (!empty($_SERVER['HTTP_HOST']) && strstr($_SERVER['HTTP_HOST'], 'devcloud'));
$is_ah_dev_env = (preg_match('/^dev[0-9]*$/', $ah_env) || $ah_env == '01dev');
$is_acsf = (!empty($ah_group) && file_exists("/mnt/files/$ah_group.$ah_env/files-private/sites.json"));
$acsf_db_name = $is_acsf ? $GLOBALS['gardens_site_settings']['conf']['acsf_db_name'] : NULL;
$is_local_env = !$is_ah_env;

/*******************************************************************************
* BLT includes & BLT default configuration.
******************************************************************************/

// Includes caching configuration.
require __DIR__ . '/cache.settings.php';

// Includes logging configuration.
require __DIR__ . '/logging.settings.php';

// Includes filesystem configuration.
require __DIR__ . '/filesystem.settings.php';

// Prevent APCu memory exhaustion.
$settings['container_yamls'][] = __DIR__ . '/apcu_fix.yml';

/**
* Salt for one-time login links, cancel links, form tokens, etc.
*
* This variable will be set to a random value by the installer. All one-time
* login links will be invalidated if the value is changed. Note that if your
* site is deployed on a cluster of web servers, you must ensure that this
* variable has the same value on each server.
*
* For enhanced security, you may set this variable to the contents of a file
* outside your document root; you should also ensure that this file is not
* stored with backups of your database.
*
* Example:
* @code
* $settings['hash_salt'] = file_get_contents('/home/example/salt.txt');
* @endcode
*/
$settings['hash_salt'] = file_get_contents(DRUPAL_ROOT . '/../salt.txt');


/*******************************************************************************
* Environment-specific includes.
******************************************************************************/

/**
* Acquia Cloud settings.
*/
if ($is_ah_env && file_exists('/var/www/site-php')) {
require "/var/www/site-php/{$_ENV['AH_SITE_GROUP']}/{$_ENV['AH_SITE_GROUP']}-settings.inc";

// Store API Keys and things outside of version control.
// @see settings/sample-secrets.settings.php for sample code.
$secrets_file = sprintf('/mnt/gfs/%s.%s/secrets.settings.php', $_ENV['AH_SITE_GROUP'], $_ENV['AH_SITE_ENVIRONMENT']);
if (file_exists($secrets_file)) {
require $secrets_file;
}
}

/**
* Load local development override configuration, if available.
*
* Use local.settings.php to override variables on secondary (staging,
* development, etc) installations of this site. Typically used to disable
* caching, JavaScript/CSS compression, re-routing of outgoing emails, and
* other things that should not happen on development and testing sites.
*
* Keep this code block at the end of this file to take full effect.
*/
if ($is_local_env) {
// Load local machine settings.
if (file_exists(DRUPAL_ROOT . '/sites/default/settings/local.settings.php')) {
require DRUPAL_ROOT . '/sites/default/settings/local.settings.php';
}

// Load Acquia Pipeline settings.
if (getenv('PIPELINE_ENV') && file_exists(__DIR__ . '/pipelines.settings.php')) {
require __DIR__ . '/pipelines.settings.php';
}
// Load Travis CI settings.
elseif (getenv('TRAVIS') && file_exists(__DIR__ . '/travis.settings.php')) {
require __DIR__ . '/travis.settings.php';
}
// Load Tugboat settings.
elseif (getenv('TUGBOAT_URL') && file_exists(__DIR__ . '/tugboat.settings.php')) {
require __DIR__ . '/tugboat.settings.php';
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions template/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"drupal/security_review" : "8.*",
"roave/security-advisories": "dev-master",
"drupal-composer/drupal-security-advisories": "8.0.x-dev",
"drupal-composer/drupal-scaffold": "^2.0.0",
"drupal/lightning": "8.1.03",
"drupal/metatag": "8.1.0-beta9"
},
Expand Down
Loading

0 comments on commit 27136a9

Please sign in to comment.