Fix multideploy MULTIDEPLOY_FILENAME conf read and allow an absolute path

_getdeployconf assigns and exports the variable, it does not print the
value, so wrapping it in a command substitution ran it in a subshell and
always yielded an empty string. A MULTIDEPLOY_FILENAME saved by an
earlier run was therefore never restored on renewal and the hook
silently fell back to multideploy.yml. Call it the same way every other
deploy hook does.

Also treat a MULTIDEPLOY_FILENAME starting with '/' as an absolute path
instead of always resolving it under DOMAIN_PATH, so one deploy file can
live outside the certificate directory and be shared by all domains.
Names without a leading '/' keep resolving under DOMAIN_PATH as before.
This commit is contained in:
neil committed 2026-08-05 23:01:54 +08:00
1 parent 603a126a7c
commit 9aad4dcbd5
1 file changed
+19 -8
+19 -8
View File
@@ -10,6 +10,10 @@
# Usage (shown values are the examples): # Usage (shown values are the examples):
# 1. Set optional environment variables # 1. Set optional environment variables
# - export MULTIDEPLOY_FILENAME="multideploy.yaml" - "multideploy.yml" will be automatically used if not set" # - export MULTIDEPLOY_FILENAME="multideploy.yaml" - "multideploy.yml" will be automatically used if not set"
# A name without a leading '/' is looked up in the certificate directory
# of the domain. An absolute path is used as is, so a single deploy file
# can be shared by all domains, e.g.
# - export MULTIDEPLOY_FILENAME="/etc/acme/multideploy.yml"
# #
# 2. Run command: # 2. Run command:
# acme.sh --deploy --deploy-hook multideploy -d example.com # acme.sh --deploy --deploy-hook multideploy -d example.com
@@ -49,7 +53,7 @@ multideploy_deploy() {
_debug _cfullchain "$_cfullchain" _debug _cfullchain "$_cfullchain"
_debug _cpfx "$_cpfx" _debug _cpfx "$_cpfx"
MULTIDEPLOY_FILENAME="${MULTIDEPLOY_FILENAME:-$(_getdeployconf MULTIDEPLOY_FILENAME)}" _getdeployconf MULTIDEPLOY_FILENAME
if [ -z "$MULTIDEPLOY_FILENAME" ]; then if [ -z "$MULTIDEPLOY_FILENAME" ]; then
MULTIDEPLOY_FILENAME="multideploy.yml" MULTIDEPLOY_FILENAME="multideploy.yml"
_info "MULTIDEPLOY_FILENAME is not set, so I will use 'multideploy.yml'." _info "MULTIDEPLOY_FILENAME is not set, so I will use 'multideploy.yml'."
@@ -75,7 +79,8 @@ multideploy_deploy() {
# This function preprocesses the deploy file by checking if 'yq' is installed, # This function preprocesses the deploy file by checking if 'yq' is installed,
# verifying the existence of the deploy file, and ensuring only one deploy file is present. # verifying the existence of the deploy file, and ensuring only one deploy file is present.
# Arguments: # Arguments:
# $@ - Posible deploy file names. # $@ - Posible deploy file names. A name starting with '/' is treated as an
# absolute path, any other name is relative to the domain directory.
# Usage: # Usage:
# _preprocess_deployfile "<deploy_file1>" "<deploy_file2>?" # _preprocess_deployfile "<deploy_file1>" "<deploy_file2>?"
_preprocess_deployfile() { _preprocess_deployfile() {
@@ -87,15 +92,21 @@ _preprocess_deployfile() {
_debug3 "yq is installed." _debug3 "yq is installed."
# Check if deploy file exists # Check if deploy file exists
found_file=""
for file in "$@"; do for file in "$@"; do
_debug3 "Checking file" "$DOMAIN_PATH/$file" if _startswith "$file" "/"; then
if [ -f "$DOMAIN_PATH/$file" ]; then _multideploy_path="$file"
else
_multideploy_path="$DOMAIN_PATH/$file"
fi
_debug3 "Checking file" "$_multideploy_path"
if [ -f "$_multideploy_path" ]; then
_debug3 "File found" _debug3 "File found"
if [ -n "$found_file" ]; then if [ -n "$found_file" ]; then
_err "Multiple deploy files found. Please keep only one deploy file." _err "Multiple deploy files found. Please keep only one deploy file."
return 1 return 1
fi fi
found_file="$file" found_file="$_multideploy_path"
else else
_debug3 "File not found" _debug3 "File not found"
fi fi
@@ -105,12 +116,12 @@ _preprocess_deployfile() {
_err "Deploy file not found. Go to https://github.com/acmesh-official/acme.sh/wiki/deployhooks#36-deploying-to-multiple-services-with-the-same-hooks to see how to create one." _err "Deploy file not found. Go to https://github.com/acmesh-official/acme.sh/wiki/deployhooks#36-deploying-to-multiple-services-with-the-same-hooks to see how to create one."
return 1 return 1
fi fi
if ! _check_deployfile "$DOMAIN_PATH/$found_file"; then if ! _check_deployfile "$found_file"; then
_err "Deploy file is not valid: $DOMAIN_PATH/$found_file" _err "Deploy file is not valid: $found_file"
return 1 return 1
fi fi
echo "$DOMAIN_PATH/$found_file" echo "$found_file"
} }
# Description: # Description:
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.