blob: 9bde02e1ddf5fb1a142ea9fe4017ab32e32c27f1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail
script_dir="$( dirname -- "${BASH_SOURCE[0]}" )"
script_dir="$( cd -- "$script_dir" && pwd )"
readonly script_dir
dump() {
local prefix="${FUNCNAME[0]}"
[ "${#FUNCNAME[@]}" -gt 1 ] && prefix="${FUNCNAME[1]}"
local msg
for msg; do
echo "$prefix: $msg"
done
}
check_ssh_agent_running() {
if [ -z "${SSH_AUTH_SOCK+x}" ]; then
dump "SSH_AUTH_SOCK isn't defined (ssh-agent not running?)" >&2
return 1
fi
}
add_ssh_key() {
local password_path="$script_dir/password.txt"
local password
password="$( cat -- "$password_path" )"
local askpass_path
askpass_path="$( mktemp --tmpdir="$script_dir" )"
local askpass_rm
askpass_rm="$( printf -- 'rm -f -- %q' "$askpass_path" )"
trap "$askpass_rm" RETURN
chmod 0700 -- "$askpass_path"
local echo_password
echo_password="$( printf -- 'echo %q' "$password" )"
echo "$echo_password" > "$askpass_path"
local key_path="$HOME/.ssh/id_rsa"
ssh-add -D
DISPLAY="${DISPLAY-x}" SSH_ASKPASS="$askpass_path" ssh-add "$key_path" < /dev/null
}
main() {
check_ssh_agent_running
add_ssh_key
python3 -m pull.main "$@"
}
main "$@"
|