diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2021-06-07 10:59:36 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-06-07 16:09:36 -0700 |
commit | e3d4b10253cf39abf66198a2c0bc5b843f47380f (patch) | |
tree | 36c2c566d76de77229d1e52a1e17c39f3debd998 /src/connection.lisp | |
parent | bdaf6ae42672f4de739002f51b1add178e53aed6 (diff) | |
download | consfigurator-e3d4b10253cf39abf66198a2c0bc5b843f47380f.tar.gz |
add PERIODIC:AT-MOST
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src/connection.lisp')
-rw-r--r-- | src/connection.lisp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/connection.lisp b/src/connection.lisp index fc4575f..1920bda 100644 --- a/src/connection.lisp +++ b/src/connection.lisp @@ -500,6 +500,25 @@ specification of POSIX ls(1))." (encode-universal-time 0 0 0 date month (parse-integer (nth 7 ls)) 0)))))))) +(defun remote-last-reboot () + "Get the time of the last reboot, rounded down to the nearest minute." + ;; The '-b' option to who(1) is specified in POSIX, though not the output + ;; format; this parse is based on GNU coreutils who(1). + (multiple-value-bind (match groups) + (re:scan-to-strings + "([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2}):([0-9]{2})" + (car (runlines :env '(:TZ "UTC") "who" "-b"))) + (if match + (let ((groups (map 'vector #'parse-integer groups))) + (encode-universal-time 0 (elt groups 4) (elt groups 3) + (elt groups 2) (elt groups 1) (elt groups 0) + 0)) + (failed-change "Could not determine time of remote's last reboot.")))) + +(defun remote-consfigurator-cache-pathname (path) + (merge-pathnames + path (car (runlines "echo ${XDG_CACHE_HOME:-$HOME/.cache}/consfigurator/")))) + (defun readfile (path) (connection-readfile *connection* |