refactoring: split helper functions into smaller scripts (#2420)

This commit is contained in:
Georg Lauterbach 2022-02-21 11:56:57 +01:00 committed by GitHub
parent 2927cc47c7
commit b61dfe1e24
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
41 changed files with 389 additions and 396 deletions

8
target/scripts/helpers/ssl.sh Normal file → Executable file
View file

@ -94,7 +94,7 @@ function _setup_ssl
# 2020 feature intended for Traefik v2 support only:
# https://github.com/docker-mailserver/docker-mailserver/pull/1553
# Extracts files `key.pem` and `fullchain.pem`.
# `_extract_certs_from_acme` is located in `helper-functions.sh`
# `_extract_certs_from_acme` is located in `helpers/ssl.sh`
# NOTE: See the `SSL_TYPE=letsencrypt` case below for more details.
function _traefik_support
{
@ -180,7 +180,7 @@ function _setup_ssl
# SSL_DOMAIN will have any wildcard prefix stripped for the output FQDN folder it is stored in.
# TODO: A wildcard cert needs to be provisioned via Traefik to validate if acme.json contains any other value for `main` or `sans` beyond the wildcard.
#
# NOTE: HOSTNAME is set via `helper-functions.sh`, it is not the original system HOSTNAME ENV anymore.
# NOTE: HOSTNAME is set via `helpers/dns.sh`, it is not the original system HOSTNAME ENV anymore.
# TODO: SSL_DOMAIN is Traefik specific, it no longer seems relevant and should be considered for removal.
_traefik_support
@ -407,7 +407,6 @@ function _setup_ssl
esac
}
export -f _setup_ssl
function _extract_certs_from_acme
{
@ -441,13 +440,11 @@ function _extract_certs_from_acme
_notify 'inf' "_extract_certs_from_acme | Certificate successfully extracted for '${CERT_DOMAIN}'"
}
export -f _extract_certs_from_acme
# Remove the `*.` prefix if it exists, else returns the input value
function _strip_wildcard_prefix {
[[ ${1} == "*."* ]] && echo "${1:2}" || echo "${1}"
}
export -f _strip_wildcard_prefix
# Compute checksums of monitored files,
# returned output on `stdout`: hash + filepath tuple on each line
@ -496,4 +493,3 @@ function _monitored_files_checksums
sha512sum -- "${CHANGED_FILES[@]}"
}
export -f _monitored_files_checksums