Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drush #2

Merged
merged 4 commits into from
Feb 25, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion php/Terminus/CommandWithSSH.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ protected function send_command($server, $remote_exec, $args, $assoc_args) {
$cmd = 'ssh -T ' . $server['user'] . '@' . $server['host'] . ' -p ' . $server['port'] . ' -o "AddressFamily inet"' . " '" . $remote_cmd . "'";

passthru( $cmd, $exit_code );
exit( $exit_code );
if ($result == 255) {
\Terminus::error("Failed to connect. Check your credentials, and that you are specifying a valid environment.");
}
return( $exit_code );
}
}
12 changes: 4 additions & 8 deletions php/commands/drush.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,19 @@ function __invoke( $args, $assoc_args ) {
Terminus::error("Command could not be completed.");
exit;
}
# TODO: validate environment quickly.
#if (!isset($site->environments->$environment)) {
# Terminus::error("The '$environment' environment does not exist.");
#}

# see https://github.com/pantheon-systems/titan-mt/blob/master/dashboardng/app/workshops/site/models/environment.coffee
$server = Array(
'user' => "$environment.$site->site_uuid",
'host' => "appserver.$environment.$site->site_uuid.drush.in",
'port' => '2222'
);

# Sanitize assoc args.
# Sanitize assoc args so we don't try to pass our own flags.
# TODO: DRY this out?
unset($assoc_args['site']);
if (isset($assoc_args['environment'])) {
unset($assoc_args['environment']);
}

# Create user-friendly output
$command = implode( $args, ' ' );
$flags = '';
Expand All @@ -64,7 +60,7 @@ function __invoke( $args, $assoc_args ) {
$flags .= "--$k";
}
}
Terminus::line( "Running drush $command $flags against $site_name-$environment" );
Terminus::line( "Running drush $command $flags on $site_name-$environment" );
$this->send_command($server, 'drush', $args, $assoc_args );
}

Expand Down
11 changes: 5 additions & 6 deletions php/commands/wp.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ function __invoke( $args, $assoc_args ) {
Terminus::error("Command could not be completed.");
exit;
}
# TODO: validate environment quickly.
#if (!isset($site->environments->$environment)) {
# Terminus::error("The '$environment' environment does not exist.");
#}

# see https://github.com/pantheon-systems/titan-mt/blob/master/dashboardng/app/workshops/site/models/environment.coffee
$server = Array(
Expand All @@ -48,11 +44,13 @@ function __invoke( $args, $assoc_args ) {
'port' => '2222'
);

# Sanitize assoc args.
# Sanitize assoc args so we don't try to pass our own flags.
# TODO: DRY this out?
unset($assoc_args['site']);
if (isset($assoc_args['environment'])) {
unset($assoc_args['environment']);
}

# Create user-friendly output
$command = implode( $args, ' ' );
$flags = '';
Expand All @@ -64,8 +62,9 @@ function __invoke( $args, $assoc_args ) {
$flags .= "--$k";
}
}
Terminus::line( "Running wp-cli $command $flags against $site_name-$environment" );
Terminus::line( "Running drush $command $flags on $site_name-$environment" );
$this->send_command($server, 'wp', $args, $assoc_args );

}

}
Expand Down