aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--overlays/kookie/dcutil/default.nix32
1 files changed, 32 insertions, 0 deletions
diff --git a/overlays/kookie/dcutil/default.nix b/overlays/kookie/dcutil/default.nix
new file mode 100644
index 00000000000..6f8e2bb2864
--- /dev/null
+++ b/overlays/kookie/dcutil/default.nix
@@ -0,0 +1,32 @@
+/* DATACORE UTILS
+ *
+ * A tool that makes it easier to deal with decrypting
+ * and re-crypting the datacore storage pool.
+ */
+
+
+{ writeShellScriptBin, zfs }: writeShellScriptBin "dcutils" ''
+ set -eo pipefail
+
+ function open_pool {
+ ${zfs}/bin/zfs load-key datacore
+ ${zfs}/bin/zfs mount datacore
+ ${zfs}/bin/zfs mount datacore/backup
+ ${zfs}/bin/zfs mount datacore/media
+ ${zfs}/bin/zfs mount datacore/sync
+ }
+
+ function close_pool {
+ ${zfs}/bin/zfs umount datacore
+ ${zfs}/bin/zfs umount datacore/backup
+ ${zfs}/bin/zfs umount datacore/media
+ ${zfs}/bin/zfs umount datacore/sync
+ ${zfs}/bin/zfs unload-key datacore
+ }
+
+ case "$1" in
+ open*) open_pool ;;
+ close*) close_pool ;;
+ *) echo "Usage: <dcutils> [open|close]"
+ esac
+''