summaryrefslogtreecommitdiff
path: root/scripts/mumi.in
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/mumi.in')
-rw-r--r--scripts/mumi.in53
1 files changed, 33 insertions, 20 deletions
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)))))