-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkeybase-client
executable file
·45 lines (39 loc) · 1009 Bytes
/
keybase-client
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
#!/bin/bash
set -euo pipefail
KEYBASE_PATH="/team/lghs.infra/passwords/ansible-vaults"
function get() {
keybase fs read "keybase://$KEYBASE_PATH/$1"
}
function set() {
if tty --quiet; then
if keybase fs stat "keybase://$KEYBASE_PATH/$1" &> /dev/null; then
read -p 'You are overwriting an existing password, continue? (Y/n) ' confirm
if [[ "$confirm" != "" && "$confirm" != "y" ]]; then
exit 2
fi
fi
read -rsp "Write your password: " password
echo "$password" | keybase fs write "keybase://$KEYBASE_PATH/$1"
else
keybase fs write "keybase://$KEYBASE_PATH/$1"
fi
}
function remove() {
keybase fs rm "keybase://$KEYBASE_PATH/$1"
}
command="$1"
shift
case "$command" in
"--vault-id" | "get")
get "$@"
;;
"set")
set "$@"
;;
"remove")
remove "$@"
;;
*)
echo "unknown command, I only know 'get' and 'set'" >&2
;;
esac