mirror of
https://github.com/acmesh-official/acme.sh.git
synced 2025-05-09 04:52:43 +00:00
Fixed bugs
Fixed the ShellCheck issues and a few bugs. Condition if script is run by root was not tested.
This commit is contained in:
parent
bb4d378733
commit
a8f1d0dd48
@ -1,15 +1,17 @@
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
# Here is the script to deploy the cert to your cpanel using the cpanel API.
|
||||||
#Here is the script to deploy the cert to your cpanel account by the cpanel APIs.
|
# Uses command line uapi.
|
||||||
|
# Cpanel username is needed only when run as root (I did not test this).
|
||||||
#returns 0 means success, otherwise error.
|
# Returns 0 when success.
|
||||||
|
# Written by Santeri Kannisto <santeri.kannisto@2globalnomads.info>
|
||||||
|
# Public domain, 2017
|
||||||
|
|
||||||
#export DEPLOY_CPANEL_USER=myusername
|
#export DEPLOY_CPANEL_USER=myusername
|
||||||
#export DEPLOY_CPANEL_PASSWORD=PASSWORD
|
|
||||||
|
|
||||||
######## Public functions #####################
|
######## Public functions #####################
|
||||||
|
|
||||||
#domain keyfile certfile cafile fullchain
|
#domain keyfile certfile cafile fullchain
|
||||||
|
|
||||||
cpanel_deploy() {
|
cpanel_deploy() {
|
||||||
_cdomain="$1"
|
_cdomain="$1"
|
||||||
_ckey="$2"
|
_ckey="$2"
|
||||||
@ -23,7 +25,29 @@ cpanel_deploy() {
|
|||||||
_debug _cca "$_cca"
|
_debug _cca "$_cca"
|
||||||
_debug _cfullchain "$_cfullchain"
|
_debug _cfullchain "$_cfullchain"
|
||||||
|
|
||||||
_err "Not implemented yet"
|
# read cert and key files and urlencode both
|
||||||
return 1
|
_certstr=$(cat "$_ccert")
|
||||||
|
_keystr=$(cat "$_ckey")
|
||||||
|
_cert=$(php -r "echo urlencode(\"$_certstr\");")
|
||||||
|
_key=$(php -r "echo urlencode(\"$_keystr\");")
|
||||||
|
|
||||||
|
_debug _cert "$_cert"
|
||||||
|
_debug _key "$_key"
|
||||||
|
|
||||||
|
if [ "$(id -u)" = 0 ]; then
|
||||||
|
_opt="--user=$DEPLOY_CPANEL_USER"
|
||||||
|
_debug _opt "$_opt"
|
||||||
|
fi
|
||||||
|
|
||||||
|
_response=$(uapi "$_opt" SSL install_ssl domain="$_cdomain" cert="$_cert" key="$_key")
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
_err "Error in deploying certificate:"
|
||||||
|
_err "$_response"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
_debug response "$_response"
|
||||||
|
_info "Certificate successfully deployed"
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user