Better integration with acme.sh utils

This commit is contained in:
Yann Bizeul 2018-08-21 16:18:00 +02:00
parent e5e57e684e
commit c205777542

View File

@ -1,4 +1,4 @@
#!/usr/bin/env sh #!/usr/bin/env sh -x
# Script to deploy certificate to a Gitlab hosted page # Script to deploy certificate to a Gitlab hosted page
@ -54,8 +54,29 @@ gitlab_deploy() {
_savedomainconf Le_Deploy_gitlab_domain "$Le_Deploy_gitlab_domain" _savedomainconf Le_Deploy_gitlab_domain "$Le_Deploy_gitlab_domain"
fi fi
curl -s --fail --request PUT --header "PRIVATE-TOKEN: $Le_Deploy_gitlab_token" --form "certificate=@$_cfullchain" --form "key=@$_ckey" "https://gitlab.com/api/v4/projects/$Le_Deploy_gitlab_project_id/pages/domains/$Le_Deploy_gitlab_domain" >/dev/null && exit 0 #curl -s --fail --request PUT --header "PRIVATE-TOKEN: $Le_Deploy_gitlab_token" --form "certificate=@$_cfullchain" --form "key=@$_ckey" "https://gitlab.com/api/v4/projects/$Le_Deploy_gitlab_project_id/pages/domains/$Le_Deploy_gitlab_domain" >/dev/null && exit 0
# Exit curl status code if curl didn't work string_fullchain=$( _url_encode < $_cfullchain )
exit $? string_key=$( _url_encode < $_ckey )
body="certificate=$string_fullchain&key=$string_key"
export _H1="PRIVATE-TOKEN: $Le_Deploy_gitlab_token"
gitlab_url="https://gitlab.com/api/v4/projects/$Le_Deploy_gitlab_project_id/pages/domains/$Le_Deploy_gitlab_domain"
_response=$( _post "$body" "$gitlab_url" 0 PUT | _dbase64 "multiline" )
error_response="error"
if test "${_response#*$error_response}" != "$_response"; then
_err "Error in deploying certificate:"
_err "$_response"
return 1
fi
_debug response "$_response"
_info "Certificate successfully deployed"
return 0
} }