forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathv_list_web_domain_ssl
More file actions
executable file
·90 lines (70 loc) · 2.16 KB
/
Copy pathv_list_web_domain_ssl
File metadata and controls
executable file
·90 lines (70 loc) · 2.16 KB
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
89
90
#!/bin/bash
# info: list web domain ssl certificate
# options: user domain [format]
#
# The function of obtaining domain ssl files.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user=$1
domain=$2
format=${3-shell}
# Importing variables
source $VESTA/conf/vars.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
# Json function
json_list_ssl() {
i='1' # iterator
echo '{'
echo -e "\t\"$domain\": {"
echo " \"CRT\": \"$crt\","
echo " \"KEY\": \"$key\","
echo " \"CA\": \"$ca\""
echo -e "\t}\n}"
}
# Shell function
shell_list_ssl() {
if [ ! -z "$crt" ]; then
echo -e "$crt"
fi
if [ ! -z "$key" ]; then
echo -e "\n$key"
fi
if [ ! -z "$ca" ]; then
echo -e "\n$ca"
fi
}
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
# Checking args
check_args '2' "$#" 'user domain [format]'
# Checking user
is_user_valid
# Checking domain exist
is_domain_valid 'web'
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
if [ -e "$V_USERS/$user/ssl/$domain.crt" ]; then
crt=$(cat $V_USERS/$user/ssl/$domain.crt |sed -e ':a;N;$!ba;s/\n/\\n/g' )
fi
if [ -e "$V_USERS/$user/ssl/$domain.key" ]; then
key=$(cat $V_USERS/$user/ssl/$domain.key |sed -e ':a;N;$!ba;s/\n/\\n/g' )
fi
if [ -e "$V_USERS/$user/ssl/$domain.ca" ]; then
ca=$(cat $V_USERS/$user/ssl/$domain.ca |sed -e ':a;N;$!ba;s/\n/\\n/g' )
fi
# Listing domains
case $format in
json) json_list_ssl ;;
plain) nohead=1; shell_list_ssl ;;
shell) shell_list_ssl ;;
*) check_args '1' '0' '[format]'
esac
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
exit