distro specific fixes
[distro-setup] / mail-setup
index 7ce6a0daeddb32bd3bcd1852227d6164b1058004..616d39bae20e9b2fdfe033754a39fb2e4fd297d8 100755 (executable)
@@ -361,31 +361,8 @@ reload=false
 if [[ -e /var/local/mail-setup-reload ]]; then
   reload=true
 fi
-# update file.
-# if the file changed, ur=true, else false.
-# note: duplicated in brc
-u() {
-  local tmp tmpdir dest="$1"
-  local base="${dest##*/}"
-  local dir="${dest%/*}"
-  if [[ $dir != "$base" ]]; then
-    # dest has a directory component
-    mkdir -p "$dir"
-  fi
-  ur=false # u result
-  tmpdir=$(mktemp -d)
-  cat >$tmpdir/"$base"
-  tmp=$(rsync -ic $tmpdir/"$base" "$dest")
-  if [[ $tmp ]]; then
-    printf "%s\n" "$tmp"
-    ur=true
-    if [[ $dest == /etc/systemd/system/* ]]; then
-      touch /var/local/mail-setup-reload
-      reload=true
-    fi
-  fi
-  rm -rf $tmpdir
-}
+
+source /a/bin/fai/fai/config/distro-install-common/bash-misc-funcs
 setini() {
   key="$1" value="$2" section="$3"
   file="/etc/radicale/config"
@@ -476,9 +453,17 @@ Pin-Priority: 500
 EOF
 fi
 
+
+unit-exists() {
+  systemctl cat $1 &>/dev/null
+}
+spamd-timer-exists() {
+  unit-exists spamassassin-maintenance.timer
+}
+
 # name change in t12, and now timer instead of cron option in /etc/default
 first_spamd_run=false
-if ! systemctl cat spamassassin-maintenance.timer &>/dev/null; then
+if ! spamd-timer-exists; then
   first_spamd_run=true
 fi
 
@@ -491,10 +476,14 @@ spamd_ser=spamd
 if systemctl cat spamassassin &>/dev/null; then
   spamd_ser=spamassassin
 elif $first_spamd_run; then
-  systemctl start spamassassin-maintenance
+  if spamd-timer-exists; then
+    systemctl start spamassassin-maintenance
+  fi
 fi
 
-systemctl enable --now spamassassin-maintenance.timer
+if spamd-timer-exists; then
+  systemctl enable --now spamassassin-maintenance.timer
+fi
 
 # note: pyzor debian readme says you need to run some initialization command
 # but its outdated.