aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2023-09-02 19:04:12 +0200
committerWojtek Kosior <koszko@koszko.org>2023-09-02 19:04:12 +0200
commite26a4699014ac5be67703dc748717f6e34b522f8 (patch)
treef8469fb209cf372b9ef53e5a96ac79a06f0cac6f
parentc4644ad9eb16c5b62a9b3042a07c89c866f453c0 (diff)
downloadkoszko-org-server-e26a4699014ac5be67703dc748717f6e34b522f8.tar.gz
koszko-org-server-e26a4699014ac5be67703dc748717f6e34b522f8.zip
Enable logging in Knot
-rw-r--r--container.scm47
1 files changed, 46 insertions, 1 deletions
diff --git a/container.scm b/container.scm
index ea5083b..8752b9d 100644
--- a/container.scm
+++ b/container.scm
@@ -678,8 +678,53 @@ exim_path = /run/setuid-programs/exim
(semantic-checks? #t)
(notify (map car %1984-freedns-nameservers))))
+(define knot-configuration-knot
+ (@@ (gnu services dns) knot-configuration-knot))
+
+(define knot-config-file
+ (@@ (gnu services dns) knot-config-file))
+
+(define (knot-config-file-with-logging knot-config)
+ (computed-file "knot-with-logging.conf"
+ #~(with-output-to-file #$output
+ (lambda _
+ (use-modules (ice-9 textual-ports))
+ (call-with-input-file #$(knot-config-file knot-config)
+ (lambda (port)
+ (display (get-string-all port))))
+ (newline)
+ (display "\
+log:
+ - target: syslog
+")))))
+
+(define (adapt-knot-shepherd-extension ext)
+ ;; Make knot daemon log to syslog.
+ (let ((old-activation (service-extension-compute ext)))
+ (define (new-activation knot-config)
+ (let* ((knot-package (knot-configuration-knot knot-config))
+ (config-file (knot-config-file-with-logging knot-config)))
+ (map (lambda (shepherd-service-record)
+ (shepherd-service
+ (inherit shepherd-service-record)
+ (start #~(make-forkexec-constructor
+ '(#$(file-append knot-package "/sbin/knotd")
+ "-c" #$config-file)))))
+ (old-activation knot-config))))
+
+ (service-extension shepherd-root-service-type new-activation)))
+
+(define koszko-knot-service-type
+ (service-type
+ (inherit knot-service-type)
+ (extensions (map (lambda (ext)
+ (if (extension-of-type? ext shepherd-root-service-type)
+ (adapt-knot-shepherd-extension ext)
+ ext))
+ (service-type-extensions knot-service-type)))))
+
(define %koszko-knot-service
- (service knot-service-type
+ (service koszko-knot-service-type
(knot-configuration
(acls (list (knot-acl-configuration
(id "allow-axfr-from-1984")