Disable home impermanence

This commit is contained in:
Madeleine Sydney
2024-12-21 09:49:20 -07:00
parent 684e78e936
commit be5341b5b1
12 changed files with 594 additions and 262 deletions

View File

@@ -1,17 +1,19 @@
#!/usr/bin/env bb
;;; TODO: rewrite with fewer assumptions about the filesystem structure.
;; TODO: rewrite with fewer assumptions about the filesystem structure. Perhaps
;; we can achieve near-atomicity by doing to bulk of the work with a function
;; `erase-home-darlings : FileSystem -> Maybe FileSystem`, which will not do any
;; IO.
;;; TODO: option to either move OR copy
;; TODO: option to either move OR copy
(require '[clojure.core.match :refer [match]]
'[babashka.cli :as cli]
'[clojure.pprint :as pp]
'[clojure.tools.logging :as l]
'[babashka.process :refer [shell check process] :as p])
(defn get-files [{:keys [rollback-to dataset]}]
;; (prn rollback-to)
;; (prn dataset)
(let [snapshot (str dataset "@" rollback-to)
diff (:out (shell {:out :string}
"zfs diff -HF"
@@ -139,9 +141,27 @@ More precisely,
(defn -main [opts]
(pp/pprint opts)
(with-echoed-shell-commands
(shell "mount" (:dataset opts) "/home")
(let [files (get-files opts)]
(archive-files opts files)
(cycle-archives opts)
(do-rollback opts))))
#_
(def fs-ops
{:zfs {:get-files zfs-get-files
:rollback zfs-rollback}})
#_
(defn -main [opts]
(let [test-bin (fn [x]
(printf "%s: %s\n"
x (map str (fs/which-all x))))]
(test-bin "mount")
(test-bin "findmnt")
(test-bin "zfs"))
(shell "mount")
(shell "ls -la /home"))
(-main (cli/parse-opts *command-line-args* cli-spec))