diff options
author | Maxim Cournoyer <maxim.cournoyer@gmail.com> | 2023-04-12 19:55:44 -0400 |
---|---|---|
committer | Maxim Cournoyer <maxim.cournoyer@gmail.com> | 2023-04-21 09:04:39 -0400 |
commit | 1ae279d7c8a4962fedcb3479e551d21991d0ac4a (patch) | |
tree | bbeeed1f5e971f1954aced1f042f65d8c9e388ec /gnu/services | |
parent | 184658e282d5e16beb4e30440afffd7f9b392021 (diff) | |
download | guix-1ae279d7c8a4962fedcb3479e551d21991d0ac4a.tar.gz guix-1ae279d7c8a4962fedcb3479e551d21991d0ac4a.zip |
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.
Diffstat (limited to 'gnu/services')
-rw-r--r-- | gnu/services/base.scm | 61 |
1 files changed, 37 insertions, 24 deletions
diff --git a/gnu/services/base.scm b/gnu/services/base.scm index dfc7571e55..3b0784ef07 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -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,30 +1532,43 @@ 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) - (define config-file - (syslog-configuration-config-file 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") - (shepherd-service - (documentation "Run the syslog daemon (syslogd).") - (provision '(syslogd)) - (requirement '(user-processes)) - (actions (list (shepherd-configuration-action config-file))) - (start #~(let ((spawn (make-forkexec-constructor - (list #$(syslog-configuration-syslogd config) - "--rcfile" #$config-file) - #:pid-file "/var/run/syslog.pid"))) - (lambda () - ;; Set the umask such that file permissions are #o640. - (let ((mask (umask #o137)) - (pid (spawn))) - (umask mask) - pid)))) - (stop #~(make-kill-destructor)))) - (syslog-configuration) +(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)) + + (shepherd-service + (documentation "Run the syslog daemon (syslogd).") + (provision '(syslogd)) + (requirement '(user-processes)) + (actions (list (shepherd-configuration-action syslog.conf))) + (start #~(let ((spawn (make-forkexec-constructor + (list #$(syslog-configuration-syslogd config) + #$(string-append "--rcfile=" syslog.conf)) + #:pid-file "/var/run/syslog.pid"))) + (lambda () + ;; Set the umask such that file permissions are #o640. + (let ((mask (umask #o137)) + (pid (spawn))) + (umask mask) + pid)))) + (stop #~(make-kill-destructor)))) + +(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."))) |