diff options
author | 宋文武 <iyzsong@member.fsf.org> | 2016-11-21 20:41:17 +0800 |
---|---|---|
committer | 宋文武 <iyzsong@member.fsf.org> | 2016-11-26 12:50:11 +0800 |
commit | f88371e86602a9b3d86f2030709f719778613552 (patch) | |
tree | 06c0aef469b28946a64f8f81146aac46e5fe9801 /gnu/services | |
parent | 0959478c726a3117da815f47c0ce92e4588a8ac4 (diff) | |
download | guix-f88371e86602a9b3d86f2030709f719778613552.tar.gz |
services: Add opensmtpd service.
* gnu/services/mail.scm (<opensmtpd-configuration>): New record type. (%default-opensmtpd-config-file, %opensmtpd-accounts): New variables. (opensmtpd-shepherd-service, opensmtpd-activation): New procedures. (opensmtpd-service-type): New variable. * doc/guix.texi (Mail Services): Document it.
Diffstat (limited to 'gnu/services')
-rw-r--r-- | gnu/services/mail.scm | 82 |
1 files changed, 81 insertions, 1 deletions
diff --git a/gnu/services/mail.scm b/gnu/services/mail.scm index cb0f119f43..f7ab9516ba 100644 --- a/gnu/services/mail.scm +++ b/gnu/services/mail.scm @@ -51,7 +51,12 @@ protocol-configuration plugin-configuration mailbox-configuration - namespace-configuration)) + namespace-configuration + + opensmtpd-configuration + opensmtpd-configuration? + opensmtpd-service-type + %default-opensmtpd-config-file)) ;;; Commentary: ;;; @@ -1691,3 +1696,78 @@ by @code{dovecot-configuration}. @var{config} may also be created by (format #t "@end deftypevr\n\n"))) fields)))) (generate 'dovecot-configuration)) + + +;;; +;;; OpenSMTPD. +;;; + +(define-record-type* <opensmtpd-configuration> + opensmtpd-configuration make-opensmtpd-configuration + opensmtpd-configuration? + (package opensmtpd-configuration-package + (default opensmtpd)) + (config-file opensmtpd-configuration-config-file + (default %default-opensmtpd-config-file))) + +(define %default-opensmtpd-config-file + (plain-file "smtpd.conf" " +listen on lo +accept from any for local deliver to mbox +accept from local for any relay +")) + +(define opensmtpd-shepherd-service + (match-lambda + (($ <opensmtpd-configuration> package config-file) + (list (shepherd-service + (provision '(smtpd)) + (requirement '(loopback)) + (documentation "Run the OpenSMTPD daemon.") + (start (let ((smtpd (file-append package "/sbin/smtpd"))) + #~(make-forkexec-constructor + (list #$smtpd "-f" #$config-file) + #:pid-file "/var/run/smtpd.pid"))) + (stop #~(make-kill-destructor))))))) + +(define %opensmtpd-accounts + (list (user-group + (name "smtpq") + (system? #t)) + (user-account + (name "smtpd") + (group "nogroup") + (system? #t) + (comment "SMTP Daemon") + (home-directory "/var/empty") + (shell (file-append shadow "/sbin/nologin"))) + (user-account + (name "smtpq") + (group "smtpq") + (system? #t) + (comment "SMTPD Queue") + (home-directory "/var/empty") + (shell (file-append shadow "/sbin/nologin"))))) + +(define opensmtpd-activation + (match-lambda + (($ <opensmtpd-configuration> package config-file) + (let ((smtpd (file-append package "/sbin/smtpd"))) + #~(begin + ;; Create mbox and spool directories. + (mkdir-p "/var/mail") + (mkdir-p "/var/spool/smtpd") + (chmod "/var/spool/smtpd" #o711)))))) + +(define opensmtpd-service-type + (service-type + (name 'opensmtpd) + (extensions + (list (service-extension account-service-type + (const %opensmtpd-accounts)) + (service-extension activation-service-type + opensmtpd-activation) + (service-extension profile-service-type + (compose list opensmtpd-configuration-package)) + (service-extension shepherd-root-service-type + opensmtpd-shepherd-service))))) |