Files
blackbox/bin/blackbox_edit_end
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

27 lines
733 B
Bash
Executable File

#!/usr/bin/env bash
#
# blackbox_edit_end -- Re-encrypt file after edits.
#
set -e
source "${0%/*}/_blackbox_common.sh"
unencrypted_file=$(get_unencrypted_filename "$1")
encrypted_file=$(get_encrypted_filename "$1")
echo ========== PLAINFILE '"'$unencrypted_file'"'
echo ========== ENCRYPTED '"'$encrypted_file'"'
fail_if_not_on_cryptlist "$unencrypted_file"
fail_if_not_exists "$unencrypted_file" "No unencrypted version to encrypt!"
fail_if_keychain_has_secrets
encrypt_file "$unencrypted_file" "$encrypted_file"
shred_file "$unencrypted_file"
_determine_vcs_base_and_type
echo ========== UPDATED '"'$encrypted_file'"'
echo "Likely next step:"
echo " $VCS_TYPE commit -m\"${encrypted_file} updated\" \"$encrypted_file\""