chore: `check-for-change.sh` - Support VHOST change visibility
- Moves the "handle changes" logic into it's own scoped function, out of the main change detection loop logic. - This will be benefit a future commit change that will rely on `VHOST_UPDATED=1`.
This commit is contained in:
parent
33a911d6cf
commit
9eabef9102
|
@ -49,8 +49,28 @@ function _check_for_changes() {
|
|||
|
||||
local CHANGED
|
||||
CHANGED=$(_get_changed_files "${CHKSUM_FILE}" "${CHKSUM_FILE}.new")
|
||||
_handle_changes
|
||||
|
||||
_remove_lock
|
||||
_log_with_date 'debug' 'Completed handling of detected change'
|
||||
|
||||
# mark changes as applied
|
||||
mv "${CHKSUM_FILE}.new" "${CHKSUM_FILE}"
|
||||
fi
|
||||
}
|
||||
|
||||
function _handle_changes() {
|
||||
# Variable to identify any config updates dependent upon vhost changes.
|
||||
local VHOST_UPDATED=0
|
||||
# These two configs are the source for /etc/postfix/vhost (managed mail domains)
|
||||
if [[ ${CHANGED} =~ ${DMS_DIR}/postfix-(accounts|virtual).cf ]]; then
|
||||
_log_with_date 'trace' 'Regenerating vhosts (Postfix)'
|
||||
# Regenerate via `helpers/postfix.sh`:
|
||||
_create_postfix_vhost
|
||||
|
||||
VHOST_UPDATED=1
|
||||
fi
|
||||
|
||||
# Handle any changes
|
||||
_ssl_changes
|
||||
_postfix_dovecot_changes
|
||||
_rspamd_changes
|
||||
|
@ -60,13 +80,6 @@ function _check_for_changes() {
|
|||
[[ ${ENABLE_AMAVIS} -eq 1 ]] && _reload_amavis
|
||||
_reload_postfix
|
||||
[[ ${SMTP_ONLY} -ne 1 ]] && dovecot reload
|
||||
|
||||
_remove_lock
|
||||
_log_with_date 'debug' 'Completed handling of detected change'
|
||||
|
||||
# mark changes as applied
|
||||
mv "${CHKSUM_FILE}.new" "${CHKSUM_FILE}"
|
||||
fi
|
||||
}
|
||||
|
||||
function _get_changed_files() {
|
||||
|
@ -85,9 +98,9 @@ function _get_changed_files() {
|
|||
}
|
||||
|
||||
function _reload_amavis() {
|
||||
if [[ ${CHANGED} =~ ${DMS_DIR}/postfix-accounts.cf ]] || [[ ${CHANGED} =~ ${DMS_DIR}/postfix-virtual.cf ]]; then
|
||||
# /etc/postfix/vhost was updated, amavis must refresh it's config by
|
||||
# reading this file again in case of new domains, otherwise they will be ignored.
|
||||
if [[ ${VHOST_UPDATED} -eq 1 ]]; then
|
||||
amavisd reload
|
||||
fi
|
||||
}
|
||||
|
@ -129,14 +142,6 @@ function _postfix_dovecot_changes() {
|
|||
[[ ${CHANGED} =~ ${DMS_DIR}/postfix-regexp.cf ]] && _handle_postfix_regexp_config
|
||||
[[ ${CHANGED} =~ ${DMS_DIR}/postfix-aliases.cf ]] && _handle_postfix_aliases_config
|
||||
|
||||
# Regenerate `/etc/postfix/vhost` (managed mail domains) via `helpers/postfix.sh`:
|
||||
if [[ ${CHANGED} =~ ${DMS_DIR}/postfix-accounts.cf ]] \
|
||||
|| [[ ${CHANGED} =~ ${DMS_DIR}/postfix-virtual.cf ]]
|
||||
then
|
||||
_log_with_date 'trace' 'Regenerating vhosts (Postfix)'
|
||||
_create_postfix_vhost
|
||||
fi
|
||||
|
||||
# Legacy workaround handled here, only seems necessary for _create_accounts:
|
||||
# - `helpers/accounts.sh` logic creates folders/files with wrong ownership.
|
||||
_chown_var_mail_if_necessary
|
||||
|
|
Loading…
Reference in New Issue