From 170580827eae85cd6fb5e0b7e3947066780c8994 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Wed, 6 Jul 2022 01:04:16 +0530 Subject: bin: Look for a default config file. * bin/tissue (%default-config-file): New variable. (default-configuration): Read default config file if it exists. --- bin/tissue | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/bin/tissue b/bin/tissue index 7b2c154..e047929 100755 --- a/bin/tissue +++ b/bin/tissue @@ -215,20 +215,26 @@ Export the repository as a website to OUTPUT-DIRECTORY. (string->number (substring listen (1+ (string-index-right listen #\:)))))))) +(define %default-config-file + "/etc/tissue.conf") + (define (default-configuration) "Return the default configuration options for the `tissue pull' and `tissue run-web' subcommands." - `((listen . "127.0.0.1:8080") - (state-directory . "/var/lib/tissue") - ;; Assume current repository as default. If there is no current - ;; repository, do not configure any hosts. - (hosts . ,(guard (c ((let ((git-error (condition-git-error c))) - (and git-error - (= (git-error-code git-error) - GIT_ENOTFOUND))) - '())) - `(("localhost" - (upstream-repository . ,(git-top-level)))))))) + (if (file-exists? %default-config-file) + (call-with-input-file %default-config-file + read) + `((listen . "127.0.0.1:8080") + (state-directory . "/var/lib/tissue") + ;; Assume current repository as default. If there is no current + ;; repository, do not configure any hosts. + (hosts . ,(guard (c ((let ((git-error (condition-git-error c))) + (and git-error + (= (git-error-code git-error) + GIT_ENOTFOUND))) + '())) + `(("localhost" + (upstream-repository . ,(git-top-level))))))))) (define tissue-run-web (match-lambda* -- cgit v1.2.3