#!/bin/bash # set -euo pipefail # we tolerate no failure :pensive: 😔 # nullglobyyyy so da FUCKIN wildcard STOPS BEING A FUCK shopt -s nullglob # add da current dir name, and timedate stamp to it plus sum middleshit idk default_file_name="$(date +%Y-%m-%d-%H%M-%Z)_$(printf '%s\n' ${PWD##*/})_ChecksumsSHA256.sha256" existing_sha256_files=(*.sha256) # just for spooky :3 ## sumtin spookie :3 # if sha256 files exist, handle if [ ${#existing_sha256_files[@]} -gt 0 ]; then # existing sha256 files fond echo "Existing *.sha256 files found in $PWD, Checking the Latest $default_file_name" for file in *.sha256; do # on fnding sha256 files in pwd, generate shas56 checks of each one, notify OK! on success, delete the offending sha256 file if fail [ -f "$file" ] && sha256sum -c $file && echo -e "$file Check: \033[0;32mOK!\033[0m\n" || (echo -e "\n$file NO MATCH! Deleting Bad File \033[31mFAIL\033[0m\n\n"; rm -f $file) # 2>/dev/null) done # validate the found checksums sha256sum -c *.sha256 | tee -a "$default_file_name" && echo -e "\nAll Checksums: \033[0;32mOK!\033[0m\n" || echo -e "\nOne or More Checksums Failed to Match: \033[33mWARN ($?)\033[0m\n" else # no sha256 files, run generate echo "NO Existing *.sha256 files found! Generating sha256 checksums recursively" # recursive search in current working dir, find "$PWD" -type f -exec bash -c "sha256sum {} | tee -a \"$PWD/$default_file_name\"" \; && echo -e "\nAll Checksums Created: \033[0;32mOK!\033[0m\n\tLog File: $default_file_name\n" || echo -e "\nOne or More Cecksums Failed to Run: \033[31mWARN ($?)\033[0m\n" fi