Files
blackbox/bin/blackbox_shred_all_files
Tyler Akins 6de7cd99cb Always setting BLACKBOX_HOME
This makes the beginning of all files the same and a little simpler.

`${0%/*}` turns "/home/user/repository/bin/blackbox_edit" into
"/home/user/repository/bin", exactly like basename but without eating a
process.

Because other scripts needed `$blackbox_home` I made this into a
standardard variable that's always available.

This also loads _stack_lib.sh always because _blackbox_common.sh
requires it.
2015-06-16 13:25:55 -05:00

34 lines
1.0 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# blackbox_shred_all_files -- shred all decrypted versions of encrypted files
#
# Shred: To securely delete a file.
#
# Typical uses:
# After running blackbox_edit_start, deciding not to edit the file.
# A developer that wants to securely clean up a workspace before deleting it.
# An automated process that doesn't want to leave
# plaintext (unencrypted) files laying around.
#
# NOTE: The output lists files that were decrypted and are being
# shredded. For example, if you have many encrypted files but none
# have been decrypted for editing, you will see an empty list.
set -e
source "${0%/*}/_blackbox_common.sh"
change_to_vcs_root
echo '========== FILES BEING SHREDDED:'
while IFS= read <&99 -r unencrypted_file; do
unencrypted_file=$(get_unencrypted_filename "$unencrypted_file")
encrypted_file=$(get_encrypted_filename "$unencrypted_file")
if [[ -f "$unencrypted_file" ]]; then
echo " $unencrypted_file"
shred_file "$unencrypted_file"
fi
done 99<"$BB_FILES"
echo '========== DONE.'