diff --git a/Documentation/man1/remail_pipe.rst b/Documentation/man1/remail_pipe.rst index 1c91604..8077c6a 100644 --- a/Documentation/man1/remail_pipe.rst +++ b/Documentation/man1/remail_pipe.rst @@ -24,6 +24,14 @@ Options -h, --help Show this help message and exit +-c, --cfgupdate + Read the configuration update and do not process mail from stdin. That + allows to send out welcome mails after a list configuration file was + updated. Otherwise the welcome mails are delayed until actual mail + delivery happens. The update and welcome mail processing is serialized + via the lock file in the working directory; no external serialization + against a concurrent mail delivery required. + -s syslog, --syslog Use syslog for logging. Default is stderr @@ -59,7 +67,7 @@ Exit codes .. list-table:: * - 0 - - Mail was successfully delivered + - Mail was successfully delivered or config update was successful * - 1 - No enabled mailinglist found for delivery * - 2 diff --git a/remail/remaild.py b/remail/remaild.py index bbe5803..3f577cf 100644 --- a/remail/remaild.py +++ b/remail/remaild.py @@ -370,13 +370,16 @@ class remaild(object): return self.should_stop() # The pipe handling interface - def handle_pipe(self): + def handle_pipe(self, cfgupdate): self._should_reload = True self.reconfigure() if not self.enabled: return 1 + if cfgupdate: + return 0 + policy = EmailPolicy(utf8=True) msg = message_from_file(sys.stdin, policy=policy) return self.process_msg(msg, 'pipe input') diff --git a/remail_pipe b/remail_pipe index 4e4c1b4..1f7e2ca 100755 --- a/remail_pipe +++ b/remail_pipe @@ -19,6 +19,9 @@ def exit_daemon(logger, res): if __name__ == '__main__': parser = ArgumentParser(description='remail pipe') parser.add_argument('config', help='Config file') + parser.add_argument('--cfgupdate', '-c', dest='cfgupdate', + action='store_true', + help='Handle config file update. No mail processing.') parser.add_argument('--syslog', '-s', dest='syslog', action='store_true', help='Use syslog for logging. Default is stderr') parser.add_argument('--verbose', '-v', dest='verbose', action='store_true', @@ -46,7 +49,7 @@ if __name__ == '__main__': exit_daemon(logger, 11) try: - res = rd.handle_pipe() + res = rd.handle_pipe(args.cfgupdate) except Exception as ex: ''' Exceptions which reach here are fatal