Adding file deregister tool + extrapolating code

This solves some TODOs by moving shared code out into
`_blackbox_common.sh`.

New VCS commands were added, `vcs_ignore` and `vcs_notice` (the
opposite of ignore).

Made some utility functions

* `remove_filename_from_cryptlist` - The opposite of `add_file_to_cryptlist`
* `remove_line` - Removes a single line from a text file
This commit is contained in:
Tyler Akins
2015-06-12 13:23:45 -05:00
parent 501c09ccd5
commit 01e681035d
5 changed files with 157 additions and 43 deletions

36
bin/blackbox_deregister_file Executable file
View File

@@ -0,0 +1,36 @@
#!/usr/bin/env bash
#
# blackbox_deregister_file -- Remove a file from the blackbox system.
#
# Takes an encrypted file and removes it from the blackbox system. The
# encrypted file will also be removed from the filesystem.
set -e
blackbox_home=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
source "${blackbox_home}/_blackbox_common.sh"
_determine_vcs_base_and_type
unencrypted_file=$(get_unencrypted_filename "$1")
encrypted_file=$(get_encrypted_filename "$1")
if [[ "$1" == "$unencrypted_file" ]]; then
echo ERROR: Please only deregister encrypted files.
exit 1
fi
echo ========== PLAINFILE "$unencrypted_file"
echo ========== ENCRYPTED "$encrypted_file"
fail_if_not_exists "$encrypted_file" "Please specify an existing file."
prepare_keychain
remove_filename_from_cryptlist "$unencrypted_file"
vcs_notice "$unencrypted_file"
git rm "$encrypted_file"
vcs_remove "$BB_FILES"
vcs_commit "Removing from blackbox: ${unencrypted_file}"
echo "========== UPDATING VCS: DONE"
echo "Local repo updated. Please push when ready."
echo " $(which_vcs) push"