|
5 | 5 | # export DEPLOY_KEYHELP_BASEURL="https://keyhelp.example.com" |
6 | 6 | # export DEPLOY_KEYHELP_USERNAME="Your KeyHelp Username" |
7 | 7 | # 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. |
9 | 8 | # export DEPLOY_KEYHELP_DOMAIN_ID="Depoly certificate to this Domain ID" |
10 | 9 |
|
11 | 10 | # 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() { |
96 | 95 | _response=$(_get "$DEPLOY_KEYHELP_BASEURL/index.php?page=domains&action=edit&id=$DOMAIN_ID") |
97 | 96 | cert_value=$(echo "$_response" | grep "$certificate_name" | sed -n 's/.*value="\([^"]*\).*/\1/p') |
98 | 97 | 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 |
99 | 113 | _debug "cert_value" "$cert_value" |
100 | 114 | if [ -z "$cert_value" ]; then |
101 | 115 | _err "Fail to get certificate id." |
102 | 116 | return 1 |
103 | 117 | fi |
104 | 118 |
|
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" |
106 | 120 | _response=$(_post "$_request_body" "$DEPLOY_KEYHELP_BASEURL/index.php?page=domains&action=edit" "" "POST") |
107 | 121 | _message=$(echo "$_response" | grep -A 2 'message-body' | sed -n '/<div class="message-body ">/,/<\/div>/{//!p;}' | sed 's/<[^>]*>//g' | sed 's/^ *//;s/ *$//') |
108 | 122 | _info "_message" "$_message" |
|
0 commit comments