-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathshell
executable file
·88 lines (79 loc) · 1.96 KB
/
shell
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
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash
set -e
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$DIR/config.sh"
function print_hello {
echo "=================================================="
echo " $SERVER_HELLO_MESSAGE"
echo "=================================================="
echo ""
}
function print_usage {
echo "Avialable commands:"
echo -e "\tgencrl\t -- generate new CRL"
echo -e "\tnew <username> <email>\t -- create new user key."
echo -e "\tnotify <username>\t -- send email with key to user"
echo -e "\temail <username>\t -- get stored email for user"
echo -e "\tscp -f <username>.zip\t -- zip and download key"
echo -e "\trevoke <username>\t -- revoke user key"
echo -e "\trenew <username>\t -- renew user key."
echo ""
}
if [ "$#" == "0" ]; then
print_hello
print_usage
exit 0
fi
source "$DIR/utils/error.sh"
source "$DIR/utils/user.sh"
source "$DIR/utils/email.sh"
PARAMS=($2)
case "${PARAMS[0]}" in
scp)
if [ "${PARAMS[1]}" == "-t" ] ; then
print_error "Upload via scp is disabled"
exit 1
fi
filename=$(cleanup_username "${PARAMS[2]}")
"${DIR}/commands/download" "${filename%.zip}"
;;
new)
print_hello
user=$(cleanup_username "${PARAMS[1]}")
if [ -z "${user}" ] || [ -z "${PARAMS[2]}" ] || [ "$(check_email ${PARAMS[2]})" == "0" ] ; then
print_error "Bad parameters: \"${PARAMS[1]} ${PARAMS[2]}\""
print_usage
exit 1
fi
"${DIR}/commands/new" "${user}" "${PARAMS[2]}"
;;
notify)
print_hello
user=$(cleanup_username "${PARAMS[1]}")
"${DIR}/commands/notify" "${user}"
;;
revoke)
print_hello
user=$(cleanup_username "${PARAMS[1]}")
"${DIR}/commands/revoke" "${user}"
;;
renew)
print_hello
user=$(cleanup_username "${PARAMS[1]}")
"${DIR}/commands/renew" "${user}"
;;
email)
print_hello
user=$(cleanup_username "${PARAMS[1]}")
echo "Stored email for user $user is: $(user_email $user)"
;;
gencrl)
print_hello
"${DIR}/commands/gencrl"
;;
*)
print_hello
print_usage
exit 0
esac
exit 0