summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mumi/config.scm.in8
-rw-r--r--scripts/mumi.in53
2 files changed, 39 insertions, 22 deletions
diff --git a/mumi/config.scm.in b/mumi/config.scm.in
index 7280e46..3daeace 100644
--- a/mumi/config.scm.in
+++ b/mumi/config.scm.in
@@ -1,5 +1,5 @@
;;; mumi -- Mediocre, uh, mail interface
-;;; Copyright © 2017, 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2017, 2018, 2019, 2020 Ricardo Wurmus <rekado@elephly.net>
;;;
;;; This program is free software: you can redistribute it and/or
;;; modify it under the terms of the GNU Affero General Public License
@@ -17,7 +17,11 @@
(define-module (mumi config)
#:use-module (debbugs)
- #:export (%config))
+ #:export (%config
+ mailer-enabled?))
+
+(define mailer-enabled?
+ (make-parameter #t))
(define %config
(let ((config
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)))))