From: Ralph Ronnquist Date: Sun, 2 Jan 2022 01:28:51 +0000 (+1100) Subject: fixes for deployment conf X-Git-Tag: 0.1~25 X-Git-Url: https://git.rrq.au/?a=commitdiff_plain;h=45a86f2b3e502e41dda26426e6e1e60ba088006f;p=rrq%2Fhourglass.git fixes for deployment conf --- diff --git a/manager/controls-update.lsp b/manager/controls-update.lsp index 7eff0b9..2085462 100644 --- a/manager/controls-update.lsp +++ b/manager/controls-update.lsp @@ -17,7 +17,6 @@ (let ((data "")(b "") (c '()) (v nil)) (while (read 0 b 1000) (extend data b)) (setf v (map (fn (x) (parse x "=")) (parse data "&"))) - (push (list 'control "ipset-control.lsp") c -1) (push (list 'gap (int-parse (lookup "gap" v))) c -1) (push (list 'clip (int-parse (lookup "clip" v))) c -1) (for (i 1 7) @@ -25,9 +24,9 @@ (mode-parse (lookup (string "mode" i) v)) (time-parse (lookup (string "start" i) v)) (time-parse (lookup (string "limit" i) v)) - (time-parse (lookup (string "end" i) v)) - ) c -1)) - (write-file "control.dat" + (time-parse (lookup (string "end" i) v)) ) + c -1)) + (write-file CONTROLFILE (append (format "; Updated at %s\n(" (date)) (join (map string c) "\n " true) ")\n")) diff --git a/manager/controls.lsp b/manager/controls.lsp index 12d3fbb..10153df 100644 --- a/manager/controls.lsp +++ b/manager/controls.lsp @@ -2,6 +2,10 @@ (load "expand-string.lsp") +(constant + 'CONTROLFILE SITE:control.dat + ) + (setf UPDATE "") (when (= (env "REQUEST_METHOD") "POST") @@ -9,19 +13,15 @@ ) (constant - 'CONTROLFILE "control.dat" 'CONTROL (read-expr (read-file CONTROLFILE)) 'GAP (or (lookup 'gap CONTROL) 5) 'CLIP (or (lookup 'clip CONTROL) 5) - 'INCL (or (lookup 'control CONTROL) "ipset-control.lsp") 'TIMES (map (fn (n) (or (assoc n CONTROL) '(1 timed (7 0) (3 0) (19 0)))) (sequence 1 7)) - 'NET (or (lookup 'net CONTROL) "10.0.0.0/8") ) (setf DAYS '(0 "Mon" "Tue" "Wed" "Thu" "Fri" "Sat" "Sun") - incl-options '("ipset-control.lsp") gap-options '(0 1 2 5 10 15 30) clip-options '(0 200 500 800 1000 1200 1500 2000) mode-options '("opened" "timed" "closed") diff --git a/manager/usage-extra.lsp b/manager/usage-extra.lsp index e0cad6a..1850723 100644 --- a/manager/usage-extra.lsp +++ b/manager/usage-extra.lsp @@ -1,7 +1,7 @@ (define (set-usage-extra m) (let ((h (/ m 60))) (setf m (- m (* h 60))) - (write-file "../control-extra.dat" (format "%d %d\n" h m)))) + (write-file EXTRAFILE (format "%d %d\n" h m)))) (catch (let ((data "")(b "") (c '()) (v nil)) diff --git a/manager/usage.lsp b/manager/usage.lsp index c5de943..3969a3e 100644 --- a/manager/usage.lsp +++ b/manager/usage.lsp @@ -1,20 +1,21 @@ (load "expand-string.lsp") +(constant + 'USAGEFILE SITE:control.usage.dat + 'EXTRAFILE SITE:control.extra.dat + ) + (when (= (env "REQUEST_METHOD") "POST") (load "usage-extra.lsp") ) -(define (get-remote-user) REMOTE_USER) - (constant - 'ADMIN (member REMOTE_USER '("ralph" "lin")) - 'USAGE (read-expr (read-file "usage.dat")) - 'extra-options '(0 10 30 60) - 'EXTRAFILE "control-extra.dat" + 'USAGE (read-expr (read-file USAGEFILE)) 'EXTRATM (file-info EXTRAFILE 6) - 'TM (date-value) 'EXTRA (and (regex "([0-9]+) ([0-9]+)" (or (read-file EXTRAFILE) "") 0) (list (int $1 0 10) (int $2 0 10))) + 'TM (date-value) + 'extra-options '(0 10 30 60) ) (define (tm2time tm)