various minor improvements
[distro-setup] / mail-setup
index 7cc7a32b6244b2b162ef5a16214c579cc3dddc82..83ae53c1b2fb8c9e402208d77d9610ff875b4242 100755 (executable)
@@ -704,6 +704,25 @@ EOF
         rm -f /etc/exim4/update-exim4.conf.conf
         dpkg-reconfigure -u -fnoninteractive exim4-config
     fi
+
+    # i have the spool directory be common to distro multi-boot, so
+    # we need the uid to be the same. 608 cuz it's kind of in the middle
+    # of the free system uids.
+    IFS=:; read _ _ uid _ < <(getent passwd Debian-exim ); unset IFS
+    IFS=:; read _ _ gid _ < <(getent group Debian-exim ); unset IFS
+    if [[ ! $uid ]]; then
+        # from /var/lib/dpkg/info/exim4-base.postinst, plus uid and gid options
+       adduser --uid 608 --gid 608 --system --group --quiet --home /var/spool/exim4 \
+               --no-create-home --disabled-login --force-badname Debian-exim
+    elif [[ $uid != 608 ]]; then
+        systemctl stop exim4 ||:
+        usermod -u 608 Debian-exim
+        groupmod -g 608 Debian-exim
+        usermod -g 608 Debian-exim
+        find / /nocow -xdev -uid $uid -exec chown -h 608 {} +
+        find / /nocow -xdev -gid $gid -exec chgrp -h 608 {} +
+    fi
+
     # light version of exim does not have sasl auth support.
     apt-get -y install --purge --auto-remove exim4-daemon-heavy spamassassin
 
@@ -868,7 +887,7 @@ fi
 dir=/nocow/$type
 sdir=/var/spool/$type
 # we only do this if our system has $dir
-if [[ -e $dir && $(readlink -f $sdir) != $dir ]]; then
+if [[ -e /nocow && $(readlink -f $sdir) != $dir ]]; then
     systemctl stop $type
     if [[ ! -e $dir && -d $sdir ]]; then
         mv $sdir $dir