From e3d4b10253cf39abf66198a2c0bc5b843f47380f Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Mon, 7 Jun 2021 10:59:36 -0700 Subject: add PERIODIC:AT-MOST Signed-off-by: Sean Whitton --- src/connection.lisp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/connection.lisp') 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* -- cgit v1.2.3