mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2025-06-28 19:50:16 +02:00
improvement: get rid of subshell + exec
in helper-functions.sh
(#2401)
* get rid of subshell + exec The new way of executing `sha512sum` should work as well as the old way but without the clutter and possible problems the usage of subshells + exec incurs. Moreover, there was a misconception about array expansion. Using `""` around an expanding array (`${ARRAY[@]}`) is quite fine (and actually the preffered way), not because it makes the expansion _one_ string (this would be `${ARRAY[*]}`), but it makes sure when elements are expanded, each element has `""` around them so to speak, i.e. there is no re-splitting of these elements. * removed old concerns in comments * increase test and check for changes sleep duration
This commit is contained in:
parent
7b21db77cc
commit
ede2b2394a
3 changed files with 19 additions and 24 deletions
|
@ -225,33 +225,33 @@ export -f _notify
|
|||
CHKSUM_FILE=/tmp/docker-mailserver-config-chksum
|
||||
|
||||
# Compute checksums of monitored files,
|
||||
# returned output is lines of hashed content + filepath pairs.
|
||||
# returned output on `stdout`: hash + filepath tuple on each line
|
||||
function _monitored_files_checksums
|
||||
{
|
||||
# If a wildcard path pattern (or an empty ENV) would yield an invalid path
|
||||
# or no results, `shopt -s nullglob` prevents it from being added.
|
||||
shopt -s nullglob
|
||||
declare -a CERT_FILES
|
||||
|
||||
# React to any cert changes within the following letsencrypt locations:
|
||||
local CERT_FILES=(
|
||||
CERT_FILES=(
|
||||
/etc/letsencrypt/live/"${SSL_DOMAIN}"/*.pem
|
||||
/etc/letsencrypt/live/"${HOSTNAME}"/*.pem
|
||||
/etc/letsencrypt/live/"${DOMAINNAME}"/*.pem
|
||||
)
|
||||
|
||||
# CERT_FILES should expand to separate paths, not a single string;
|
||||
# otherwise fails to generate checksums for these file paths.
|
||||
#shellcheck disable=SC2068
|
||||
(
|
||||
cd /tmp/docker-mailserver || exit 1
|
||||
exec sha512sum 2>/dev/null -- \
|
||||
postfix-accounts.cf \
|
||||
postfix-virtual.cf \
|
||||
postfix-aliases.cf \
|
||||
dovecot-quotas.cf \
|
||||
/etc/letsencrypt/acme.json \
|
||||
${CERT_FILES[@]}
|
||||
)
|
||||
if [[ ! -d /tmp/docker-mailserver ]]
|
||||
then
|
||||
return 1
|
||||
fi
|
||||
|
||||
sha512sum 2>/dev/null -- \
|
||||
/tmp/docker-mailserver/postfix-accounts.cf \
|
||||
/tmp/docker-mailserver/postfix-virtual.cf \
|
||||
/tmp/docker-mailserver/postfix-aliases.cf \
|
||||
/tmp/docker-mailserver/dovecot-quotas.cf \
|
||||
/etc/letsencrypt/acme.json \
|
||||
"${CERT_FILES[@]}"
|
||||
}
|
||||
export -f _monitored_files_checksums
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue