diff options
author | Franz Geffke <franz@pantherx.org> | 2023-11-06 20:08:14 +0000 |
---|---|---|
committer | Franz Geffke <franz@pantherx.org> | 2023-11-06 20:08:14 +0000 |
commit | 47b4c9c854915df93893dbaa993accfacf9027fe (patch) | |
tree | 4f9b1742d63fcfbc94cc6b8d84f76c4d00c3a0b7 /px/services/log.scm | |
parent | 0b426d7b7ed8e176bf464ef9e0683f74a6c9d20f (diff) |
rewrite: apply guix-reference formatting; cleanup some module imports
Diffstat (limited to 'px/services/log.scm')
-rw-r--r-- | px/services/log.scm | 156 |
1 files changed, 83 insertions, 73 deletions
diff --git a/px/services/log.scm b/px/services/log.scm index f8f2bc2..cf0475a 100644 --- a/px/services/log.scm +++ b/px/services/log.scm @@ -7,7 +7,7 @@ #:use-module (gnu packages logging) #:use-module (gnu packages screen) #:use-module (gnu services shepherd) - #:use-module (px packages log) + #:use-module (px packages log) #:use-module (gnu system) #:use-module (gnu system shadow) #:use-module (guix gexp) @@ -15,9 +15,8 @@ #:use-module (ice-9 match) #:use-module (ice-9 pretty-print) - #:export (remote-syslog-service-configuration + #:export (remote-syslog-service-configuration remote-syslog-service-type - %rsyslog-default-config %rsyslog-default-config-file rsyslog-configuration @@ -27,59 +26,74 @@ ;; remote-syslog SERVICE ;; -(define (script-builder destionation-host destionation-port hostname log-files package) +(define (script-builder destionation-host destionation-port hostname log-files + package) "Return the chorny configuration file corresponding to CONFIG." (computed-file "remote-syslog-script.sh" - (with-imported-modules - '((guix build utils)) - #~(begin - (use-modules (guix build utils)) - (call-with-output-file #$output - (lambda (port) - (format port "#!~a~% exec ~a \"$@\"~%" - #+(file-append bash "/bin/sh") - (string-append #$package "/bin/remote_syslog2" - " --no-detach" - " -d " #$destionation-host - " -p " #$destionation-port - " --pid-file=/var/run/remote_syslog.pid" - " --hostname " #$hostname - " " #$log-files)) - (chmod port #o555))))))) + (with-imported-modules '((guix build utils)) + #~(begin + (use-modules (guix build utils)) + (call-with-output-file #$output + (lambda (port) + (format port + "#!~a~% exec ~a \"$@\"~%" + #+(file-append bash "/bin/sh") + (string-append #$package + "/bin/remote_syslog2" + " --no-detach" + " -d " + #$destionation-host + " -p " + #$destionation-port + " --pid-file=/var/run/remote_syslog.pid" + " --hostname " + #$hostname + " " + #$log-files)) + (chmod port #o555))))))) (define-record-type* <remote-syslog-service-configuration> - remote-syslog-service-configuration make-remote-syslog-service-configuration + remote-syslog-service-configuration + make-remote-syslog-service-configuration remote-syslog-service-configuration? - (destionation-host remote-syslog-service-configuration-destionation-host - (default "logs.papertrailapp.com")) - (destionation-port remote-syslog-service-configuration-destionation-port - (default "46169")) - (hostname remote-syslog-service-configuration-host - (default "$(hostname)")) - (log-files remote-syslog-service-configuration-log-files - (default "/var/log/messages")) - (package remote-syslog-service-configuration-package - (default remote_syslog2))) + (destionation-host remote-syslog-service-configuration-destionation-host + (default "logs.papertrailapp.com")) + (destionation-port remote-syslog-service-configuration-destionation-port + (default "46169")) + (hostname remote-syslog-service-configuration-host + (default "$(hostname)")) + (log-files remote-syslog-service-configuration-log-files + (default "/var/log/messages")) + (package + remote-syslog-service-configuration-package + (default remote_syslog2))) (define remote-syslog-shepherd-service (match-lambda - (($ <remote-syslog-service-configuration> destionation-host destionation-port hostname log-files package) - (list (shepherd-service - (provision '(remote-syslog)) - (documentation "Run remote-syslog as a daemon") - (requirement '(networking syslogd)) - (start #~(make-forkexec-constructor - (list #$(script-builder destionation-host destionation-port hostname log-files package)))) - (stop #~(make-kill-destructor))))))) + (($ <remote-syslog-service-configuration> + destionation-host + destionation-port + hostname + log-files + package) + (list (shepherd-service (provision '(remote-syslog)) + (documentation "Run remote-syslog as a daemon") + (requirement '(networking syslogd)) + (start #~(make-forkexec-constructor (list #$(script-builder + destionation-host + destionation-port + hostname + log-files + package)))) + (stop #~(make-kill-destructor))))))) (define remote-syslog-service-type - (service-type - (name "remote-syslog") - (description "Remote syslog service") - (extensions (list (service-extension shepherd-root-service-type - remote-syslog-shepherd-service))) - (default-value (remote-syslog-service-configuration)))) - + (service-type (name "remote-syslog") + (description "Remote syslog service") + (extensions (list (service-extension + shepherd-root-service-type + remote-syslog-shepherd-service))) + (default-value (remote-syslog-service-configuration)))) ;; ;; rsyslog-service-type @@ -104,20 +118,18 @@ $ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat *.* /var/log/rsyslog ") - (define %rsyslog-default-config-file (plain-file "rsyslog.conf" %rsyslog-default-config)) - -(define-record-type* <rsyslog-configuration> - rsyslog-configuration make-rsyslog-cofiguration +(define-record-type* <rsyslog-configuration> rsyslog-configuration + make-rsyslog-cofiguration rsyslog-configuration? - (package rsyslog-configuration-package - (default rsyslog)) + (package + rsyslog-configuration-package + (default rsyslog)) (config-file rsyslog-configuration-config-file (default %rsyslog-default-config-file))) - (define (rsyslog-activation config) (with-imported-modules '((guix build utils)) #~(begin @@ -125,28 +137,26 @@ $ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat (let ((lib-dir "/var/lib/rsyslog")) (mkdir-p lib-dir))))) - (define rsyslog-shepherd-service (match-lambda (($ <rsyslog-configuration> package config-file) - (list - (shepherd-service - (provision '(rsyslogd)) - (documentation "Rsyslog daemon service") - (requirement '(syslogd)) - (start #~(make-forkexec-constructor - (list #$(file-append package "/sbin/rsyslogd") - "-n" "-f" #$config-file))) - (stop #~(make-kill-destructor))))))) - + (list (shepherd-service (provision '(rsyslogd)) + (documentation "Rsyslog daemon service") + (requirement '(syslogd)) + (start #~(make-forkexec-constructor (list #$(file-append + package + "/sbin/rsyslogd") + "-n" + "-f" + #$config-file))) + (stop #~(make-kill-destructor))))))) (define rsyslog-service-type - (service-type - (name 'rsyslog) - (description "Run rsyslog daemon on machine") - (extensions - (list (service-extension shepherd-root-service-type - rsyslog-shepherd-service) - (service-extension activation-service-type - rsyslog-activation))) - (default-value (rsyslog-configuration)))) + (service-type (name 'rsyslog) + (description "Run rsyslog daemon on machine") + (extensions (list (service-extension + shepherd-root-service-type + rsyslog-shepherd-service) + (service-extension activation-service-type + rsyslog-activation))) + (default-value (rsyslog-configuration)))) |