enable mult domains in qiniu deploy hook
This commit is contained in:
parent
902c08e9c9
commit
5b4b236e86
@ -47,7 +47,7 @@ qiniu_deploy() {
|
|||||||
string_key=$(sed 's/$/\\n/' "$_ckey" | tr -d '\n')
|
string_key=$(sed 's/$/\\n/' "$_ckey" | tr -d '\n')
|
||||||
|
|
||||||
sslcert_path="/sslcert"
|
sslcert_path="/sslcert"
|
||||||
sslcerl_body="{\"name\":\"$_cdomain\",\"common_name\":\"$QINIU_CDN_DOMAIN\",\"ca\":\"$string_fullchain\",\"pri\":\"$string_key\"}"
|
sslcerl_body="{\"name\":\"$_cdomain\",\"ca\":\"$string_fullchain\",\"pri\":\"$string_key\"}"
|
||||||
sslcert_access_token="$(_make_access_token "$sslcert_path")"
|
sslcert_access_token="$(_make_access_token "$sslcert_path")"
|
||||||
_debug sslcert_access_token "$sslcert_access_token"
|
_debug sslcert_access_token "$sslcert_access_token"
|
||||||
export _H1="Authorization: QBox $sslcert_access_token"
|
export _H1="Authorization: QBox $sslcert_access_token"
|
||||||
@ -60,14 +60,31 @@ qiniu_deploy() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
_debug sslcert_response "$sslcert_response"
|
_debug sslcert_response "$sslcert_response"
|
||||||
_info "Certificate successfully uploaded, updating domain $_cdomain"
|
_info "Certificate successfully uploaded"
|
||||||
|
|
||||||
## extract certId
|
## extract certId
|
||||||
_certId="$(printf "%s" "$sslcert_response" | _normalizeJson | _egrep_o "certID\": *\"[^\"]*\"" | cut -d : -f 2)"
|
_certId="$(printf "%s" "$sslcert_response" | _normalizeJson | _egrep_o "certID\": *\"[^\"]*\"" | cut -d : -f 2)"
|
||||||
_debug certId "$_certId"
|
_debug certId "$_certId"
|
||||||
|
|
||||||
|
IFS=', ' read -r -a targets <<<"$QINIU_CDN_DOMAIN"
|
||||||
|
for target in ${targets[@]}; do
|
||||||
|
_deploy_domain "$_certId" "$target"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
_make_access_token() {
|
||||||
|
_token="$(printf "%s\n" "$1" | _hmac "sha1" "$(printf "%s" "$QINIU_SK" | _hex_dump | tr -d " ")" | _base64 | tr -- '+/' '-_')"
|
||||||
|
echo "$QINIU_AK:$_token"
|
||||||
|
}
|
||||||
|
|
||||||
|
_deploy_domain() {
|
||||||
|
_certId=$1
|
||||||
|
target_domain=$2
|
||||||
|
|
||||||
|
_info "Updating domain $target_domain"
|
||||||
|
|
||||||
## update domain ssl config
|
## update domain ssl config
|
||||||
update_path="/domain/$QINIU_CDN_DOMAIN/httpsconf"
|
update_path="/domain/$target_domain/httpsconf"
|
||||||
update_body="{\"certid\":$_certId,\"forceHttps\":false}"
|
update_body="{\"certid\":$_certId,\"forceHttps\":false}"
|
||||||
update_access_token="$(_make_access_token "$update_path")"
|
update_access_token="$(_make_access_token "$update_path")"
|
||||||
_debug update_access_token "$update_access_token"
|
_debug update_access_token "$update_access_token"
|
||||||
@ -85,8 +102,3 @@ qiniu_deploy() {
|
|||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
_make_access_token() {
|
|
||||||
_token="$(printf "%s\n" "$1" | _hmac "sha1" "$(printf "%s" "$QINIU_SK" | _hex_dump | tr -d " ")" | _base64 | tr -- '+/' '-_')"
|
|
||||||
echo "$QINIU_AK:$_token"
|
|
||||||
}
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user