From 7205fd9382975e59776e1d4e8e8f6a5006311f74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Pant=C5=AF=C4=8Dek?= Date: Wed, 12 Jul 2023 18:35:00 +0200 Subject: [PATCH] Improve default config loading. --- src/configuration.scm | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/configuration.scm b/src/configuration.scm index 9b03e33..48d5c12 100644 --- a/src/configuration.scm +++ b/src/configuration.scm @@ -53,7 +53,10 @@ ;; Initial configuration from *etc-hackerbase* ;; Where to load initial configuration from - (define *etc-hackerbase* (make-parameter "/etc/hackerbase")) + (define *etc-hackerbase* (make-parameter + (list "/etc/hackerbase" + ;; TODO: $HOME expansion + "/home/hackerbase/.hackerbaserc"))) ;; Needed by multiple modules actually (define *members-directory* (make-parameter #f)) @@ -82,11 +85,9 @@ (define *doku-base* (make-parameter #f)) (define =doku-base= "/var/www") - ;; Loads the configuration file and possibly changes the default - ;; parameters. - (define (load-configuration!) - (when (file-exists? (*etc-hackerbase*)) - (let loop ((lines (read-lines (open-input-file (*etc-hackerbase*))))) + (define (load-single-configuration! fname) + (when (file-exists? fname) + (let loop ((lines (read-lines (open-input-file fname)))) (when (not (null? lines)) (let* ((line (car lines)) (kv (parser-parse-line @@ -117,7 +118,18 @@ (when (not (*doku-base*)) (*doku-base* v))) ))) - (loop (cdr lines)))))) + (loop (cdr lines))))))) + + ;; Loads the configuration file and possibly changes the default + ;; parameters. + (define (load-configuration!) + (let ((fnames (*etc-hackerbase*))) + (if (string? fnames) + (load-single-configuration! fnames) + (let loop ((fnames fnames)) + (when (not (null? fnames)) + (load-single-configuration! (car fnames)) + (loop (cdr fnames)))))) (when (not (*members-directory*)) (*members-directory* =members-directory=)) (when (not (*apikeys-file*))