-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathotp-cli
executable file
·75 lines (67 loc) · 1.34 KB
/
otp-cli
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/sh
APP_HOME="$HOME/otp-cli"
TOKENFILES_DIR="$APP_HOME/tokens"
CONFIG_FILE="$APP_HOME/config"
WAIT_FOR_NEXT=0
PERMISSION_WARN=1
ENCRYPTED=0
[ -z $OS ] && OS=$( uname )
[ -z $CURRENT_DIR ] && [ $OS = "Darwin" ] && CURRENT_DIR=$(dirname `$(command -v realpath || command -v readlink) $0`)
[ -z $CURRENT_DIR ] && CURRENT_DIR=$(dirname `readlink -f $0`)
if [ ! -f "$CONFIG_FILE" ]; then
mkdir -p $APP_HOME
cat $CURRENT_DIR/config-example > $CONFIG_FILE
chmod 700 $CONFIG_FILE
fi
. $CONFIG_FILE
. $CURRENT_DIR/lib/common
CMD=$1
[ $# -gt 0 ] && shift
show_usage()
{
[ -n "$1" ] && echo "ERROR: $1"
echo "Usage: $( basename ${0} ) <command> [-h]"
echo
echo " -h : If after a <command>, the respective help. Otherwise, this help."
echo
echo " Where <command> are:"
echo
echo " help : This help"
echo " add : Add a new token"
echo " clip : Copy OTP to clipboard"
echo " show : Show the current OTP"
echo " list : List available tokens"
echo " lock : Lock an unencrypted token"
echo " unlock : Unlock an encrypted token"
echo " remove : Remove a token"
exit 1
}
case $CMD in
add)
;;
clip)
;;
remove)
;;
show)
;;
lock)
;;
unlock)
;;
list)
;;
help)
show_usage
;;
-h)
show_usage
;;
-help)
show_usage
;;
*)
show_usage "Unknow command $CMD"
;;
esac
. $CURRENT_DIR/lib/$CMD