Skip to content

Commit af7ee87

Browse files
committed
Merge pull request pocketarc#40 from sergeyvolkov/master
Added the password prompt in the terminal
2 parents f0bfd16 + 5e55a58 commit af7ee87

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

deploy.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44

55
skip = false
66
user = example
7+
; remove this options and enter a password in the terminal
78
pass = password
89
host = example.com
910
port = 21
1011
path = /path/to/installation
1112
passive = true
1213

1314
; If that seemed too long for you, you can specify servers like this:
14-
[ftp://example:password@example.com:21/path/to/installation]
15+
[ftp://example:password@example.com:21/path/to/installation]

git-deploy

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,6 @@ class Config {
617617
'host' => '',
618618
'user' => '',
619619
'branch' => null,
620-
'pass' => '',
621620
'port' => 21,
622621
'path' => '/',
623622
'passive' => true,
@@ -626,6 +625,10 @@ class Config {
626625
'upload_untracked' => array()
627626
), $options);
628627

628+
if (!isset($options['pass'])) {
629+
$options['pass'] = self::promptPassword();
630+
}
631+
629632
if ($options['skip']) {
630633
continue;
631634
} else {
@@ -639,6 +642,24 @@ class Config {
639642
return $return;
640643
}
641644

645+
public static function promptPassword() {
646+
$prompt = 'Enter ftp password: ';
647+
648+
$command = "/usr/bin/env bash -c 'echo OK'";
649+
if (rtrim(shell_exec($command)) !== 'OK') {
650+
trigger_error("Can't invoke bash");
651+
return;
652+
}
653+
654+
$command = "/usr/bin/env bash -c 'read -s -p \""
655+
. addslashes($prompt)
656+
. "\" mypassword && echo \$mypassword'";
657+
$password = rtrim(shell_exec($command));
658+
echo "\n";
659+
660+
return $password;
661+
}
662+
642663
}
643664

644665
#### PHP SEC LIB 0.3.5
@@ -32098,4 +32119,4 @@ class Net_SSH2 {
3209832119
}
3209932120
}
3210032121

32101-
main();
32122+
main();

0 commit comments

Comments
 (0)