2021-10-27 16:57:53 +02:00
|
|
|
(define-module (glicid services openldap)
|
2021-12-10 16:10:32 +01:00
|
|
|
#:use-module (gnu packages openldap)
|
2021-11-02 09:07:30 +01:00
|
|
|
#:use-module (gnu services)
|
|
|
|
#:use-module (gnu services shepherd)
|
|
|
|
#:use-module (guix)
|
|
|
|
#:use-module (guix records)
|
|
|
|
#:use-module (ice-9 match)
|
2021-10-27 16:57:53 +02:00
|
|
|
#: export (
|
|
|
|
openldap-configuration
|
|
|
|
openldap-configuration?
|
2021-11-05 16:30:43 +01:00
|
|
|
openldap-shepherd-service
|
|
|
|
openldap-service-type
|
2021-10-27 16:57:53 +02:00
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2021-11-02 09:07:30 +01:00
|
|
|
(define-record-type* <openldap-configuration>
|
2021-11-04 22:02:40 +01:00
|
|
|
openldap-configuration make-openldap-configuration
|
|
|
|
openldap-configuration?
|
2021-12-03 09:08:58 +01:00
|
|
|
(openldap openldap-configuration-openldap
|
2021-12-16 12:36:30 +01:00
|
|
|
(default openldap)
|
2021-11-04 22:02:40 +01:00
|
|
|
)
|
2021-12-03 09:08:58 +01:00
|
|
|
(uri openldap-configuration-uri
|
|
|
|
(default "ldapi:// ldap://")
|
|
|
|
)
|
|
|
|
(logflags openldap-configuration-logflags
|
2021-11-04 22:02:40 +01:00
|
|
|
(default "0")
|
|
|
|
)
|
2021-12-03 09:08:58 +01:00
|
|
|
(pid-file openldap-configuration-pid-file
|
2021-11-04 22:02:40 +01:00
|
|
|
(default "/var/run/openldap/slapd.pid")
|
|
|
|
)
|
2021-12-03 09:08:58 +01:00
|
|
|
(config-file openldap-configuration-config-file
|
2021-12-10 16:10:32 +01:00
|
|
|
(default (file-append openldap "/etc/openldap/slapd.conf"))
|
2021-11-04 22:02:40 +01:00
|
|
|
)
|
2021-12-03 09:08:58 +01:00
|
|
|
(log-file openldap-configuration-log-file
|
|
|
|
(default "/var/log/slapd.log")
|
|
|
|
)
|
2021-11-02 09:07:30 +01:00
|
|
|
)
|
2021-12-02 21:30:43 +01:00
|
|
|
|
2021-11-02 09:07:30 +01:00
|
|
|
(define openldap-shepherd-service
|
2021-11-04 22:02:40 +01:00
|
|
|
(match-lambda
|
2021-12-03 09:08:58 +01:00
|
|
|
(($ <openldap-configuration> openldap uri logflags pid-file config-file log-file)
|
2021-11-04 22:02:40 +01:00
|
|
|
(list
|
|
|
|
(shepherd-service
|
|
|
|
(provision '(slapd) )
|
|
|
|
(documentation "Run openldap.")
|
|
|
|
(requirement '(user-processes))
|
2021-12-10 16:10:32 +01:00
|
|
|
(respawn? #t)
|
2021-12-03 10:45:27 +01:00
|
|
|
(start #~(make-forkexec-constructor
|
2021-11-02 09:07:30 +01:00
|
|
|
(list
|
2021-11-05 16:39:03 +01:00
|
|
|
#$(file-append openldap "/libexec/slapd")
|
2021-12-03 09:08:58 +01:00
|
|
|
"-h" #$uri
|
2021-12-02 21:50:37 +01:00
|
|
|
"-d" #$logflags
|
2021-11-04 22:02:40 +01:00
|
|
|
"-f" #$config-file
|
2021-10-27 16:57:53 +02:00
|
|
|
)
|
2021-11-04 22:02:40 +01:00
|
|
|
#:pid-file #$pid-file
|
2021-12-03 09:08:58 +01:00
|
|
|
#:log-file #$log-file
|
2021-11-04 22:02:40 +01:00
|
|
|
))
|
|
|
|
(stop #~(make-kill-destructor))
|
2021-10-27 16:57:53 +02:00
|
|
|
)
|
2021-11-04 22:02:40 +01:00
|
|
|
)
|
2021-10-27 16:57:53 +02:00
|
|
|
)
|
2021-11-04 22:02:40 +01:00
|
|
|
)
|
2021-11-02 09:07:30 +01:00
|
|
|
)
|
2021-12-02 21:30:43 +01:00
|
|
|
|
2021-12-17 11:00:10 +01:00
|
|
|
|
2021-12-17 11:09:24 +01:00
|
|
|
(define %openldap-activation
|
2021-12-17 11:00:10 +01:00
|
|
|
(with-imported-modules '((guix build utils))
|
|
|
|
#~(begin
|
|
|
|
(use-modules (guix build utils))
|
|
|
|
(mkdir-p "/var/run/openldap")
|
|
|
|
(mkdir-p "/var/lib/ldap")
|
|
|
|
#t
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2021-11-02 09:07:30 +01:00
|
|
|
(define openldap-service-type
|
2021-11-04 22:02:40 +01:00
|
|
|
(service-type (name 'slapd)
|
|
|
|
(extensions
|
2021-12-17 11:00:10 +01:00
|
|
|
(list
|
|
|
|
(service-extension shepherd-root-service-type openldap-shepherd-service)
|
2021-12-17 11:09:24 +01:00
|
|
|
(service-extension activation-service-type (const %openldap-activation))
|
2021-12-17 11:00:10 +01:00
|
|
|
)
|
2021-10-27 16:57:53 +02:00
|
|
|
)
|
2021-11-04 22:02:40 +01:00
|
|
|
(description "Run @uref{https://www.openldap.org, Openldap} community developped LDAP software.")
|
|
|
|
)
|
2021-11-02 09:07:30 +01:00
|
|
|
)
|