Load the configuration actually.
This commit is contained in:
parent
c53ceb1358
commit
a0058ce35f
2 changed files with 30 additions and 2 deletions
|
@ -31,20 +31,25 @@
|
|||
*current-month*
|
||||
|
||||
*member-suspend-max-months*
|
||||
|
||||
|
||||
*etc-hackerbase*
|
||||
|
||||
*members-directory*
|
||||
*apikeys-file*
|
||||
*jendasap-checked*
|
||||
*bank-dir*
|
||||
|
||||
load-configuration!
|
||||
)
|
||||
|
||||
(import scheme
|
||||
(chicken base)
|
||||
(chicken time)
|
||||
(chicken time posix)
|
||||
month)
|
||||
(chicken file)
|
||||
(chicken io)
|
||||
month
|
||||
util-parser)
|
||||
|
||||
;; Current month - if changed, we get the actual state for given month.
|
||||
(define *current-month*
|
||||
|
@ -56,6 +61,9 @@
|
|||
;; How long the member can be suspended without any action required?
|
||||
(define *member-suspend-max-months* (make-parameter 24))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Initial configuration from *etc-hackerbase*
|
||||
|
||||
;; Where to load initial configuration from
|
||||
(define *etc-hackerbase* (make-parameter "/etc/hackerbase"))
|
||||
|
||||
|
@ -71,4 +79,23 @@
|
|||
;; Where are the bank CSV files
|
||||
(define *bank-dir* (make-parameter #f))
|
||||
|
||||
;; 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*)))))
|
||||
(when (not (null? lines))
|
||||
(let* ((line (car lines))
|
||||
(kv (parser-parse-line
|
||||
(parser-preprocess-line line))))
|
||||
(when (pair? kv)
|
||||
(let ((k (car kv))
|
||||
(v (cdr kv)))
|
||||
(case k
|
||||
((members-directory) (*members-directory* v))
|
||||
((apikeys-file) (*apikeys-file* v))
|
||||
((jendasap-checked) (*jendasap-checked* v))
|
||||
((bank-dir) (*bank-dir* v)))))
|
||||
(loop (cdr lines)))))))
|
||||
|
||||
)
|
||||
|
|
|
@ -164,6 +164,7 @@
|
|||
)
|
||||
|
||||
;; Load default configuration
|
||||
(load-configuration!)
|
||||
|
||||
;; Override from command-line
|
||||
(when (=members-directory=)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue