Skip to content

Instantly share code, notes, and snippets.

@sherakama
Last active March 20, 2018 21:50
Show Gist options
  • Save sherakama/7d97141d7bd43e933cd3 to your computer and use it in GitHub Desktop.
Save sherakama/7d97141d7bd43e933cd3 to your computer and use it in GitHub Desktop.
Wildcard remote aliases for sites.
<?php
## STANFORD WILDCARD ###########################################################
// The command you just typed in shell.
$command = $_SERVER['argv'];
$remote_user = "sheamck";
// Look at every argument...
foreach ($command as $arg) {
// There aren't many cases where there are '.'...
$test = explode('.', $arg);
$first = array_shift($test);
switch ($first) {
case "@sse":
// Set the project to be whatever the alias was.
$project_alias = str_replace('@', '', $arg);
$project_name = "ds_" . array_pop($test);
$shortname = str_replace("ds_", "", $project_name);
$uri = "https://sites.stanford.edu/" . $shortname;
$remote_host = "sites2.stanford.edu";
$root = '/var/www/' . $project_name . '/public_html';
break;
case "@uat":
// Set the project to be whatever the alias was.
$project_alias = str_replace('@', '', $arg);
$project_name = "ds_" . array_pop($test);
$shortname = str_replace("ds_", "", $project_name);
$uri = "https://sites-uat.stanford.edu/" . $shortname;
$remote_host = "sites-uat.stanford.edu";
$root = '/var/www/' . $project_name . '/public_html';
break;
case "@ppl":
// Set the project to be whatever the alias was.
$project_alias = str_replace('@', '', $arg);
$project_name = "dp_" . array_pop($test);
$shortname = str_replace("dp_", "", $project_name);
$uri = "https://people.stanford.edu/" . $shortname;
$remote_host = "people1.stanford.edu";
$root = '/var/www/' . $project_name . '/public_html';
break;
}
}
// Project alias; this will be sse.ds_foo, uat.ds_foo, or ppl.dp_sunetid.
$aliases[$project_alias] = array(
'remote-host' => $remote_host,
'remote-user' => $remote_user,
'root' => $root,
'uri' => $uri,
'path-aliases' => array(
'%dump-dir' => '/afs/ir/group/webservices/tmp',
),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment