Skip to content

Instantly share code, notes, and snippets.

@rupl
Created August 19, 2011 21:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rupl/1158118 to your computer and use it in GitHub Desktop.
Save rupl/1158118 to your computer and use it in GitHub Desktop.
Allows regular drush commands without -l arg when using super awesome dynamic vhost
/**
* Allow developers to override settings.
*/
define('SWEET_ASS_STAGE_SETTINGS_REGEX', '/^(dca11\.webchefs\.org|dca11\.dev1\.fourkitchens\.com)(:\d+)*$/');
define('SWEET_ASS_USER_SETTINGS_REGEX', '/^(.*)\.(.*)\.(webchefs\.org|dev1\.fourkitchens\.com)(:\d+)*$/');
if (preg_match(SWEET_ASS_USER_SETTINGS_REGEX, $_SERVER['HTTP_HOST'], $matches)) {
// Load general dev settings.
if (file_exists('sites/default/settings.dev.php')) {
include_once 'sites/default/settings.dev.php';
}
// Load user specific settings.
if (file_exists('sites/default/settings_' . $matches[1] . '.php')) {
include_once 'sites/default/settings_' . $matches[1] . '.php';
}
} elseif (preg_match(SWEET_ASS_STAGE_SETTINGS_REGEX, $_SERVER['HTTP_HOST'])) {
if (file_exists('sites/default/settings.stage.php')) {
include_once 'sites/default/settings.stage.php';
}
} else {
// fallback
if (file_exists('sites/default/settings_' . getenv(USER) . '.php')) {
include_once 'sites/default/settings_' . getenv(USER) . '.php';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment