From: Steven Baltakatei Sandoval Date: Mon, 1 Jun 2026 22:37:20 +0000 (+0000) Subject: feat(user/bkotsgu):Add script to update OpenTimestamp files X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2020-03.git/commitdiff_plain/ef3df5c46b494872ad11cf69c8e75c046820c803?ds=inline feat(user/bkotsgu):Add script to update OpenTimestamp files --- diff --git a/prvt b/prvt index 5d30a14..981e3b2 160000 --- a/prvt +++ b/prvt @@ -1 +1 @@ -Subproject commit 5d30a14c7710d2cacde755e16eead6be5079d999 +Subproject commit 981e3b23ed633b7c093b06947304e3b0b46e3183 diff --git a/user/bkotsgu b/user/bkotsgu new file mode 100755 index 0000000..348ed67 --- /dev/null +++ b/user/bkotsgu @@ -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 "$@"; };