github.com/StackExchange/blackbox/v2@v2.0.1-0.20220331193400-d84e904973ab/bin/blackbox_deregister_file (about)

     1  #!/usr/bin/env bash
     2  
     3  #
     4  # blackbox_deregister_file -- Remove a file from the blackbox system.
     5  #
     6  # Takes an encrypted file and removes it from the blackbox system.
     7  # The encrypted file will also be removed from the filesystem.
     8  # The unencrypted file, if it exists, will be left alone.
     9  
    10  set -e
    11  source "${0%/*}/_blackbox_common.sh"
    12  
    13  unencrypted_file=$(get_unencrypted_filename "$1")
    14  encrypted_file=$(get_encrypted_filename "$1")
    15  
    16  if [[ "$1" == "$unencrypted_file" ]]; then
    17    echo ERROR: Please only deregister encrypted files.
    18    exit 1
    19  fi
    20  
    21  echo ========== PLAINFILE "$unencrypted_file"
    22  echo ========== ENCRYPTED "$encrypted_file"
    23  
    24  fail_if_not_exists "$encrypted_file" "Please specify an existing file."
    25  
    26  prepare_keychain
    27  remove_filename_from_cryptlist "$unencrypted_file"
    28  vcs_remove "$encrypted_file"
    29  vcs_notice "$unencrypted_file"
    30  vcs_add "$BB_FILES" 
    31  
    32  vcs_commit "Removing from blackbox: ${unencrypted_file}" "$BB_FILES" "$encrypted_file" "$(vcs_ignore_file_path)"
    33  echo "========== UPDATING VCS: DONE"
    34  echo "Local repo updated.  Please push when ready."
    35  echo "    $VCS_TYPE push"