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.
35 lines
970 B
Bash
Executable File
35 lines
970 B
Bash
Executable File
#!/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
|
|
source "${0%/*}/_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"
|
|
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"
|