fixes for deployment conf
[rrq/hourglass.git] / command.lsp
1
2 # This script is intended as main script for packnl embedding, it
3 # dispatches to the command of the first argument.
4
5 (context 'MAIN:SITE)
6
7 (define (set-int K V) (set K (int V 0 10)))
8
9 (define (set-ints K V)
10   (map (curry set-int K) (clean empty? (parse V "\\s*,?\\s*" 0))))
11
12 (define (set-list K V)
13   (map (curry set K) (clean empty? (parse V "\\s*,?\\s*" 0))))
14
15 (constant
16  'FILE "hourglass.conf"
17  'KEYS '(
18          ("libc" set)
19          ("listener.ports" set-ints)
20          ("listener.ip" set)
21          ("listener.activity.dir" set)
22          ("control.action" set)
23          ("control.dat" set)
24          ("control.net" set)
25          ("control.extra.dat" set)
26          ("control.usage.dat" set)
27          ("control.usage.tmp" set)
28
29          ("wui.port" set-int)
30          ("wui.roles" set)
31          ("wui.passwd" set)
32          )
33  )
34
35 (define (setting LINE)
36   (when (regex "^\\s([^;#][^=]*)=(.*)" LINE 0)
37     (let ((KV (map trim (list $1 $2))))
38       (if (lookup (KV 0) KEYS) (apply $it (list (sym (KV 0)) (KV 1)))))))
39
40 (map setting (parse (or (read-file FILE) "") "\n"))
41
42 ####################
43 (context MAIN)
44
45 (if (exists file? (list (main-args 1)
46                         (string (main-args 1) ".lsp")))
47     (load $it)
48   (write-line 2 (string "Unknown command " (main-args 1))))
49 (exit 0)