Skip to content

Instantly share code, notes, and snippets.

@jdillick
Last active December 24, 2015 02:39
Show Gist options
  • Save jdillick/6731777 to your computer and use it in GitHub Desktop.
Save jdillick/6731777 to your computer and use it in GitHub Desktop.

Revisions

  1. jdillick revised this gist Sep 27, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion aliases.drushrc.php
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    // paths to search for drupal sites
    $paths = array(
    '/var/www/multisites/',
    '/var/www/schoolyard/'
    '/var/www/schoolyard/',
    );

    $new_aliases = array();
  2. jdillick revised this gist Sep 27, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion aliases.drushrc.php
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    <?php
    // the current environment
    $env = $_ENV['ENVTYPE'];
    $env = $_ENV['ENVTYPE'] ? $_ENV['ENVTYPE'] : '';

    // paths to search for drupal sites
    $paths = array(
  3. jdillick revised this gist Sep 27, 2013. 1 changed file with 16 additions and 1 deletion.
    17 changes: 16 additions & 1 deletion aliases.drushrc.php
    Original file line number Diff line number Diff line change
    @@ -8,6 +8,7 @@
    '/var/www/schoolyard/'
    );

    $new_aliases = array();
    foreach ( $paths as $path ) {
    $dh = opendir($path);
    while ( $file = readdir($dh) ) {
    @@ -29,7 +30,7 @@
    // skip ./, ../, all/, and default/ directories
    if ( is_dir($sitepath) && ! in_array($site, array('default', '.', '..', 'all')) ) {
    // construct the site alias from the environment and domain
    $aliases[$file] = array(
    $new_aliases[$file][$site] = array(
    'root' => $fullname . ($has_webroot ? '/webroot/' : '/'),
    'uri' => (strpos($fullname, 'schoolyard') ? "http://$site" : "http://$env.$site"),
    );
    @@ -38,3 +39,17 @@
    }
    }
    }

    foreach ( $new_aliases as $file => $sites ) {
    // single site drupal install
    if ( count($sites) == 1 ) {
    $aliases[$file] = reset($sites);
    }
    // multisite drupal install
    else {
    foreach ( $sites as $name => $site ) {
    list($prefix, $suffix) = explode('.', $name);
    $aliases[$file . "." . $prefix] = $site;
    }
    }
    }
  4. jdillick revised this gist Sep 27, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion aliases.drushrc.php
    Original file line number Diff line number Diff line change
    @@ -30,7 +30,7 @@
    if ( is_dir($sitepath) && ! in_array($site, array('default', '.', '..', 'all')) ) {
    // construct the site alias from the environment and domain
    $aliases[$file] = array(
    'root' => $fullname . "/",
    'root' => $fullname . ($has_webroot ? '/webroot/' : '/'),
    'uri' => (strpos($fullname, 'schoolyard') ? "http://$site" : "http://$env.$site"),
    );
    }
  5. jdillick revised this gist Sep 27, 2013. 1 changed file with 6 additions and 4 deletions.
    10 changes: 6 additions & 4 deletions aliases.drushrc.php
    Original file line number Diff line number Diff line change
    @@ -14,11 +14,13 @@
    $fullname = "$path$file";

    // skip files, current directory, and parent directory
    if ( strpos('.', $file) === 0 || ! is_dir($fullname) ) continue;
    if ( strpos($file, '.') === 0 || ! is_dir($fullname) ) continue;

    // look for sites or webroot/sites directories in path
    if ( file_exists($fullname . '/sites/') || file_exists($fullname . '/webroot/sites/') ) {
    $sites = $fullname . (file_exists($fullname . '/sites/') ? '/sites/' : '/webroot/sites/');
    $has_webroot = file_exists($fullname . '/webroot/sites/');
    $has_sites = file_exists($fullname . '/sites/');
    if ( $has_webroot || $has_sites ) {
    $sites = $fullname . ($has_sites ? '/sites/' : '/webroot/sites/');
    $sh = opendir($sites);

    // look for domain.tld directory in sites
    @@ -29,7 +31,7 @@
    // construct the site alias from the environment and domain
    $aliases[$file] = array(
    'root' => $fullname . "/",
    'uri' => "http://$env.$site",
    'uri' => (strpos($fullname, 'schoolyard') ? "http://$site" : "http://$env.$site"),
    );
    }
    }
  6. jdillick revised this gist Sep 27, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion aliases.drushrc.php
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@
    $fullname = "$path$file";

    // skip files, current directory, and parent directory
    if ( strpos('.', $file) !== 0 || ! is_dir($fullname) ) continue;
    if ( strpos('.', $file) === 0 || ! is_dir($fullname) ) continue;

    // look for sites or webroot/sites directories in path
    if ( file_exists($fullname . '/sites/') || file_exists($fullname . '/webroot/sites/') ) {
  7. jdillick revised this gist Sep 27, 2013. 1 changed file with 8 additions and 5 deletions.
    13 changes: 8 additions & 5 deletions aliases.drushrc.php
    Original file line number Diff line number Diff line change
    @@ -4,18 +4,21 @@

    // paths to search for drupal sites
    $paths = array(
    $_ENV['HOME'] . '/clones/',
    $_ENV['HOME'] . '/sandboxes/drupal/'
    '/var/www/multisites/',
    '/var/www/schoolyard/'
    );

    foreach ( $paths as $path ) {
    $dh = opendir($path);
    while ( $file = readdir($dh) ) {
    $fullname = "$path$file";

    // look for sites directories in path
    if ( strpos('.', $file) === FALSE && is_dir($fullname) && file_exists($fullname . '/sites/') ) {
    $sites = $fullname . '/sites/';
    // skip files, current directory, and parent directory
    if ( strpos('.', $file) !== 0 || ! is_dir($fullname) ) continue;

    // look for sites or webroot/sites directories in path
    if ( file_exists($fullname . '/sites/') || file_exists($fullname . '/webroot/sites/') ) {
    $sites = $fullname . (file_exists($fullname . '/sites/') ? '/sites/' : '/webroot/sites/');
    $sh = opendir($sites);

    // look for domain.tld directory in sites
  8. jdillick created this gist Sep 27, 2013.
    35 changes: 35 additions & 0 deletions aliases.drushrc.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    <?php
    // the current environment
    $env = $_ENV['ENVTYPE'];

    // paths to search for drupal sites
    $paths = array(
    $_ENV['HOME'] . '/clones/',
    $_ENV['HOME'] . '/sandboxes/drupal/'
    );

    foreach ( $paths as $path ) {
    $dh = opendir($path);
    while ( $file = readdir($dh) ) {
    $fullname = "$path$file";

    // look for sites directories in path
    if ( strpos('.', $file) === FALSE && is_dir($fullname) && file_exists($fullname . '/sites/') ) {
    $sites = $fullname . '/sites/';
    $sh = opendir($sites);

    // look for domain.tld directory in sites
    while ( $site = readdir($sh) ) {
    $sitepath = $sites . $site;
    // skip ./, ../, all/, and default/ directories
    if ( is_dir($sitepath) && ! in_array($site, array('default', '.', '..', 'all')) ) {
    // construct the site alias from the environment and domain
    $aliases[$file] = array(
    'root' => $fullname . "/",
    'uri' => "http://$env.$site",
    );
    }
    }
    }
    }
    }