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,17 +49,7 @@ function _check_for_changes() {
|
||||||
|
|
||||||
local CHANGED
|
local CHANGED
|
||||||
CHANGED=$(_get_changed_files "${CHKSUM_FILE}" "${CHKSUM_FILE}.new")
|
CHANGED=$(_get_changed_files "${CHKSUM_FILE}" "${CHKSUM_FILE}.new")
|
||||||
|
_handle_changes
|
||||||
# Handle any changes
|
|
||||||
_ssl_changes
|
|
||||||
_postfix_dovecot_changes
|
|
||||||
_rspamd_changes
|
|
||||||
|
|
||||||
_log_with_date 'debug' 'Reloading services due to detected changes'
|
|
||||||
|
|
||||||
[[ ${ENABLE_AMAVIS} -eq 1 ]] && _reload_amavis
|
|
||||||
_reload_postfix
|
|
||||||
[[ ${SMTP_ONLY} -ne 1 ]] && dovecot reload
|
|
||||||
|
|
||||||
_remove_lock
|
_remove_lock
|
||||||
_log_with_date 'debug' 'Completed handling of detected change'
|
_log_with_date 'debug' 'Completed handling of detected change'
|
||||||
|
@ -69,6 +59,29 @@ function _check_for_changes() {
|
||||||
fi
|
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
|
||||||
|
|
||||||
|
_ssl_changes
|
||||||
|
_postfix_dovecot_changes
|
||||||
|
_rspamd_changes
|
||||||
|
|
||||||
|
_log_with_date 'debug' 'Reloading services due to detected changes'
|
||||||
|
|
||||||
|
[[ ${ENABLE_AMAVIS} -eq 1 ]] && _reload_amavis
|
||||||
|
_reload_postfix
|
||||||
|
[[ ${SMTP_ONLY} -ne 1 ]] && dovecot reload
|
||||||
|
}
|
||||||
|
|
||||||
function _get_changed_files() {
|
function _get_changed_files() {
|
||||||
local CHKSUM_CURRENT=${1}
|
local CHKSUM_CURRENT=${1}
|
||||||
local CHKSUM_NEW=${2}
|
local CHKSUM_NEW=${2}
|
||||||
|
@ -85,9 +98,9 @@ function _get_changed_files() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function _reload_amavis() {
|
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
|
||||||
# /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.
|
||||||
# reading this file again in case of new domains, otherwise they will be ignored.
|
if [[ ${VHOST_UPDATED} -eq 1 ]]; then
|
||||||
amavisd reload
|
amavisd reload
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -129,14 +142,6 @@ function _postfix_dovecot_changes() {
|
||||||
[[ ${CHANGED} =~ ${DMS_DIR}/postfix-regexp.cf ]] && _handle_postfix_regexp_config
|
[[ ${CHANGED} =~ ${DMS_DIR}/postfix-regexp.cf ]] && _handle_postfix_regexp_config
|
||||||
[[ ${CHANGED} =~ ${DMS_DIR}/postfix-aliases.cf ]] && _handle_postfix_aliases_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:
|
# Legacy workaround handled here, only seems necessary for _create_accounts:
|
||||||
# - `helpers/accounts.sh` logic creates folders/files with wrong ownership.
|
# - `helpers/accounts.sh` logic creates folders/files with wrong ownership.
|
||||||
_chown_var_mail_if_necessary
|
_chown_var_mail_if_necessary
|
||||||
|
|
Loading…
Reference in New Issue