File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change 44
55namespace Hypernode \Deploy \Deployer \Task \Common ;
66
7+ use Deployer \Exception \RunException ;
78use Hypernode \Deploy \Deployer \Task \TaskBase ;
89use Hypernode \DeployConfiguration \Configuration ;
9- use Symfony \Component \Process \Exception \ProcessFailedException ;
1010
1111use function Deployer \get ;
1212use function Deployer \runLocally ;
@@ -31,16 +31,19 @@ public function configure(Configuration $config): void
3131 task ('prepare:ssh ' , function () {
3232 $ this ->configureKey ();
3333
34- if (testLocally ('ssh-add -l | grep -q "no identities" ' )) {
34+ $ agentHasNoIdentities = testLocally ('ssh-add -l | grep -q "no identities" ' );
35+ $ sshKeyFileExists = testLocally ('[ -f {{ssh_key_file}} ] ' );
36+
37+ if ($ agentHasNoIdentities && $ sshKeyFileExists ) {
3538 try {
3639 runLocally ('ssh-add -k {{ssh_key_file}} ' );
37- } catch (ProcessFailedException $ e ) {
40+ } catch (RunException $ e ) {
3841 writeln ('Failed to add key to ssh agent. ' );
3942 writeln ('Trying key {{ssh_key_file}} ' );
4043 try {
4144 $ keyMd5 = runLocally ('md5sum {{ssh_key_file}} ' );
4245 writeln ("With MD5 $ keyMd5 " );
43- } catch (ProcessFailedException $ e ) {
46+ } catch (RunException $ e ) {
4447 writeln ('Failed to get keyfile MD5 ' . $ e );
4548 }
4649 throw $ e ;
You can’t perform that action at this time.
0 commit comments