mirror of
https://github.com/acmesh-official/acme.sh.git
synced 2025-06-15 18:42:44 +00:00
Merge pull request #1 from invario/localcopy-shellchecked-shfmted
Update localcopy.sh, shellcheck'ed and shfmt'ed
This commit is contained in:
commit
ab3cb35ab5
@ -1,10 +1,10 @@
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
# Deploy-hook to very simply copy files to set directories and then
|
# Deploy-hook to very simply copy files to set directories and then
|
||||||
# execute whatever reloadcmd the admin needs afterwards. This can be
|
# execute whatever reloadcmd the admin needs afterwards. This can be
|
||||||
# useful for configurations where the "multideploy" hook (in development)
|
# useful for configurations where the "multideploy" hook (in development)
|
||||||
# is used or when an admin wants ACME.SH to renew certs but needs to
|
# is used or when an admin wants ACME.SH to renew certs but needs to
|
||||||
# manually configure deployment via an external script
|
# manually configure deployment via an external script
|
||||||
# (e.g. The deploy-freenas script for TrueNAS Core/Scale
|
# (e.g. The deploy-freenas script for TrueNAS Core/Scale
|
||||||
# https://github.com/danb35/deploy-freenas/ )
|
# https://github.com/danb35/deploy-freenas/ )
|
||||||
#
|
#
|
||||||
@ -26,80 +26,75 @@ localcopy_deploy() {
|
|||||||
_ccert="$3"
|
_ccert="$3"
|
||||||
_cca="$4"
|
_cca="$4"
|
||||||
_cfullchain="$5"
|
_cfullchain="$5"
|
||||||
|
|
||||||
_debug _cdomain "$_cdomain"
|
_debug _cdomain "$_cdomain"
|
||||||
_debug _ckey "$_ckey"
|
_debug _ckey "$_ckey"
|
||||||
_debug _ccert "$_ccert"
|
_debug _ccert "$_ccert"
|
||||||
_debug _cca "$_cca"
|
_debug _cca "$_cca"
|
||||||
_debug _cfullchain "$_cfullchain"
|
_debug _cfullchain "$_cfullchain"
|
||||||
|
|
||||||
_getdeployconf DEPLOY_LOCALCOPY_CERTIFICATE
|
_getdeployconf DEPLOY_LOCALCOPY_CERTIFICATE
|
||||||
_getdeployconf DEPLOY_LOCALCOPY_CERTKEY
|
_getdeployconf DEPLOY_LOCALCOPY_CERTKEY
|
||||||
_getdeployconf DEPLOY_LOCALCOPY_FULLCHAIN
|
_getdeployconf DEPLOY_LOCALCOPY_FULLCHAIN
|
||||||
_getdeployconf DEPLOY_LOCALCOPY_CA
|
_getdeployconf DEPLOY_LOCALCOPY_CA
|
||||||
_getdeployconf DEPLOY_LOCALCOPY_RELOADCMD
|
_getdeployconf DEPLOY_LOCALCOPY_RELOADCMD
|
||||||
|
|
||||||
if [ "$DEPLOY_LOCALCOPY_CERTIFICATE" ]; then
|
if [ "$DEPLOY_LOCALCOPY_CERTIFICATE" ]; then
|
||||||
_info "Copying certificate"
|
_info "Copying certificate"
|
||||||
_debug "Copying $_ccert to $DEPLOY_LOCALCOPY_CERTIFICATE"
|
_debug "Copying $_ccert to $DEPLOY_LOCALCOPY_CERTIFICATE"
|
||||||
eval "cp $_ccert $DEPLOY_LOCALCOPY_CERTIFICATE"
|
if ! eval "cp $_ccert $DEPLOY_LOCALCOPY_CERTIFICATE"; then
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
_err "Failed to copy certificate, aborting."
|
_err "Failed to copy certificate, aborting."
|
||||||
return 1;
|
return 1
|
||||||
fi;
|
fi
|
||||||
_savedeployconf DEPLOY_LOCALCOPY_CERTIFICATE "$DEPLOY_LOCALCOPY_CERTIFICATE"
|
_savedeployconf DEPLOY_LOCALCOPY_CERTIFICATE "$DEPLOY_LOCALCOPY_CERTIFICATE"
|
||||||
fi;
|
fi
|
||||||
|
|
||||||
if [ "$DEPLOY_LOCALCOPY_CERTKEY" ]; then
|
if [ "$DEPLOY_LOCALCOPY_CERTKEY" ]; then
|
||||||
_info "Copying certificate key"
|
_info "Copying certificate key"
|
||||||
_debug "Copying $_ckey to $DEPLOY_LOCALCOPY_CERTKEY"
|
_debug "Copying $_ckey to $DEPLOY_LOCALCOPY_CERTKEY"
|
||||||
eval "cp $_ckey $DEPLOY_LOCALCOPY_CERTKEY"
|
if ! eval "cp $_ckey $DEPLOY_LOCALCOPY_CERTKEY"; then
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
_err "Failed to copy certificate key, aborting."
|
_err "Failed to copy certificate key, aborting."
|
||||||
return 1;
|
return 1
|
||||||
fi;
|
fi
|
||||||
_savedeployconf DEPLOY_LOCALCOPY_CERTKEY "$DEPLOY_LOCALCOPY_CERTKEY"
|
_savedeployconf DEPLOY_LOCALCOPY_CERTKEY "$DEPLOY_LOCALCOPY_CERTKEY"
|
||||||
fi;
|
fi
|
||||||
|
|
||||||
if [ "$DEPLOY_LOCALCOPY_FULLCHAIN" ]; then
|
if [ "$DEPLOY_LOCALCOPY_FULLCHAIN" ]; then
|
||||||
_info "Copying fullchain"
|
_info "Copying fullchain"
|
||||||
_debug "Copying $_cfullchain to $DEPLOY_LOCALCOPY_FULLCHAIN"
|
_debug "Copying $_cfullchain to $DEPLOY_LOCALCOPY_FULLCHAIN"
|
||||||
eval "cp $_cfullchain $DEPLOY_LOCALCOPY_FULLCHAIN"
|
if ! eval "cp $_cfullchain $DEPLOY_LOCALCOPY_FULLCHAIN"; then
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
_err "Failed to copy fullchain, aborting."
|
_err "Failed to copy fullchain, aborting."
|
||||||
return 1;
|
return 1
|
||||||
fi;
|
fi
|
||||||
_savedeployconf DEPLOY_LOCALCOPY_FULLCHAIN "$DEPLOY_LOCALCOPY_FULLCHAIN"
|
_savedeployconf DEPLOY_LOCALCOPY_FULLCHAIN "$DEPLOY_LOCALCOPY_FULLCHAIN"
|
||||||
fi;
|
fi
|
||||||
|
|
||||||
if [ "$DEPLOY_LOCALCOPY_CA" ]; then
|
if [ "$DEPLOY_LOCALCOPY_CA" ]; then
|
||||||
_info "Copying CA"
|
_info "Copying CA"
|
||||||
_debug "Copying $_cca to $DEPLOY_LOCALCOPY_CA"
|
_debug "Copying $_cca to $DEPLOY_LOCALCOPY_CA"
|
||||||
eval "cp $_cca $DEPLOY_LOCALCOPY_CA"
|
if ! eval "cp $_cca $DEPLOY_LOCALCOPY_CA"; then
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
_err "Failed to copy CA, aborting."
|
_err "Failed to copy CA, aborting."
|
||||||
return 1;
|
return 1
|
||||||
fi;
|
fi
|
||||||
_savedeployconf DEPLOY_LOCALCOPY_CA "$DEPLOY_LOCALCOPY_CA"
|
_savedeployconf DEPLOY_LOCALCOPY_CA "$DEPLOY_LOCALCOPY_CA"
|
||||||
fi;
|
fi
|
||||||
|
|
||||||
_reload=$DEPLOY_LOCALCOPY_RELOADCMD
|
_reload=$DEPLOY_LOCALCOPY_RELOADCMD
|
||||||
_debug "Running reloadcmd $_reload"
|
_debug "Running reloadcmd $_reload"
|
||||||
|
|
||||||
if [ -z "$_reload" ]; then
|
if [ -z "$_reload" ]; then
|
||||||
_info "Reloadcmd not provided, skipping."
|
_info "Reloadcmd not provided, skipping."
|
||||||
else
|
else
|
||||||
_info "Reloading"
|
_info "Reloading"
|
||||||
if eval $_reload; then
|
if eval "$_reload"; then
|
||||||
_info "Reload successful."
|
_info "Reload successful."
|
||||||
_savedeployconf DEPLOY_LOCALCOPY_RELOADCMD "$DEPLOY_LOCALCOPY_RELOADCMD" "base64"
|
_savedeployconf DEPLOY_LOCALCOPY_RELOADCMD "$DEPLOY_LOCALCOPY_RELOADCMD" "base64"
|
||||||
else
|
else
|
||||||
_err "Reload failed."
|
_err "Reload failed."
|
||||||
return 1;
|
return 1
|
||||||
fi;
|
fi
|
||||||
fi;
|
fi
|
||||||
|
|
||||||
_info "$(__green "'localcopy' deploy success")"
|
_info "$(__green "'localcopy' deploy success")"
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user