even bettar

This commit is contained in:
2026-05-12 04:43:25 -06:00
parent 7719c92b89
commit 8e81b4b29e
+64 -10
View File
@@ -1,8 +1,15 @@
#!/bin/bash #!/bin/bash
# usage: by its self or with nuke
# bash improved_file_management.sh
# bash improved_file_management.sh nuke
## "nuke" is not case sensitive
start_date="$(date)"
args="$@"
# backup_dir="/mnt/c/Users/human/Downloads/tint" # backup_dir="/mnt/c/Users/human/Downloads/tint"
backup_dir="/mnt/d/Anbernic_Research_Tinkering_Save" backup_dir="/mnt/d/Anbernic_Research_Tinkering_Save"
cd "$backup_dir" error_log="${backup_dir}/error.log" # errror log path
cd "$backup_dir" # slide on in
# sum text colorz # sum text colorz
RED='\033[0;31m' # anmgry red RED='\033[0;31m' # anmgry red
@@ -10,6 +17,38 @@ YELLOW='\033[0;33m' # BOLD yellow :"3
GREEN='\033[1;32m' # bold green :3 GREEN='\033[1;32m' # bold green :3
RESET='\033[0m' # reset color RESET='\033[0m' # reset color
check_error_log () {
if [ -f "$error_log" ]; then
echo -e "${GREEN}Found $error_log clearing at $(date) With $SECONDS Elapsed At Line Number $LINENO${RESET}"
echo > "$error_log" # initialize as empty
else
echo -e "${GREEN}No $error_log fiound, creating at $(date) With $SECONDS Elapsed At Line Number $LINENO${RESET}"
touch "$error_log" # create and initialize
fi
}
environment_checks () {
# tests if backup dir is a directory and available
if [ ! -d "$backup_dir" ]; then
echo -e "\n\n\n${RED}Supplied backup dir: $backup_dir not present, not available, out of permissions, or is not a directory"
exit 1
else
echo -e "${GREEN}OK! Backup Dir GOOD${RESET}"
fi
# tests current location
if [[ "$PWD" != "$backup_dir" ]]; then
echo -e "\n\n\n${RED}pwd: $PWD does not match specified dir: $backup Dir, FAIL. Exiting.${RESET}\n\n\n" # notify
exit 1 # exit with error
else
echo -e "${GREEN}OK! Backup Dir IS Current Location!${RESET}"
fi
echo -e "\n${GREEN}Environment Checks GOOD!${RESET}\n"
}
greet () { greet () {
echo -e "\n\n\n${GREEN}WELCOME TO DURABLE, PROVABLE FILE HANDLING${RESET}\n\n\n" echo -e "\n\n\n${GREEN}WELCOME TO DURABLE, PROVABLE FILE HANDLING${RESET}\n\n\n"
} }
@@ -28,7 +67,7 @@ verify_sha256_files() {
local file local file
local failed=0 local failed=0
find "${1:-.}" -type f -name '*.sha256' -print0 | find "${1:-.}" -type f -name '*.sha256' -not -path "*.git*" -print0 |
while IFS= read -r -d '' file; do while IFS= read -r -d '' file; do
echo "Checking: $file" echo "Checking: $file"
@@ -54,7 +93,7 @@ generate_sha256_checksums () {
sha256sum "$file" | tee "$file.sha256" sha256sum "$file" | tee "$file.sha256"
fi fi
done done
' bash {} + ' bash {} + # idk what this hippie bullshit voodoo witchcraft this syntax is, kill nme now
} }
do_git () { do_git () {
@@ -77,10 +116,25 @@ run_backup () {
pwsh.exe -File "D:\Anbernic-Hackin-Archive_restic_backup.ps1" # do da restic backup ps1 pwsh.exe -File "D:\Anbernic-Hackin-Archive_restic_backup.ps1" # do da restic backup ps1
} }
greet # shutdown by force of powershell huehhuehue
delete_sha256_files box_force_shutdown () {
generate_sha256_checksums webhook "TIME TO SHUT THE FUCK DOWN WOOOO\n\t$SECONDS Seconds Elapsed\n\tStart Date: $start_date\n\tEnd Date: $(date)" true # true so it pingas mneeee
verify_sha256_files
do_git # hateful cursed powershell call to shut off box ffs
run_backup pwsh.exe -C "Stop-Computer -Force" # i reeally dgaf this is so terribly fuckin cursed
when_done }
greet # welcome msg
environment_checks # test environment for working
if [[ "$args" =~ nuke ]]; then
delete_sha256_files # delete all *.sha256 files
fi
check_error_log # verify error log faggot
while $true; do # do an infinite loop to keep em all running and operating at all times :3
verify_sha256_files # check files against their sha256 checksum
generate_sha256_checksums # create the checksums from the files to generate each file its own *.sha256 buddy \o/
do_git # archive for version controll
run_backup # do multiple redndant backups using restic
done
when_done # goodbye msg