]> zdv2.bktei.com Git - BK-2020-03.git/commitdiff
feat(user/bkotsgu):Add script to update OpenTimestamp files
authorSteven Baltakatei Sandoval <baltakatei@gmail.com>
Mon, 1 Jun 2026 22:37:20 +0000 (22:37 +0000)
committerSteven Baltakatei Sandoval <baltakatei@gmail.com>
Mon, 1 Jun 2026 22:37:20 +0000 (22:37 +0000)
prvt
user/bkotsgu [new file with mode: 0755]

diff --git a/prvt b/prvt
index 5d30a14c7710d2cacde755e16eead6be5079d999..981e3b23ed633b7c093b06947304e3b0b46e3183 160000 (submodule)
--- a/prvt
+++ b/prvt
@@ -1 +1 @@
-Subproject commit 5d30a14c7710d2cacde755e16eead6be5079d999
+Subproject commit 981e3b23ed633b7c093b06947304e3b0b46e3183
diff --git a/user/bkotsgu b/user/bkotsgu
new file mode 100755 (executable)
index 0000000..348ed67
--- /dev/null
@@ -0,0 +1,33 @@
+#!/bin/bash
+# Desc: Updates all ots files in $HOME and /mnt/ directories recursively.
+# Depends: bash 5.1.16, GNU Findutils 4.8.0, GNU Coreutils 8.32
+# Version: 0.1.3
+# Depends: GNU Coreutils (nproc)
+
+main() {
+    # Specify find targets
+    declare -a find_targets;
+    
+    ## User home directory
+    find_targets+=("$HOME");
+    
+    ## Subdirectories of /mnt/
+    mapfile -t -O "${#find_targets[@]}" find_targets < <(find /mnt/ -mindepth 1 -maxdepth 1 -type d; );
+
+    # Specify options
+    find_depth=12;                     # find directory depth
+    cpu_count="$(nproc)";              # get logical CPU count
+    batch_size_xargs=100;              # xargs batch size
+    cpu_duty="$((cpu_count / 4 + 1))"; # logical CPU cores to use
+    
+    # Remove OTS backup files
+    find "${find_targets[@]}" -maxdepth "$find_depth" -type f -name "*.ots.bak" -exec rm '{}' \; 2>/dev/random;
+
+    # Upgrade OTS files
+    find "${find_targets[@]}" -maxdepth "$find_depth" -type f -name "*.ots" -print0 2>/dev/random | \
+        sort -uz | \
+        shuf -z | \
+        xargs -0 -n "$batch_size_xargs" -P "$cpu_duty" ots u;
+}; # main program
+
+time { main "$@"; };