mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-24 13:28:12 -05:00
services: dovecot: Copy dovecot.conf to /etc/dovecot.
Many Dovecot utilities compiled with assumption of ‘/etc/dovecot/dovecot.conf’ existence. * gnu/services/mail.scm (dovecot-shepherd-service): Move config generation. Invoke ‘dovecot’ without ‘-c’ flag. (%dovecot-activation): Copy ‘dovecot.conf’ to ‘/etc/dovecot’. (dovecot-service-type): Make ‘%dovecot-activation’ non-constant.
This commit is contained in:
parent
a539ad867d
commit
6310dff1dc
1 changed files with 74 additions and 73 deletions
|
@ -1435,8 +1435,17 @@ (define %dovecot-accounts
|
|||
(home-directory "/var/empty")
|
||||
(shell (file-append shadow "/sbin/nologin")))))
|
||||
|
||||
(define %dovecot-activation
|
||||
(define (%dovecot-activation config)
|
||||
;; Activation gexp.
|
||||
(let ((config-str
|
||||
(cond
|
||||
((opaque-dovecot-configuration? config)
|
||||
(opaque-dovecot-configuration-string config))
|
||||
(else
|
||||
(with-output-to-string
|
||||
(lambda ()
|
||||
(serialize-configuration config
|
||||
dovecot-configuration-fields)))))))
|
||||
#~(begin
|
||||
(use-modules (guix build utils))
|
||||
(define (mkdir-p/perms directory owner perms)
|
||||
|
@ -1487,26 +1496,18 @@ (define* (create-self-signed-certificate-if-absent
|
|||
(mkdir-p/perms "/var/run/dovecot" user #o755)
|
||||
(mkdir-p/perms "/var/lib/dovecot" user #o755)
|
||||
(mkdir-p/perms "/etc/dovecot" user #o755)
|
||||
(copy-file #$(plain-file "dovecot.conf" config-str)
|
||||
"/etc/dovecot/dovecot.conf")
|
||||
(mkdir-p/perms "/etc/dovecot/private" user #o700)
|
||||
(create-self-signed-certificate-if-absent
|
||||
#:private-key "/etc/dovecot/private/default.pem"
|
||||
#:public-key "/etc/dovecot/default.pem"
|
||||
#:owner (getpwnam "root")
|
||||
#:common-name (format #f "Dovecot service on ~a" (gethostname))))))
|
||||
#:common-name (format #f "Dovecot service on ~a" (gethostname)))))))
|
||||
|
||||
(define (dovecot-shepherd-service config)
|
||||
"Return a list of <shepherd-service> for CONFIG."
|
||||
(let* ((config-str
|
||||
(cond
|
||||
((opaque-dovecot-configuration? config)
|
||||
(opaque-dovecot-configuration-string config))
|
||||
(else
|
||||
(with-output-to-string
|
||||
(lambda ()
|
||||
(serialize-configuration config
|
||||
dovecot-configuration-fields))))))
|
||||
(config-file (plain-file "dovecot.conf" config-str))
|
||||
(dovecot (if (opaque-dovecot-configuration? config)
|
||||
(let ((dovecot (if (opaque-dovecot-configuration? config)
|
||||
(opaque-dovecot-configuration-dovecot config)
|
||||
(dovecot-configuration-dovecot config))))
|
||||
(list (shepherd-service
|
||||
|
@ -1515,10 +1516,10 @@ (define (dovecot-shepherd-service config)
|
|||
(requirement '(networking))
|
||||
(start #~(make-forkexec-constructor
|
||||
(list (string-append #$dovecot "/sbin/dovecot")
|
||||
"-F" "-c" #$config-file)))
|
||||
"-F")))
|
||||
(stop #~(make-forkexec-constructor
|
||||
(list (string-append #$dovecot "/sbin/dovecot")
|
||||
"-c" #$config-file "stop")))))))
|
||||
"stop")))))))
|
||||
|
||||
(define %dovecot-pam-services
|
||||
(list (unix-pam-service "dovecot")))
|
||||
|
@ -1533,7 +1534,7 @@ (define dovecot-service-type
|
|||
(service-extension pam-root-service-type
|
||||
(const %dovecot-pam-services))
|
||||
(service-extension activation-service-type
|
||||
(const %dovecot-activation))))))
|
||||
%dovecot-activation)))))
|
||||
|
||||
(define* (dovecot-service #:key (config (dovecot-configuration)))
|
||||
"Return a service that runs @command{dovecot}, a mail server that can run
|
||||
|
|
Loading…
Reference in a new issue