From a8f9679210c1b8e4cd1e3f54255f7ce2a3098ea1 Mon Sep 17 00:00:00 2001 From: invario <67800603+invario@users.noreply.github.com> Date: Wed, 28 May 2025 10:51:11 -0400 Subject: [PATCH 1/5] Create localcopy deploy-hook Deploy-hook to very simply copy files to set directories and then execute whatever reloadcmd the admin needs afterwards. This can be useful for configurations where the "multideploy" hook (in development) is used or when an admin wants ACME.SH to renew certs but needs to manually configure deployment via an external script (e.g. The deploy-freenas script for TrueNAS Core/Scale https://github.com/danb35/deploy-freenas/ --- deploy/localcopy.sh | 101 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 deploy/localcopy.sh diff --git a/deploy/localcopy.sh b/deploy/localcopy.sh new file mode 100644 index 00000000..a7e9f07d --- /dev/null +++ b/deploy/localcopy.sh @@ -0,0 +1,101 @@ +#!/usr/bin/env sh + +# Deploy-hook to very simply copy files to set directories and then +# execute whatever reloadcmd the admin needs afterwards. This can be +# useful for configurations where the "multideploy" hook (in development) +# is used or when an admin wants ACME.SH to renew certs but needs to +# manually configure deployment via an external script +# (e.g. The deploy-freenas script for TrueNAS Core/Scale +# https://github.com/danb35/deploy-freenas/ ) +# +# +# Environment variables to be utilized are as follows: +# +# DEPLOY_LOCALCOPY_CERTIFICATE - /path/to/target/cert.cer +# DEPLOY_LOCALCOPY_CERTKEY - /path/to/target/cert.key +# DEPLOY_LOCALCOPY_FULLCHAIN - /path/to/target/fullchain.cer +# DEPLOY_LOCALCOPY_CA - /path/to/target/ca.cer +# DEPLOY_LOCALCOPY_RELOADCMD - "echo 'this is my cmd'" + +######## Public functions ##################### + +#domain keyfile certfile cafile fullchain +localcopy_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" + + _getdeployconf DEPLOY_LOCALCOPY_CERTIFICATE + _getdeployconf DEPLOY_LOCALCOPY_CERTKEY + _getdeployconf DEPLOY_LOCALCOPY_FULLCHAIN + _getdeployconf DEPLOY_LOCALCOPY_CA + _getdeployconf DEPLOY_LOCALCOPY_RELOADCMD + + if [ "$DEPLOY_LOCALCOPY_CERTIFICATE" ]; then + _info "Copying certificate" + _debug "Copying $_ccert to $DEPLOY_LOCALCOPY_CERTIFICATE" + eval "cp $_ccert $DEPLOY_LOCALCOPY_CERTIFICATE" + if [ $? -ne 0 ]; then + _err "Failed to copy certificate, aborting." + return 1; + fi; + fi; + + if [ "$DEPLOY_LOCALCOPY_CERTKEY" ]; then + _info "Copying certificate key" + _debug "Copying $_ckey to $DEPLOY_LOCALCOPY_CERTKEY" + eval "cp $_ckey $DEPLOY_LOCALCOPY_CERTKEY" + if [ $? -ne 0 ]; then + _err "Failed to copy certificate key, aborting." + return 1; + fi; + + fi; + + if [ "$DEPLOY_LOCALCOPY_FULLCHAIN" ]; then + _info "Copying fullchain" + _debug "Copying $_cfullchain to $DEPLOY_LOCALCOPY_FULLCHAIN" + eval "cp $_cfullchain $DEPLOY_LOCALCOPY_FULLCHAIN" + if [ $? -ne 0 ]; then + _err "Failed to copy fullchain, aborting." + return 1; + fi; + + fi; + + if [ "$DEPLOY_LOCALCOPY_CA" ]; then + _info "Copying CA" + _debug "Copying $_cca to $DEPLOY_LOCALCOPY_CA" + eval "cp $_cca $DEPLOY_LOCALCOPY_CA" + if [ $? -ne 0 ]; then + _err "Failed to copy CA, aborting." + return 1; + fi; + fi; + + _reload=$DEPLOY_LOCALCOPY_RELOADCMD + if eval $_reload; then + _info "Reload successful." + else + _err "Reload failed." + fi; + +# Save configuration + _savedeployconf DEPLOY_LOCALCOPY_CERTIFICATE "$DEPLOY_LOCALCOPY_CERTIFICATE" + _savedeployconf DEPLOY_LOCALCOPY_CERTKEY "$DEPLOY_LOCALCOPY_CERTKEY" + _savedeployconf DEPLOY_LOCALCOPY_FULLCHAIN "$DEPLOY_LOCALCOPY_FULLCHAIN" + _savedeployconf DEPLOY_LOCALCOPY_CA "$DEPLOY_LOCALCOPY_CA" + + _info "$(__green ""localcopy" deploy success")" + return 0 + +} + From 16137b6ebffbf8b9aa0163e3aca780b7e64bc0c4 Mon Sep 17 00:00:00 2001 From: invario <67800603+invario@users.noreply.github.com> Date: Wed, 28 May 2025 11:36:37 -0400 Subject: [PATCH 2/5] Fix: save reloadcmd also and base64 encode --- deploy/localcopy.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/deploy/localcopy.sh b/deploy/localcopy.sh index a7e9f07d..3fbe37b0 100644 --- a/deploy/localcopy.sh +++ b/deploy/localcopy.sh @@ -93,6 +93,7 @@ localcopy_deploy() { _savedeployconf DEPLOY_LOCALCOPY_CERTKEY "$DEPLOY_LOCALCOPY_CERTKEY" _savedeployconf DEPLOY_LOCALCOPY_FULLCHAIN "$DEPLOY_LOCALCOPY_FULLCHAIN" _savedeployconf DEPLOY_LOCALCOPY_CA "$DEPLOY_LOCALCOPY_CA" + _savedeployconf DEPLOY_LOCALCOPY_RELOADCMD "$DEPLOY_LOCALCOPY_RELOADCMD" "base64" _info "$(__green ""localcopy" deploy success")" return 0 From 06b9db9077cefae92ae3ad463c4df45740c7da05 Mon Sep 17 00:00:00 2001 From: invario <67800603+invario@users.noreply.github.com> Date: Wed, 28 May 2025 12:28:09 -0400 Subject: [PATCH 3/5] Update localcopy.sh Fix tabbing Add more debug/info Only save conf values if not blank and if successful --- deploy/localcopy.sh | 143 ++++++++++++++++++++++---------------------- 1 file changed, 73 insertions(+), 70 deletions(-) diff --git a/deploy/localcopy.sh b/deploy/localcopy.sh index 3fbe37b0..fcb1b25a 100644 --- a/deploy/localcopy.sh +++ b/deploy/localcopy.sh @@ -21,82 +21,85 @@ #domain keyfile certfile cafile fullchain localcopy_deploy() { - _cdomain="$1" - _ckey="$2" - _ccert="$3" - _cca="$4" - _cfullchain="$5" +_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" +_debug _cdomain "$_cdomain" +_debug _ckey "$_ckey" +_debug _ccert "$_ccert" +_debug _cca "$_cca" +_debug _cfullchain "$_cfullchain" - _getdeployconf DEPLOY_LOCALCOPY_CERTIFICATE - _getdeployconf DEPLOY_LOCALCOPY_CERTKEY - _getdeployconf DEPLOY_LOCALCOPY_FULLCHAIN - _getdeployconf DEPLOY_LOCALCOPY_CA - _getdeployconf DEPLOY_LOCALCOPY_RELOADCMD +_getdeployconf DEPLOY_LOCALCOPY_CERTIFICATE +_getdeployconf DEPLOY_LOCALCOPY_CERTKEY +_getdeployconf DEPLOY_LOCALCOPY_FULLCHAIN +_getdeployconf DEPLOY_LOCALCOPY_CA +_getdeployconf DEPLOY_LOCALCOPY_RELOADCMD - if [ "$DEPLOY_LOCALCOPY_CERTIFICATE" ]; then - _info "Copying certificate" - _debug "Copying $_ccert to $DEPLOY_LOCALCOPY_CERTIFICATE" - eval "cp $_ccert $DEPLOY_LOCALCOPY_CERTIFICATE" - if [ $? -ne 0 ]; then - _err "Failed to copy certificate, aborting." - return 1; - fi; +if [ "$DEPLOY_LOCALCOPY_CERTIFICATE" ]; then + _info "Copying certificate" + _debug "Copying $_ccert to $DEPLOY_LOCALCOPY_CERTIFICATE" + eval "cp $_ccert $DEPLOY_LOCALCOPY_CERTIFICATE" + if [ $? -ne 0 ]; then + _err "Failed to copy certificate, aborting." + return 1; fi; - - if [ "$DEPLOY_LOCALCOPY_CERTKEY" ]; then - _info "Copying certificate key" - _debug "Copying $_ckey to $DEPLOY_LOCALCOPY_CERTKEY" - eval "cp $_ckey $DEPLOY_LOCALCOPY_CERTKEY" - if [ $? -ne 0 ]; then - _err "Failed to copy certificate key, aborting." - return 1; - fi; - - fi; - - if [ "$DEPLOY_LOCALCOPY_FULLCHAIN" ]; then - _info "Copying fullchain" - _debug "Copying $_cfullchain to $DEPLOY_LOCALCOPY_FULLCHAIN" - eval "cp $_cfullchain $DEPLOY_LOCALCOPY_FULLCHAIN" - if [ $? -ne 0 ]; then - _err "Failed to copy fullchain, aborting." - return 1; - fi; - - fi; - - if [ "$DEPLOY_LOCALCOPY_CA" ]; then - _info "Copying CA" - _debug "Copying $_cca to $DEPLOY_LOCALCOPY_CA" - eval "cp $_cca $DEPLOY_LOCALCOPY_CA" - if [ $? -ne 0 ]; then - _err "Failed to copy CA, aborting." - return 1; - fi; - fi; - - _reload=$DEPLOY_LOCALCOPY_RELOADCMD - if eval $_reload; then - _info "Reload successful." - else - _err "Reload failed." - fi; - -# Save configuration _savedeployconf DEPLOY_LOCALCOPY_CERTIFICATE "$DEPLOY_LOCALCOPY_CERTIFICATE" - _savedeployconf DEPLOY_LOCALCOPY_CERTKEY "$DEPLOY_LOCALCOPY_CERTKEY" - _savedeployconf DEPLOY_LOCALCOPY_FULLCHAIN "$DEPLOY_LOCALCOPY_FULLCHAIN" - _savedeployconf DEPLOY_LOCALCOPY_CA "$DEPLOY_LOCALCOPY_CA" - _savedeployconf DEPLOY_LOCALCOPY_RELOADCMD "$DEPLOY_LOCALCOPY_RELOADCMD" "base64" +fi; - _info "$(__green ""localcopy" deploy success")" - return 0 +if [ "$DEPLOY_LOCALCOPY_CERTKEY" ]; then + _info "Copying certificate key" + _debug "Copying $_ckey to $DEPLOY_LOCALCOPY_CERTKEY" + eval "cp $_ckey $DEPLOY_LOCALCOPY_CERTKEY" + if [ $? -ne 0 ]; then + _err "Failed to copy certificate key, aborting." + return 1; + fi; + _savedeployconf DEPLOY_LOCALCOPY_CERTKEY "$DEPLOY_LOCALCOPY_CERTKEY" +fi; + +if [ "$DEPLOY_LOCALCOPY_FULLCHAIN" ]; then + _info "Copying fullchain" + _debug "Copying $_cfullchain to $DEPLOY_LOCALCOPY_FULLCHAIN" + eval "cp $_cfullchain $DEPLOY_LOCALCOPY_FULLCHAIN" + if [ $? -ne 0 ]; then + _err "Failed to copy fullchain, aborting." + return 1; + fi; + _savedeployconf DEPLOY_LOCALCOPY_FULLCHAIN "$DEPLOY_LOCALCOPY_FULLCHAIN" +fi; + +if [ "$DEPLOY_LOCALCOPY_CA" ]; then + _info "Copying CA" + _debug "Copying $_cca to $DEPLOY_LOCALCOPY_CA" + eval "cp $_cca $DEPLOY_LOCALCOPY_CA" + if [ $? -ne 0 ]; then + _err "Failed to copy CA, aborting." + return 1; + fi; + _savedeployconf DEPLOY_LOCALCOPY_CA "$DEPLOY_LOCALCOPY_CA" +fi; + +_reload=$DEPLOY_LOCALCOPY_RELOADCMD +_debug "Running reloadcmd $_reload" + +if [ -z "$_reload" ]; then + _info "Reloadcmd not provided, skipping." +else + _info "Reloading" + if eval $_reload; then + _info "Reload successful." + _savedeployconf DEPLOY_LOCALCOPY_RELOADCMD "$DEPLOY_LOCALCOPY_RELOADCMD" "base64" + else + _err "Reload failed." + fi; +fi; + +_info "$(__green "'localcopy' deploy success")" +return 0 } From 9ef3e128c6ec98f668567b51cf886f26abb5a4a2 Mon Sep 17 00:00:00 2001 From: invario <67800603+invario@users.noreply.github.com> Date: Wed, 28 May 2025 17:44:26 -0400 Subject: [PATCH 4/5] Fix indentation and return 1 for failed reload --- deploy/localcopy.sh | 148 ++++++++++++++++++++++---------------------- 1 file changed, 74 insertions(+), 74 deletions(-) diff --git a/deploy/localcopy.sh b/deploy/localcopy.sh index fcb1b25a..e685d3f8 100644 --- a/deploy/localcopy.sh +++ b/deploy/localcopy.sh @@ -21,85 +21,85 @@ #domain keyfile certfile cafile fullchain localcopy_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" - -_getdeployconf DEPLOY_LOCALCOPY_CERTIFICATE -_getdeployconf DEPLOY_LOCALCOPY_CERTKEY -_getdeployconf DEPLOY_LOCALCOPY_FULLCHAIN -_getdeployconf DEPLOY_LOCALCOPY_CA -_getdeployconf DEPLOY_LOCALCOPY_RELOADCMD - -if [ "$DEPLOY_LOCALCOPY_CERTIFICATE" ]; then - _info "Copying certificate" - _debug "Copying $_ccert to $DEPLOY_LOCALCOPY_CERTIFICATE" - eval "cp $_ccert $DEPLOY_LOCALCOPY_CERTIFICATE" - if [ $? -ne 0 ]; then - _err "Failed to copy certificate, aborting." - return 1; + _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" + + _getdeployconf DEPLOY_LOCALCOPY_CERTIFICATE + _getdeployconf DEPLOY_LOCALCOPY_CERTKEY + _getdeployconf DEPLOY_LOCALCOPY_FULLCHAIN + _getdeployconf DEPLOY_LOCALCOPY_CA + _getdeployconf DEPLOY_LOCALCOPY_RELOADCMD + + if [ "$DEPLOY_LOCALCOPY_CERTIFICATE" ]; then + _info "Copying certificate" + _debug "Copying $_ccert to $DEPLOY_LOCALCOPY_CERTIFICATE" + eval "cp $_ccert $DEPLOY_LOCALCOPY_CERTIFICATE" + if [ $? -ne 0 ]; then + _err "Failed to copy certificate, aborting." + return 1; + fi; + _savedeployconf DEPLOY_LOCALCOPY_CERTIFICATE "$DEPLOY_LOCALCOPY_CERTIFICATE" fi; - _savedeployconf DEPLOY_LOCALCOPY_CERTIFICATE "$DEPLOY_LOCALCOPY_CERTIFICATE" -fi; - -if [ "$DEPLOY_LOCALCOPY_CERTKEY" ]; then - _info "Copying certificate key" - _debug "Copying $_ckey to $DEPLOY_LOCALCOPY_CERTKEY" - eval "cp $_ckey $DEPLOY_LOCALCOPY_CERTKEY" - if [ $? -ne 0 ]; then - _err "Failed to copy certificate key, aborting." - return 1; + + if [ "$DEPLOY_LOCALCOPY_CERTKEY" ]; then + _info "Copying certificate key" + _debug "Copying $_ckey to $DEPLOY_LOCALCOPY_CERTKEY" + eval "cp $_ckey $DEPLOY_LOCALCOPY_CERTKEY" + if [ $? -ne 0 ]; then + _err "Failed to copy certificate key, aborting." + return 1; + fi; + _savedeployconf DEPLOY_LOCALCOPY_CERTKEY "$DEPLOY_LOCALCOPY_CERTKEY" fi; - _savedeployconf DEPLOY_LOCALCOPY_CERTKEY "$DEPLOY_LOCALCOPY_CERTKEY" -fi; - -if [ "$DEPLOY_LOCALCOPY_FULLCHAIN" ]; then - _info "Copying fullchain" - _debug "Copying $_cfullchain to $DEPLOY_LOCALCOPY_FULLCHAIN" - eval "cp $_cfullchain $DEPLOY_LOCALCOPY_FULLCHAIN" - if [ $? -ne 0 ]; then - _err "Failed to copy fullchain, aborting." - return 1; + + if [ "$DEPLOY_LOCALCOPY_FULLCHAIN" ]; then + _info "Copying fullchain" + _debug "Copying $_cfullchain to $DEPLOY_LOCALCOPY_FULLCHAIN" + eval "cp $_cfullchain $DEPLOY_LOCALCOPY_FULLCHAIN" + if [ $? -ne 0 ]; then + _err "Failed to copy fullchain, aborting." + return 1; + fi; + _savedeployconf DEPLOY_LOCALCOPY_FULLCHAIN "$DEPLOY_LOCALCOPY_FULLCHAIN" fi; - _savedeployconf DEPLOY_LOCALCOPY_FULLCHAIN "$DEPLOY_LOCALCOPY_FULLCHAIN" -fi; - -if [ "$DEPLOY_LOCALCOPY_CA" ]; then - _info "Copying CA" - _debug "Copying $_cca to $DEPLOY_LOCALCOPY_CA" - eval "cp $_cca $DEPLOY_LOCALCOPY_CA" - if [ $? -ne 0 ]; then - _err "Failed to copy CA, aborting." - return 1; + + if [ "$DEPLOY_LOCALCOPY_CA" ]; then + _info "Copying CA" + _debug "Copying $_cca to $DEPLOY_LOCALCOPY_CA" + eval "cp $_cca $DEPLOY_LOCALCOPY_CA" + if [ $? -ne 0 ]; then + _err "Failed to copy CA, aborting." + return 1; + fi; + _savedeployconf DEPLOY_LOCALCOPY_CA "$DEPLOY_LOCALCOPY_CA" fi; - _savedeployconf DEPLOY_LOCALCOPY_CA "$DEPLOY_LOCALCOPY_CA" -fi; - -_reload=$DEPLOY_LOCALCOPY_RELOADCMD -_debug "Running reloadcmd $_reload" - -if [ -z "$_reload" ]; then - _info "Reloadcmd not provided, skipping." -else - _info "Reloading" - if eval $_reload; then - _info "Reload successful." - _savedeployconf DEPLOY_LOCALCOPY_RELOADCMD "$DEPLOY_LOCALCOPY_RELOADCMD" "base64" + + _reload=$DEPLOY_LOCALCOPY_RELOADCMD + _debug "Running reloadcmd $_reload" + + if [ -z "$_reload" ]; then + _info "Reloadcmd not provided, skipping." else - _err "Reload failed." + _info "Reloading" + if eval $_reload; then + _info "Reload successful." + _savedeployconf DEPLOY_LOCALCOPY_RELOADCMD "$DEPLOY_LOCALCOPY_RELOADCMD" "base64" + else + _err "Reload failed." + return 1; + fi; fi; -fi; - -_info "$(__green "'localcopy' deploy success")" -return 0 - + + _info "$(__green "'localcopy' deploy success")" + return 0 } From ce80fcd1166dfe56669ed31fe4bff294a16bd672 Mon Sep 17 00:00:00 2001 From: invario <67800603+invario@users.noreply.github.com> Date: Sat, 31 May 2025 14:54:44 -0400 Subject: [PATCH 5/5] Update localcopy.sh, shellcheck'ed and shfmt'ed --- deploy/localcopy.sh | 71 +++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 38 deletions(-) diff --git a/deploy/localcopy.sh b/deploy/localcopy.sh index e685d3f8..3b4fc219 100644 --- a/deploy/localcopy.sh +++ b/deploy/localcopy.sh @@ -1,10 +1,10 @@ #!/usr/bin/env sh -# Deploy-hook to very simply copy files to set directories and then -# execute whatever reloadcmd the admin needs afterwards. This can be +# Deploy-hook to very simply copy files to set directories and then +# execute whatever reloadcmd the admin needs afterwards. This can be # useful for configurations where the "multideploy" hook (in development) -# is used or when an admin wants ACME.SH to renew certs but needs to -# manually configure deployment via an external script +# is used or when an admin wants ACME.SH to renew certs but needs to +# manually configure deployment via an external script # (e.g. The deploy-freenas script for TrueNAS Core/Scale # https://github.com/danb35/deploy-freenas/ ) # @@ -26,80 +26,75 @@ localcopy_deploy() { _ccert="$3" _cca="$4" _cfullchain="$5" - + _debug _cdomain "$_cdomain" _debug _ckey "$_ckey" _debug _ccert "$_ccert" _debug _cca "$_cca" _debug _cfullchain "$_cfullchain" - + _getdeployconf DEPLOY_LOCALCOPY_CERTIFICATE _getdeployconf DEPLOY_LOCALCOPY_CERTKEY _getdeployconf DEPLOY_LOCALCOPY_FULLCHAIN _getdeployconf DEPLOY_LOCALCOPY_CA _getdeployconf DEPLOY_LOCALCOPY_RELOADCMD - + if [ "$DEPLOY_LOCALCOPY_CERTIFICATE" ]; then _info "Copying certificate" _debug "Copying $_ccert to $DEPLOY_LOCALCOPY_CERTIFICATE" - eval "cp $_ccert $DEPLOY_LOCALCOPY_CERTIFICATE" - if [ $? -ne 0 ]; then + if ! eval "cp $_ccert $DEPLOY_LOCALCOPY_CERTIFICATE"; then _err "Failed to copy certificate, aborting." - return 1; - fi; + return 1 + fi _savedeployconf DEPLOY_LOCALCOPY_CERTIFICATE "$DEPLOY_LOCALCOPY_CERTIFICATE" - fi; - + fi + if [ "$DEPLOY_LOCALCOPY_CERTKEY" ]; then _info "Copying certificate key" _debug "Copying $_ckey to $DEPLOY_LOCALCOPY_CERTKEY" - eval "cp $_ckey $DEPLOY_LOCALCOPY_CERTKEY" - if [ $? -ne 0 ]; then + if ! eval "cp $_ckey $DEPLOY_LOCALCOPY_CERTKEY"; then _err "Failed to copy certificate key, aborting." - return 1; - fi; + return 1 + fi _savedeployconf DEPLOY_LOCALCOPY_CERTKEY "$DEPLOY_LOCALCOPY_CERTKEY" - fi; - + fi + if [ "$DEPLOY_LOCALCOPY_FULLCHAIN" ]; then _info "Copying fullchain" _debug "Copying $_cfullchain to $DEPLOY_LOCALCOPY_FULLCHAIN" - eval "cp $_cfullchain $DEPLOY_LOCALCOPY_FULLCHAIN" - if [ $? -ne 0 ]; then + if ! eval "cp $_cfullchain $DEPLOY_LOCALCOPY_FULLCHAIN"; then _err "Failed to copy fullchain, aborting." - return 1; - fi; + return 1 + fi _savedeployconf DEPLOY_LOCALCOPY_FULLCHAIN "$DEPLOY_LOCALCOPY_FULLCHAIN" - fi; - + fi + if [ "$DEPLOY_LOCALCOPY_CA" ]; then _info "Copying CA" _debug "Copying $_cca to $DEPLOY_LOCALCOPY_CA" - eval "cp $_cca $DEPLOY_LOCALCOPY_CA" - if [ $? -ne 0 ]; then + if ! eval "cp $_cca $DEPLOY_LOCALCOPY_CA"; then _err "Failed to copy CA, aborting." - return 1; - fi; + return 1 + fi _savedeployconf DEPLOY_LOCALCOPY_CA "$DEPLOY_LOCALCOPY_CA" - fi; - + fi + _reload=$DEPLOY_LOCALCOPY_RELOADCMD _debug "Running reloadcmd $_reload" - + if [ -z "$_reload" ]; then _info "Reloadcmd not provided, skipping." else _info "Reloading" - if eval $_reload; then + if eval "$_reload"; then _info "Reload successful." _savedeployconf DEPLOY_LOCALCOPY_RELOADCMD "$DEPLOY_LOCALCOPY_RELOADCMD" "base64" else _err "Reload failed." - return 1; - fi; - fi; - + return 1 + fi + fi + _info "$(__green "'localcopy' deploy success")" return 0 } -