-
Notifications
You must be signed in to change notification settings - Fork 314
/
Copy pathau.sh
executable file
·118 lines (98 loc) · 2.61 KB
/
au.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
#!/bin/bash
#[email protected] 欢迎关注我的书《深入浅出HTTPS:从原理到实战》
###### 根据自己的情况修改 Begin ##############
#PHP 命令行路径,如果有需要可以修改
phpcmd="/usr/bin/php"
#Python 命令行路径,如果有需要可以修改
pythoncmd="/usr/bin/python"
#填写阿里云的AccessKey ID及AccessKey Secret
#如何申请见https://help.aliyun.com/knowledge_detail/38738.html
ALY_KEY=""
ALY_TOKEN=""
#填写腾讯云的SecretId及SecretKey
#如何申请见https://console.cloud.tencent.com/cam/capi
TXY_KEY=""
TXY_TOKEN=""
#填写华为云的 Access Key Id 及 Secret Access Key
#如何申请见https://support.huaweicloud.com/devg-apisign/api-sign-provide.html
HWY_KEY=""
HWY_TOKEN=""
#GoDaddy的SecretId及SecretKey
#如何申请见https://developer.godaddy.com/getstarted
GODADDY_KEY=""
GODADDY_TOKEN=""
################ END ##############
PATH=$(cd `dirname $0`; pwd)
# 命令行参数
# 第一个参数:使用什么语言环境
# 第二个参数:使用那个 DNS 的 API
# 第三个参数:add or clean
plang=$1 #python or php
pdns=$2 #aly, txy, hwy, godaddy
paction=$3 #add or clean
#内部变量
cmd=""
key=""
token=""
if [[ "$paction" != "clean" ]]; then
paction="add"
fi
case $plang in
"php")
cmd=$phpcmd
if [[ "$pdns" == "aly" ]]; then
dnsapi=$PATH"/php-version/alydns.php"
key=$ALY_KEY
token=$ALY_TOKEN
elif [[ "$pdns" == "txy" ]]; then
dnsapi="$PATH/php-version/txydns.php"
key=$TXY_KEY
token=$TXY_TOKEN
elif [[ "$pdns" == "hwy" ]]; then
# TODO
dnsapi=""
key=$HWY_KEY
token=$HWY_TOKEN
exit
elif [[ "$pdns" == "godaddy" ]] ;then
dnsapi="$PATH/php-version/godaddydns.php"
key=$GODADDY_KEY
token=$GODADDY_TOKEN
else
echo "Not support this dns services"
exit
fi
;;
"python")
cmd=$pythoncmd
if [[ "$pdns" == "aly" ]]; then
dnsapi=$PATH"/python-version/alydns.py"
key=$ALY_KEY
token=$ALY_TOKEN
elif [[ "$pdns" == "txy" ]] ;then
dnsapi=$PATH"/python-version/txydns.py"
key=$TXY_KEY
token=$TXY_TOKEN
elif [[ "$pdns" == "txy" ]]; then
dnsapi=$PATH"/python-version/txydns.py"
key=$TXY_KEY
token=$TXY_TOKEN
elif [[ "$pdns" == "hwy" ]]; then
dnsapi="$PATH/python-version/hwydns.py"
key=$HWY_KEY
token=$HWY_TOKEN
elif [[ "$pdns" == "godaddy" ]] ;then
dnsapi=$PATH"/python-version/godaddydns.py"
key=$GODADDY_KEY
token=$GODADDY_TOKEN
else
echo "Not support this dns services"
exit
fi
;;
esac
$cmd $dnsapi $paction $CERTBOT_DOMAIN "_acme-challenge" $CERTBOT_VALIDATION $key $token >>"/var/log/certd.log"
if [[ "$paction" == "add" ]]; then
# DNS TXT 记录刷新时间
/bin/sleep 20
fi