Drupal 7 version of ucb_envconf
Shell
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
CHANGELOG.md
README.md
rebuild.sh
ucberkeley_envconf.info
ucberkeley_envconf.install
ucberkeley_envconf.module

README.md

ucberkeley_envconf

PURPOSE

UCB Environment Configurations (ucb_envconf) is a small module that defines configuration depending on the environment (dev/test/live) of the site. When developing a Drupal site in a dev/test/live environment the developer will often load her dev site with the live database. (Consider the Pantheon dashboard funtion "Sync content and pull code.") Unless the developer manually updates certain settings, the dev site will receive some settings that should be specific to production.

ucb_envconf automatically forces certain settings to their correct values based on the site's environment. It does this via hook_boot(). The module takes pains to do as little as possible in hook_boot so as not to negatively affect site performance.

Basically:

if ($site_env == 'live') { $conf['cas_server'] = 'auth.berkeley.edu'; } elseif ($site_env == 'dev') OR ($site_env == 'test') { $conf['cas_server'] = 'auth-test.berkeley.edu'; }

There are a number of different ways that this goal might be achieved:

  1. Insert conditional logic into settings.php
  2. Use a module like this one
  3. Write a Rule triggered by cron

We chose #2 because

  • We can limit user confusion by doing form_alters explaining about hard-coded variables which don't change when admin forms are submitted.

  • Users can easily disable the module if they don't like the functionality. They don't have to go edit code in settings.php. They don't have to disable rules.

CAS

Should auth.berkeley.edu become unavailable, quickly switch to the backup CAS server (cas-p4.calnet.berkeley.edu) with drush vset ucberkeley_envconf_cas_backup_server_enabled 1 (0 == off).

LDAP

Prior to 2.0 this code was setting the LDAP server (used by CAS Attributes) to ldap-test.berkeley.edu in the dev and test environments. In 2.0 we began using ldap.berkeley.edu (production LDAP) in all environments, because the dev and test environments require production-level availability of the LDAP server.

Notes

drush @somealias vget cas_server

Because this module applies configuration on hook_boot() and because hook_boot doesn't run when you issue 'drush vget', you will encounter situations where 'drush vget' reports the wrong value. If you visit the corresponding admin page, you should see the right value.

Theorectically you could get the correct value with

drush @somealias php-eval "echo variable_get('cas_server', NULL);"