From c1691e492d921e948efb839ebb6166d5fe1ceb01 Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Sun, 5 Apr 2020 15:53:47 +0200 Subject: Rewrite script and add "mailer" command. The scirpt now takes a mandatory first argument and a bunch of options. --- scripts/mumi.in | 53 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 20 deletions(-) (limited to 'scripts') diff --git a/scripts/mumi.in b/scripts/mumi.in index ac2eb9b..9f8fcf8 100644 --- a/scripts/mumi.in +++ b/scripts/mumi.in @@ -30,6 +30,7 @@ (ice-9 format) (mumi config) (mumi bugs) + (mumi jobs) (mumi messages) (mumi web server) (debbugs)) @@ -102,18 +103,22 @@ (alist-cons 'listen-repl port (alist-delete 'listen-repl result)) (error "invalid REPL server port" arg))))) - (option '("fetch") #f #f + (option '("disable-mailer") #f #f (lambda (opt name arg result) - (alist-cons 'fetch #t result))) - (option '("worker") #f #f + (alist-cons 'disable-mailer #t result))) + (option '("sender") #t #f (lambda (opt name arg result) - (alist-cons 'worker #t result))))) + (alist-cons 'sender arg result))) + (option '("smtp") #t #f + (lambda (opt name arg result) + (alist-cons 'smtp arg result))))) (define %default-options ;; Alist of default option values `((listen-repl . #f) - (fetch . #f) - (worker . #f))) + (smtp . #f) + (sender . #f) + (disable-mailer . #f))) (define (parse-options args) (args-fold @@ -124,17 +129,25 @@ (error "extraneous argument" arg)) %default-options)) -(let ((opts (parse-options (cdr (program-arguments))))) - (cond - ((assoc-ref opts 'worker) - (update-state!)) - ((assoc-ref opts 'fetch) - (fetch-messages!)) - (else - (let ((repl-port (assoc-ref opts 'listen-repl))) - (when repl-port - (spawn-server (make-tcp-server-socket #:port repl-port)))) - (use-modules (mumimu)) - (mu-index) - (mu:initialize (%config 'mail-dir)) - (start-mumi-web-server 1234)))) +(match (cdr (program-arguments)) + (("mailer" . rest) + (let* ((opts (parse-options rest)) + (sender (assoc-ref opts 'sender)) + (smtp (assoc-ref opts 'smtp))) + (if (and sender smtp) + (worker-loop opts) + (error "Both sender and smtp options must be provided!")))) + (("worker") + (update-state!)) + (("fetch") + (fetch-messages!)) + (("web" . rest) + (let ((opts (parse-options rest))) + (parameterize ((mailer-enabled? (not (assoc-ref opts 'disable-mailer)))) + (let ((repl-port (assoc-ref opts 'listen-repl))) + (when repl-port + (spawn-server (make-tcp-server-socket #:port repl-port)))) + (use-modules (mumimu)) + (mu-index) + (mu:initialize (%config 'mail-dir)) + (start-mumi-web-server 1234))))) -- cgit v1.2.3