Skip to content

Commit f981c78

Browse files
authored
Merge pull request acmesh-official#6160 from acmesh-official/dev
sync
2 parents 5d6f1bd + 3fbdb7a commit f981c78

File tree

6 files changed

+378
-3
lines changed

6 files changed

+378
-3
lines changed

.github/workflows/pr_dns.yml

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
First thing: don't send PR to the master branch, please send to the dev branch instead.
2424
Please make sure you've read our [DNS API Dev Guide](../wiki/DNS-API-Dev-Guide) and [DNS-API-Test](../wiki/DNS-API-Test).
2525
Then reply on this message, otherwise, your code will not be reviewed or merged.
26+
Please also make sure to add/update the usage here: https://github.com/acmesh-official/acme.sh/wiki/dnsapi2
2627
We look forward to reviewing your Pull request shortly ✨
2728
注意: 必须通过了 [DNS-API-Test](../wiki/DNS-API-Test) 才会被 review. 无论是修改, 还是新加的 dns api, 都必须确保通过这个测试.
2829
`

deploy/ruckus.sh

+172
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
#!/usr/bin/env sh
2+
3+
# Here is a script to deploy cert to Ruckus ZoneDirector / Unleashed.
4+
#
5+
# Public domain, 2024, Tony Rielly <https://github.com/ms264556>
6+
#
7+
# ```sh
8+
# acme.sh --deploy -d ruckus.example.com --deploy-hook ruckus
9+
# ```
10+
#
11+
# Then you need to set the environment variables for the
12+
# deploy script to work.
13+
#
14+
# ```sh
15+
# export RUCKUS_HOST=myruckus.example.com
16+
# export RUCKUS_USER=myruckususername
17+
# export RUCKUS_PASS=myruckuspassword
18+
#
19+
# acme.sh --deploy -d myruckus.example.com --deploy-hook ruckus
20+
# ```
21+
#
22+
# returns 0 means success, otherwise error.
23+
24+
######## Public functions #####################
25+
26+
#domain keyfile certfile cafile fullchain
27+
ruckus_deploy() {
28+
_cdomain="$1"
29+
_ckey="$2"
30+
_ccert="$3"
31+
_cca="$4"
32+
_cfullchain="$5"
33+
_err_code=0
34+
35+
_debug _cdomain "$_cdomain"
36+
_debug _ckey "$_ckey"
37+
_debug _ccert "$_ccert"
38+
_debug _cca "$_cca"
39+
_debug _cfullchain "$_cfullchain"
40+
41+
_getdeployconf RUCKUS_HOST
42+
_getdeployconf RUCKUS_USER
43+
_getdeployconf RUCKUS_PASS
44+
45+
if [ -z "$RUCKUS_HOST" ]; then
46+
_debug "Using _cdomain as RUCKUS_HOST, please set if not correct."
47+
RUCKUS_HOST="$_cdomain"
48+
fi
49+
50+
if [ -z "$RUCKUS_USER" ]; then
51+
_err "Need to set the env variable RUCKUS_USER"
52+
return 1
53+
fi
54+
55+
if [ -z "$RUCKUS_PASS" ]; then
56+
_err "Need to set the env variable RUCKUS_PASS"
57+
return 1
58+
fi
59+
60+
_savedeployconf RUCKUS_HOST "$RUCKUS_HOST"
61+
_savedeployconf RUCKUS_USER "$RUCKUS_USER"
62+
_savedeployconf RUCKUS_PASS "$RUCKUS_PASS"
63+
64+
_debug RUCKUS_HOST "$RUCKUS_HOST"
65+
_debug RUCKUS_USER "$RUCKUS_USER"
66+
_secure_debug RUCKUS_PASS "$RUCKUS_PASS"
67+
68+
export ACME_HTTP_NO_REDIRECTS=1
69+
70+
_info "Discovering the login URL"
71+
_get "https://$RUCKUS_HOST" >/dev/null
72+
_login_url="$(_response_header 'Location')"
73+
if [ -n "$_login_url" ]; then
74+
_login_path=$(echo "$_login_url" | sed 's|https\?://[^/]\+||')
75+
if [ -z "$_login_path" ]; then
76+
# redirect was to a different host
77+
_err "Connection failed: redirected to a different host. Configure Unleashed with a Preferred Master or Management Interface."
78+
return 1
79+
fi
80+
fi
81+
82+
if [ -z "${_login_url}" ]; then
83+
_err "Connection failed: couldn't find login page."
84+
return 1
85+
fi
86+
87+
_base_url=$(dirname "$_login_url")
88+
_login_page=$(basename "$_login_url")
89+
90+
if [ "$_login_page" = "index.html" ]; then
91+
_err "Connection temporarily unavailable: Unleashed Rebuilding."
92+
return 1
93+
fi
94+
95+
if [ "$_login_page" = "wizard.jsp" ]; then
96+
_err "Connection failed: Setup Wizard not complete."
97+
return 1
98+
fi
99+
100+
_info "Login"
101+
_username_encoded="$(printf "%s" "$RUCKUS_USER" | _url_encode)"
102+
_password_encoded="$(printf "%s" "$RUCKUS_PASS" | _url_encode)"
103+
_login_query="$(printf "%s" "username=${_username_encoded}&password=${_password_encoded}&ok=Log+In")"
104+
_post "$_login_query" "$_login_url" >/dev/null
105+
106+
_login_code="$(_response_code)"
107+
if [ "$_login_code" = "200" ]; then
108+
_err "Login failed: incorrect credentials."
109+
return 1
110+
fi
111+
112+
_info "Collect Session Cookie"
113+
_H1="Cookie: $(_response_cookie)"
114+
export _H1
115+
_info "Collect CSRF Token"
116+
_H2="X-CSRF-Token: $(_response_header 'HTTP_X_CSRF_TOKEN')"
117+
export _H2
118+
119+
_info "Uploading certificate"
120+
_post_upload "uploadcert" "$_cfullchain"
121+
122+
_info "Uploading private key"
123+
_post_upload "uploadprivatekey" "$_ckey"
124+
125+
_info "Replacing certificate"
126+
_replace_cert_ajax='<ajax-request action="docmd" comp="system" updater="rid.0.5" xcmd="replace-cert" checkAbility="6" timeout="-1"><xcmd cmd="replace-cert" cn="'$RUCKUS_HOST'"/></ajax-request>'
127+
_post "$_replace_cert_ajax" "$_base_url/_cmdstat.jsp" >/dev/null
128+
129+
_info "Rebooting"
130+
_cert_reboot_ajax='<ajax-request action="docmd" comp="worker" updater="rid.0.5" xcmd="cert-reboot" checkAbility="6"><xcmd cmd="cert-reboot" action="undefined"/></ajax-request>'
131+
_post "$_cert_reboot_ajax" "$_base_url/_cmdstat.jsp" >/dev/null
132+
133+
return 0
134+
}
135+
136+
_response_code() {
137+
_egrep_o <"$HTTP_HEADER" "^HTTP[^ ]* .*$" | cut -d " " -f 2-100 | tr -d "\f\n" | _egrep_o "^[0-9]*"
138+
}
139+
140+
_response_header() {
141+
grep <"$HTTP_HEADER" -i "^$1:" | cut -d ':' -f 2- | tr -d "\r\n\t "
142+
}
143+
144+
_response_cookie() {
145+
_response_header 'Set-Cookie' | sed 's/;.*//'
146+
}
147+
148+
_post_upload() {
149+
_post_action="$1"
150+
_post_file="$2"
151+
152+
_post_boundary="----FormBoundary$(date "+%s%N")"
153+
154+
_post_data="$({
155+
printf -- "--%s\r\n" "$_post_boundary"
156+
printf -- "Content-Disposition: form-data; name=\"u\"; filename=\"%s\"\r\n" "$_post_action"
157+
printf -- "Content-Type: application/octet-stream\r\n\r\n"
158+
printf -- "%s\r\n" "$(cat "$_post_file")"
159+
160+
printf -- "--%s\r\n" "$_post_boundary"
161+
printf -- "Content-Disposition: form-data; name=\"action\"\r\n\r\n"
162+
printf -- "%s\r\n" "$_post_action"
163+
164+
printf -- "--%s\r\n" "$_post_boundary"
165+
printf -- "Content-Disposition: form-data; name=\"callback\"\r\n\r\n"
166+
printf -- "%s\r\n" "uploader_$_post_action"
167+
168+
printf -- "--%s--\r\n\r\n" "$_post_boundary"
169+
})"
170+
171+
_post "$_post_data" "$_base_url/_upload.jsp?request_type=xhr" "" "" "multipart/form-data; boundary=$_post_boundary" >/dev/null
172+
}

dnsapi/dns_fornex.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ _get_root() {
8888

8989
i=1
9090
while true; do
91-
h=$(printf "%s" "$domain" | cut -d . -f $i-100)
91+
h=$(printf "%s" "$domain" | cut -d . -f "$i"-100)
9292
_debug h "$h"
9393
if [ -z "$h" ]; then
9494
#not valid

dnsapi/dns_technitium.sh

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env sh
2+
# shellcheck disable=SC2034
3+
dns_Technitium_info='Technitium DNS Server
4+
5+
Site: https://technitium.com/dns/
6+
Docs: github.com/acmesh-official/acme.sh/wiki/dnsapi2#dns_technitium
7+
Options:
8+
Technitium_Server Server Address
9+
Technitium_Token API Token
10+
Issues:https://github.com/acmesh-official/acme.sh/issues/6116
11+
Author: Henning Reich <acmesh@qupfer.de>
12+
'
13+
14+
dns_technitium_add() {
15+
_info "add txt Record using Technitium"
16+
_Technitium_account
17+
fulldomain=$1
18+
txtvalue=$2
19+
response="$(_get "$Technitium_Server/api/zones/records/add?token=$Technitium_Token&domain=$fulldomain&type=TXT&text=${txtvalue}")"
20+
if _contains "$response" '"status":"ok"'; then
21+
return 0
22+
fi
23+
_err "Could not add txt record."
24+
return 1
25+
}
26+
27+
dns_technitium_rm() {
28+
_info "remove txt record using Technitium"
29+
_Technitium_account
30+
fulldomain=$1
31+
txtvalue=$2
32+
response="$(_get "$Technitium_Server/api/zones/records/delete?token=$Technitium_Token&domain=$fulldomain&type=TXT&text=${txtvalue}")"
33+
if _contains "$response" '"status":"ok"'; then
34+
return 0
35+
fi
36+
_err "Could not remove txt record"
37+
return 1
38+
}
39+
40+
#################### Private functions below ##################################
41+
42+
_Technitium_account() {
43+
Technitium_Server="${Technitium_Server:-$(_readaccountconf_mutable Technitium_Server)}"
44+
Technitium_Token="${Technitium_Token:-$(_readaccountconf_mutable Technitium_Token)}"
45+
if [ -z "$Technitium_Server" ] || [ -z "$Technitium_Token" ]; then
46+
Technitium_Server=""
47+
Technitium_Token=""
48+
_err "You don't specify Technitium Server and Token yet."
49+
_err "Please create your Token and add server address and try again."
50+
return 1
51+
fi
52+
53+
#save the credentials to the account conf file.
54+
_saveaccountconf_mutable Technitium_Server "$Technitium_Server"
55+
_saveaccountconf_mutable Technitium_Token "$Technitium_Token"
56+
}

dnsapi/dns_world4you.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ dns_world4you_rm() {
115115

116116
_resethttp
117117
export ACME_HTTP_NO_REDIRECTS=1
118-
body="DeleteDnsRecordForm[recordId]=$recordid&DeleteDnsRecordForm[uniqueFormIdDP]=$formiddp&DeleteDnsRecordForm[_token]=$form_token"
118+
body="DeleteDnsRecordForm[id]=$recordid&DeleteDnsRecordForm[uniqueFormIdDP]=$formiddp&DeleteDnsRecordForm[_token]=$form_token"
119119
_info "Removing record..."
120120
ret=$(_post "$body" "$WORLD4YOU_API/$paketnr/dns/record/delete" '' POST 'application/x-www-form-urlencoded')
121121
_resethttp
@@ -203,6 +203,7 @@ _get_paketnr() {
203203
form="$2"
204204

205205
domains=$(echo "$form" | grep '<ul class="nav header-paket-list">' | sed 's/<li/\n<li/g' | sed 's/<[^>]*>/ /g' | sed 's/^.*>\([^>]*\)$/\1/')
206+
_debug domains "$domains"
206207
domain=''
207208
for domain in $domains; do
208209
if _contains "$fqdn" "$domain\$"; then
@@ -217,7 +218,7 @@ _get_paketnr() {
217218
TLD="$domain"
218219
_debug domain "$domain"
219220
RECORD=$(echo "$fqdn" | cut -c"1-$((${#fqdn} - ${#TLD} - 1))")
220-
PAKETNR=$(echo "$domains" | grep "$domain" | sed 's/^[^,]*, *\([0-9]*\).*$/\1/')
221+
PAKETNR=$(echo "$domains" | grep -o " $domain.*" | sed 's/^[^,]*, *\([0-9]*\).*$/\1/')
221222
return 0
222223
}
223224

0 commit comments

Comments
 (0)