-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcert.sh
171 lines (167 loc) · 3.54 KB
/
cert.sh
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#! /bin/bash
source $(cd $(dirname $0);pwd)/core.sh
source $(cd $(dirname $0);pwd)/cert/acme.sh
show_menu() {
choice=$2
if [[ ! -n $2 ]]; then
echo "> 证书管理"
echo "------------------------"
echo "1. ACME.SH信息"
echo "2. 签发新证书"
echo "3. 查看签发证书"
echo "------------------------"
echo "11. 安装ACME.SH"
echo "12. 卸载ACME.SH"
echo "------------------------"
echo "0. 返回主菜单"
echo "------------------------"
echo
if [[ -n $1 ]]; then
echo -e "${red}$1${plain}"
echo
fi
read -p "请输入选择: " choice
fi
case $choice in
1)
clear
echo "ACME.SH信息"
echo "------------------------"
echo
is_acme_env 0
$KENOTE_ACMECTL --version
echo
$KENOTE_ACMECTL --info
echo
$KENOTE_ACMECTL --list
echo
echo "Crontab"
echo "------------------------"
crontab -l | grep "acme.sh" | grep ""
echo
read -n1 -p "按任意键继续" key
clear
show_menu
;;
2)
clear
echo "签发新证书"
echo "------------------------"
echo -e "${green}1${plain}. 提前将域名解析到本机并可正常访问80端口"
echo -e "${green}2${plain}. 输入 ${yellow}#1${plain} 返回"
echo
is_acme_env 0
if [[ -n $3 ]]; then
echo -e "${red}$3${plain}"
echo
fi
while read -p "请绑定一个域名: " domain
do
goback $domain "clear;show_menu"
if [[ ! -n $domain ]]; then
show_menu "" 2 "请填写域名"
continue
fi
is_param_true "is_domain" "${domain[*]}"
if [[ $? == 1 ]]; then
show_menu "" 2 "绑定域名中存在格式错误"
continue
fi
break
done
echo
issue_cert_nginx "${domain[*]}"
echo
read -n1 -p "按任意键继续" key
clear
show_menu
;;
3)
clear
echo "查看签发证书"
echo "------------------------"
echo
is_acme_env 0
$KENOTE_ACMECTL --list
echo
if [[ -n $3 ]]; then
echo -e "${red}$3${plain}"
echo
fi
while read -p "输入域名: " name
do
goback $name "clear;show_menu" "show_menu \"\" 3"
if [[ ! -n $name ]]; then
show_menu "" 3 "请输入域名"
continue
fi
if [[ ! -n $($KENOTE_ACMECTL --list | grep -E "^$name\s+") ]]; then
show_menu "" 3 "域名证书不存在"
continue
fi
break
done
echo
clear
cert_options $name 3
clear
show_menu
;;
11)
clear
echo "安装ACME.SH"
echo "------------------------"
echo
is_acme_env 1
if [[ -n $3 ]]; then
echo -e "${red}$3${plain}"
echo
fi
while read -p "请设置一个邮箱: " email
do
goback $email "clear;show_menu"
if [[ ! -n $email ]]; then
show_menu "" 11 "请填写邮箱地址"
continue
fi
if [[ ! -n $(is_email "$email") ]]; then
show_menu "" 11 "请填写正确的邮箱地址"
continue
fi
break
done
install_acme "$email"
echo
read -n1 -p "按任意键继续" key
clear
show_menu
;;
12)
clear
echo "卸载ACME.SH"
echo "------------------------"
echo
is_acme_env 0
confirm "确定要执行卸载ACME.SH吗?" "n"
if [[ $? == 1 ]]; then
clear
show_menu
return
fi
remove_acme
echo
read -n1 -p "按任意键继续" key
clear
show_menu
;;
0)
run_script start.sh
;;
*)
clear
show_menu "请输入正确的数字"
;;
esac
}
clear
show_menu