domtool-public: workaround mailman plugin deficiencies
[hcoop/domtool2.git] / scripts / domtool-publish
index c6f0dbe..94bf9b1 100755 (executable)
@@ -1,7 +1,17 @@
 #!/bin/sh -e
 
+# grab tokens in case they were dropped by sudo
+if [ -x "$(which aklog)" ]; then
+    # ignore exit code, may fail on older versions
+    aklog || true
+fi
+
 redo_exim() {
-        touch /var/domtool/local_domains.cfg /var/domtool/relay_domains.cfg /var/domtool/mailman_domains.cfg
+        # FIXME: we're ignoring status of the touch command because we
+        # had to set mailman_domains.cfg immutable on mail relays not
+        # running mailman due to deficiencies on the domtool mailman
+        # plugin. Needs to be removed when not needed...
+        sudo -u domtool touch /var/domtool/local_domains.cfg /var/domtool/relay_domains.cfg /var/domtool/mailman_domains.cfg || true
        /bin/echo -n "domainlist local_domains = " >/etc/exim4/conf.d/main/10_domtool-domains
        /bin/cat /var/domtool/local_domains.cfg >>/etc/exim4/conf.d/main/10_domtool-domains
        /bin/echo "" >>/etc/exim4/conf.d/main/10_domtool-domains
@@ -46,7 +56,7 @@ case $1 in
                service bind9 restart
        ;;
        exim)
-               touch /var/domtool/aliases /var/domtool/aliases.default
+               sudo -u domtool touch /var/domtool/aliases /var/domtool/aliases.default
                /bin/cp /var/domtool/aliases /etc/aliases.hosted
                /bin/cp /var/domtool/aliases.default /etc/aliases.wildcard
                redo_exim