From: Ismaƫl Bouya Date: Tue, 28 Jun 2022 21:06:32 +0000 (+0200) Subject: Retry dovecot submission on failure X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=c92dab20c2bdb2039f37da4d675609986dc1dc6d;p=perso%2FImmae%2FConfig%2FNix.git Retry dovecot submission on failure --- diff --git a/modules/private/mail/postfix.nix b/modules/private/mail/postfix.nix index 3febe62..21f12ff 100644 --- a/modules/private/mail/postfix.nix +++ b/modules/private/mail/postfix.nix @@ -420,13 +420,20 @@ # here. rspamc_dovecot = pkgs.writeScriptBin "rspamc_dovecot" '' #! ${pkgs.stdenv.shell} + set -o pipefail sender="$1" original_recipient="$2" user="$3" ${pkgs.coreutils}/bin/cat - | \ - (${pkgs.rspamd}/bin/rspamc -h ${config.myServices.mail.rspamd.sockets.worker-controller} -c bayes -d "$user" --mime || true) | \ + ${pkgs.rspamd}/bin/rspamc -h ${config.myServices.mail.rspamd.sockets.worker-controller} -c bayes -d "$user" --mime | \ ${pkgs.dovecot}/libexec/dovecot/dovecot-lda -f "$sender" -a "$original_recipient" -d "$user" + if echo ''${PIPESTATUS[@]} | ${pkgs.gnugrep}/bin/grep -qE '^[0 ]+$'; then + exit 0 + else + # src/global/sys_exits.h to retry + exit 75 + fi ''; in [ "flags=ODRhu" "user=vhost:vhost"