1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- #!/usr/bin/env sh
- cpanel_uapi_deploy() {
- _cdomain="$1"
- _ckey="$2"
- _ccert="$3"
- _cca="$4"
- _cfullchain="$5"
- _debug _cdomain "$_cdomain"
- _debug _ckey "$_ckey"
- _debug _ccert "$_ccert"
- _debug _cca "$_cca"
- _debug _cfullchain "$_cfullchain"
- if ! _exists uapi; then
- _err "The command uapi is not found."
- return 1
- fi
-
- _cert=$(_url_encode <"$_ccert")
- _key=$(_url_encode <"$_ckey")
- _debug _cert "$_cert"
- _debug _key "$_key"
- if [ "$(id -u)" = 0 ]; then
- if [ -z "$DEPLOY_CPANEL_USER" ]; then
- _err "It seems that you are root, please define the target user name: export DEPLOY_CPANEL_USER=username"
- return 1
- fi
- _savedomainconf DEPLOY_CPANEL_USER "$DEPLOY_CPANEL_USER"
- _response=$(uapi --user="$DEPLOY_CPANEL_USER" SSL install_ssl domain="$_cdomain" cert="$_cert" key="$_key")
- else
- _response=$(uapi SSL install_ssl domain="$_cdomain" cert="$_cert" key="$_key")
- fi
- error_response="status: 0"
- 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
- }
|