X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2020-03.git/blobdiff_plain/21beb7be61fdf90ea0df0a542c5f29f70a4a2434..6a6e2a33966e7e2d4f52fe0f9d03939dc183fc71:/user/bkots diff --git a/user/bkots b/user/bkots index ec371f6..8d6ecde 100755 --- a/user/bkots +++ b/user/bkots @@ -1,8 +1,13 @@ #!/usr/bin/env bash +# Desc: Recursively timestamp files with OpenTimestamp +# Usage: bkots [PATH] +# Version: 0.2.0 # Define variables declare -g max_job_count="2"; # default max job count declare -g age_threshold="60"; # min age to add file; seconds; +declare -g stamp_throttle="0.1"; # seconds delay between stamps +declare -g stamp_throttle_fail="1"; # seconds delay if stamp errors declare -Ag appRollCall # Associative array for storing app status declare -Ag fileRollCall # Associative array for storing file status declare -Ag dirRollCall # Associative array for storing dir status @@ -200,7 +205,7 @@ showVersion() { vbm "DEBUG:showVersion function called." cat <<'EOF' -bkots 2.1.0 +bkots 2.1.1 Copyright (C) 2022 Steven Baltakatei Sandoval License GPLv3: GNU GPL version 3 This is free software; you are free to change and redistribute it. @@ -674,7 +679,7 @@ main() { path_prf="$(cut -d $'\n' -f1 < <(echo "$item"))"; if [[ -z "$path_prf" ]]; then yell "ERROR:blank upgrade item encountered. Skipping:item:$item"; - continue; + return 1; # would have been `continue` were it not in a subshell fi; vbm "DEBUG:Attempting to upgrade proof file:path_prf:$path_prf"; if [[ ! $option_dry_run == "true" ]]; then @@ -684,7 +689,7 @@ main() { #### assemble command local -a cmd_temp; - cmd_temp+=("ots"); + cmd_temp=("ots"); if [[ "$opVerbose" = "true" ]]; then cmd_temp+=("-v"); fi; cmd_temp+=("-l" "$url" "--no-default-whitelist"); cmd_temp+=("upgrade" "$path_prf"); @@ -709,7 +714,7 @@ main() { path_prf="$(cut -d $'\n' -f2 < <(echo "$item"))"; if [[ -z "$path_src" ]] || [[ -z "$path_prf" ]]; then yell "ERROR:blank verify item encountered. Skipping:item:$item"; - continue; + return 1; # would have been `continue` were it not in a subshell fi; vbm "DEBUG:Attempting to verify source file:path_src:$path_src"; vbm "DEBUG: against proof file: path_prf:$path_prf"; @@ -720,7 +725,7 @@ main() { #### assemble command local -a cmd_temp; - cmd_temp+=("ots"); + cmd_temp=("ots"); if [[ "$opVerbose" = "true" ]]; then cmd_temp+=("-v"); fi; cmd_temp+=("-l" "$url" "--no-default-whitelist"); cmd_temp+=("verify" "-f" "$path_src" "$path_prf"); @@ -744,20 +749,26 @@ main() { path_src="$(cut -d $'\n' -f1 < <(echo "$item"))"; if [[ -z "$path_src" ]]; then yell "ERROR:blank stamp item encountered. Skipping:item:$item"; - continue; + return 1; # would have been `continue` were it not in a subshell fi; vbm "DEBUG:Attempting to stamp source file:path_src:$path_src"; if [[ ! $option_dry_run == "true" ]]; then #### assemble command local -a cmd_temp; - cmd_temp+=("ots"); + cmd_temp=("ots"); if [[ "$opVerbose" = "true" ]]; then cmd_temp+=("-v"); fi; cmd_temp+=("stamp" "$path_src"); if [[ "$opVerbose" = "true" ]]; then declare -p cmd_temp; fi; #### execute command - "${cmd_temp[@]}"; + if "${cmd_temp[@]}"; then + sleep "$stamp_throttle" || die "FATAL:Invalid stamp throttle."; + else + yell "ERROR:Could not stamp file with command:$(declare -p cmd_temp)"; + sleep "$stamp_throttle_fail" || die "FATAL:Invalid stamp throttle."; + fi; + unset cmd_temp; #ots stamp "$path_src"; else