services: syslog: Move configuration to /etc/syslog.conf.
Having the configuration live at a static location makes it possible to hot-reload it. * gnu/services/base.scm (syslog.conf): New variable. (syslog-etc, syslog-shepherd-service): New procedures. (syslog-service-type): Rewrite using the above new variable and procedures, extending etc-service-type with its configuration file.
This commit is contained in:
parent
184658e282
commit
1ae279d7c8
@ -15,7 +15,7 @@
|
||||
;;; Copyright © 2020, 2021 Brice Waegeneire <brice@waegenei.re>
|
||||
;;; Copyright © 2021 qblade <qblade@protonmail.com>
|
||||
;;; Copyright © 2021 Hui Lu <luhuins@163.com>
|
||||
;;; Copyright © 2021, 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
|
||||
;;; Copyright © 2021, 2022, 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
|
||||
;;; Copyright © 2021 muradm <mail@muradm.net>
|
||||
;;; Copyright © 2022 Guillaume Le Vaillant <glv@posteo.net>
|
||||
;;; Copyright © 2022 Justin Veilleux <terramorpha@cock.li>
|
||||
@ -1532,10 +1532,16 @@ Service Switch}, for an example."
|
||||
(config-file syslog-configuration-config-file
|
||||
(default %default-syslog.conf)))
|
||||
|
||||
(define syslog-service-type
|
||||
(shepherd-service-type
|
||||
'syslog
|
||||
(lambda (config)
|
||||
;;; Note: a static file name is used for syslog.conf so that the reload action
|
||||
;;; work as intended.
|
||||
(define syslog.conf "/etc/syslog.conf")
|
||||
|
||||
(define (syslog-etc configuration)
|
||||
(match-record configuration <syslog-configuration>
|
||||
(config-file)
|
||||
(list `(,(basename syslog.conf) ,config-file))))
|
||||
|
||||
(define (syslog-shepherd-service config)
|
||||
(define config-file
|
||||
(syslog-configuration-config-file config))
|
||||
|
||||
@ -1543,10 +1549,10 @@ Service Switch}, for an example."
|
||||
(documentation "Run the syslog daemon (syslogd).")
|
||||
(provision '(syslogd))
|
||||
(requirement '(user-processes))
|
||||
(actions (list (shepherd-configuration-action config-file)))
|
||||
(actions (list (shepherd-configuration-action syslog.conf)))
|
||||
(start #~(let ((spawn (make-forkexec-constructor
|
||||
(list #$(syslog-configuration-syslogd config)
|
||||
"--rcfile" #$config-file)
|
||||
#$(string-append "--rcfile=" syslog.conf))
|
||||
#:pid-file "/var/run/syslog.pid")))
|
||||
(lambda ()
|
||||
;; Set the umask such that file permissions are #o640.
|
||||
@ -1555,7 +1561,14 @@ Service Switch}, for an example."
|
||||
(umask mask)
|
||||
pid))))
|
||||
(stop #~(make-kill-destructor))))
|
||||
(syslog-configuration)
|
||||
|
||||
(define syslog-service-type
|
||||
(service-type
|
||||
(name 'syslog)
|
||||
(default-value (syslog-configuration))
|
||||
(extensions (list (service-extension shepherd-root-service-type
|
||||
(compose list syslog-shepherd-service))
|
||||
(service-extension etc-service-type syslog-etc)))
|
||||
(description "Run the syslog daemon, @command{syslogd}, which is
|
||||
responsible for logging system messages.")))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user