diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2018-07-02 04:35:42 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2018-07-02 04:35:42 +0300 |
commit | b33664f5225e6fadde76ff9273d0e8851dec02d1 (patch) | |
tree | 6688a239ef383be10b40865ec48e8d6812bae324 /pull.sh | |
download | cgitize-b33664f5225e6fadde76ff9273d0e8851dec02d1.tar.gz cgitize-b33664f5225e6fadde76ff9273d0e8851dec02d1.zip |
initial commit
Diffstat (limited to 'pull.sh')
-rwxr-xr-x | pull.sh | 38 |
1 files changed, 38 insertions, 0 deletions
@@ -0,0 +1,38 @@ +#!/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 + +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 +} + +if [ -z "${SSH_AUTH_SOCK+x}" ]; then + echo "SSH_AUTH_SOCK isn't defined (ssh-agent not running?)" >&2 + exit 1 +fi +add_ssh_key +"$script_dir/pull.py" |