Index: trunk/extensions/Deployment/Deployment.i18n.php |
— | — | @@ -34,8 +34,9 @@ |
35 | 35 | 'deploy-ssh2-username-required' => 'SSH username is required', |
36 | 36 | 'deploy-ssh2-password-required' => 'SSH password or private key is required', |
37 | 37 | 'deploy-ssh2-hostname-required' => 'SSH hostname is required', |
38 | | - 'deploy-ftp-connect-failed' => 'Failed to connect to SSH2 server $1:$2', |
| 38 | + 'deploy-ssh2-connect-failed' => 'Failed to connect to SSH2 server $1:$2', |
39 | 39 | 'deploy-ssh2-key-authentication-failed' => 'Public and private keys are incorrect for username $1', |
40 | 40 | 'deploy-ssh2-password-authentication-failed' => 'Username or password incorrect for username $1', |
| 41 | + 'deploy-ssh2-command-failed' => 'Unable to perform command: $1', |
41 | 42 | |
42 | 43 | ); |
Index: trunk/extensions/Deployment/includes/filesystems/FtpFilesystem.php |
— | — | @@ -27,9 +27,9 @@ |
28 | 28 | /** |
29 | 29 | * The FTP connection link. |
30 | 30 | * |
31 | | - * @var resource |
| 31 | + * @var FTP resource or false |
32 | 32 | */ |
33 | | - protected $connection; |
| 33 | + protected $connection = false; |
34 | 34 | |
35 | 35 | /** |
36 | 36 | * Constructor. |
Index: trunk/extensions/Deployment/includes/filesystems/Ssh2Filesystem.php |
— | — | @@ -27,9 +27,9 @@ |
28 | 28 | /** |
29 | 29 | * The FTP connection link. |
30 | 30 | * |
31 | | - * @var FTP resource |
| 31 | + * @var FTP resource or false |
32 | 32 | */ |
33 | | - protected $connection; |
| 33 | + protected $connection = false; |
34 | 34 | |
35 | 35 | /** |
36 | 36 | * The SFTP connection link. |
— | — | @@ -95,6 +95,10 @@ |
96 | 96 | $options['port'] = 21; |
97 | 97 | } |
98 | 98 | |
| 99 | + if ( !array_key_exists( 'timeout', $options ) ) { |
| 100 | + $options['timeout'] = 240; |
| 101 | + } |
| 102 | + |
99 | 103 | // Store the options. |
100 | 104 | $this->options = $options; |
101 | 105 | } |
— | — | @@ -119,7 +123,7 @@ |
120 | 124 | } |
121 | 125 | |
122 | 126 | if ( $this->publicKeyAuthentication ) { |
123 | | - $ssh2_auth_pubkey_file = ssh2_auth_pubkey_file($this->link, $this->options['username'], $this->options['public_key'], $this->options['private_key'], $this->options['password'] ); |
| 127 | + $ssh2_auth_pubkey_file = ssh2_auth_pubkey_file( $this->link, $this->options['username'], $this->options['public_key'], $this->options['private_key'], $this->options['password'] ); |
124 | 128 | |
125 | 129 | if ( !$ssh2_auth_pubkey_file ) { |
126 | 130 | $this->addErrorMessage( wfMsgExt( 'deploy-ssh2-key-authentication-failed', $this->options['username'] ) ); |
— | — | @@ -308,4 +312,30 @@ |
309 | 313 | |
310 | 314 | } |
311 | 315 | |
| 316 | + /** |
| 317 | + * Executes a command. |
| 318 | + * |
| 319 | + * @param string $command |
| 320 | + */ |
| 321 | + protected function runCommand( $command ) { |
| 322 | + if ( !$this->connection ) { |
| 323 | + return false; |
| 324 | + } |
| 325 | + |
| 326 | + if ( $stream = ssh2_exec( $this->connection, $command ) ) { |
| 327 | + stream_set_blocking( $stream, true ); |
| 328 | + stream_set_timeout( $stream, $this->options['timeout'] ); |
| 329 | + |
| 330 | + $data = stream_get_contents( $stream ); |
| 331 | + |
| 332 | + fclose( $stream ); |
| 333 | + |
| 334 | + return $data; |
| 335 | + } |
| 336 | + else { |
| 337 | + $this->addErrorMessage( wfMsgExt( 'deploy-ssh2-command-failed', $command ) ); |
| 338 | + return false; |
| 339 | + } |
| 340 | + } |
| 341 | + |
312 | 342 | } |
\ No newline at end of file |