Skip to content

Commit 2f5ea12

Browse files
committed
deployhook KeyHelp: fix bug
1 parent 3f40380 commit 2f5ea12

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

deploy/keyhelp.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
# export DEPLOY_KEYHELP_BASEURL="https://keyhelp.example.com"
66
# export DEPLOY_KEYHELP_USERNAME="Your KeyHelp Username"
77
# export DEPLOY_KEYHELP_PASSWORD="Your KeyHelp Password"
8-
# export DEPLOY_KEYHELP_ENFORCE_HTTPS="1" # 0 or 1, input 1 to enable Enforce HTTP to HTTPS redirection.
98
# export DEPLOY_KEYHELP_DOMAIN_ID="Depoly certificate to this Domain ID"
109

1110
# Open the 'Edit domain' page, and you will see id=xxx at the end of the URL. This is the Domain ID.
@@ -96,13 +95,28 @@ keyhelp_deploy() {
9695
_response=$(_get "$DEPLOY_KEYHELP_BASEURL/index.php?page=domains&action=edit&id=$DOMAIN_ID")
9796
cert_value=$(echo "$_response" | grep "$certificate_name" | sed -n 's/.*value="\([^"]*\).*/\1/p')
9897
target_type=$(echo "$_response" | grep 'target_type' | grep 'checked' | sed -n 's/.*value="\([^"]*\).*/\1/p')
98+
if [ "$target_type" = "directory" ]; then
99+
path=$(echo "$_response" | awk '/name="path"/{getline; print}' | sed -n 's/.*value="\([^"]*\).*/\1/p')
100+
fi
101+
echo "$_response" | grep "is_prefer_https" | grep "checked" >/dev/null
102+
if [ $? -eq 0 ]; then
103+
is_prefer_https=1
104+
else
105+
is_prefer_https=0
106+
fi
107+
echo "$_response" | grep "hsts_enabled" | grep "checked" >/dev/null
108+
if [ $? -eq 0 ]; then
109+
hsts_enabled=1
110+
else
111+
hsts_enabled=0
112+
fi
99113
_debug "cert_value" "$cert_value"
100114
if [ -z "$cert_value" ]; then
101115
_err "Fail to get certificate id."
102116
return 1
103117
fi
104118

105-
_request_body="submit=1&id=$DOMAIN_ID&target_type=$target_type&certificate_type=custom&certificate_id=$cert_value&enforce_https=$DEPLOY_KEYHELP_ENFORCE_HTTPS"
119+
_request_body="submit=1&id=$DOMAIN_ID&target_type=$target_type&path=$path&is_prefer_https=$is_prefer_https&hsts_enabled=$hsts_enabled&certificate_type=custom&certificate_id=$cert_value&enforce_https=$DEPLOY_KEYHELP_ENFORCE_HTTPS"
106120
_response=$(_post "$_request_body" "$DEPLOY_KEYHELP_BASEURL/index.php?page=domains&action=edit" "" "POST")
107121
_message=$(echo "$_response" | grep -A 2 'message-body' | sed -n '/<div class="message-body ">/,/<\/div>/{//!p;}' | sed 's/<[^>]*>//g' | sed 's/^ *//;s/ *$//')
108122
_info "_message" "$_message"

0 commit comments

Comments
 (0)