if [[ -e /var/local/mail-setup-reload ]]; then
reload=true
fi
+declare -A modified_services
source /a/bin/fai/fai/config/distro-install-common/bash-misc-funcs
setini() {
serverp() {
case $HOSTNAME in
li|bk|je)
- return true
+ return 0
;;
esac
- return false
+ return 1
}
nn-hostp() {
case $HOSTNAME in
li|je)
- return false
+ return 1
;;
esac
- return true
+ return 0
}
reifactive() {
bhost_t=false
case $HOSTNAME in
$MAIL_HOST) : ;;
- kd|x2|x3|kw|sy|bo|so|frodo)
+ kd|x2|x3|kw|sy|so|frodo)
bhost_t=true
;;
esac
#
# note: rspamd would need to be here if we were using it. Note: these
# don't start, but they are enabled.
-pi-nostart exim4 exim4-daemon-heavy spamassassin unbound clamav-daemon wireguard
+pi-nostart exim4 exim4-daemon-heavy spamassassin unbound wireguard
spamd_remove=spamassassin
spamd_ser=spamd
case $HOSTNAME in
$MAIL_HOST|bk)
- m systemctl --now enable mailnn mailnnroute
+ # If any of these have config changes, then restart them as needed:
+ # sre mailnn mailnnroute $vpnser
+ m systemctl --now enable mailnn mailnnroute $vpnser
;;&
$MAIL_HOST)
- # we use dns to start wg
- if $reload; then
- sre unbound
- else
- m systemctl --now enable unbound
- fi
- ;;&
- $MAIL_HOST|bk)
- # If these have changes, id rather manually restart it, id rather
- # not restart and cause temporary errors
- if $reload; then
- sre $vpnser
- else
- m systemctl --now enable $vpnser
- fi
+ # If this service's config changes, add a manual restart here.
+ # note: we use dns to start wireguard
+ m systemctl --now enable unbound
;;&
bk)
if ! systemctl is-active clamav-daemon >/dev/null; then
$MAIL_HOST|bk|je)
# start spamassassin/dovecot before exim.
sre dovecot $myspam_ser mailtest-check
+
# Wait a bit before restarting exim, else I get a paniclog entry
# like: spam acl condition: all spamd servers failed. But I'm tired
# of waiting. I'll deal with this some other way.
;;&
esac
+## wip to only restart services that actually need restarting.
+all_units=(
+ mailnn.service mailnnroute.service $vpnser.service
+ unbound.service
+ clamav-daemon.service
+ dovecot.service $myspam_ser.service mailtest-check.service
+ mailclean.timer
+ radicale.service
+)
+for unit in ${all_units[@]}; do
+ if [[ ${modified_services[$unit]} ]]; then
+ enabled=$(systemctl is-enabled $service 2>/dev/null ||:)
+ if [[ $enabled == enabled ]]; then
+ systemctl stop $service
+ systemctl start $service
+ fi
+ fi
+done
+
# for debugging dns issues
case $HOSTNAME in
je|bk)