blackbox_register_new_file: Accept multiple files on the command line.
This commit is contained in:
@@ -1,16 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
#
|
||||
# blackbox_register_new_file -- Enroll a new file in the blackbox system.
|
||||
# blackbox_register_new_file -- Enroll new file(s) in the blackbox system.
|
||||
#
|
||||
# Takes a previously unencrypted file and enrolls it into the blackbox
|
||||
# system. It will be kept in the repo as an encrypted file. On deployment
|
||||
# Takes previously unencrypted file(s) and enrolls them into the blackbox
|
||||
# system. Each file will be kept in the repo as an encrypted file. On deployment
|
||||
# to systems that need the plaintext (unencrypted) versions, run
|
||||
# blackbox_postdeploy.sh to decrypt all the files.
|
||||
|
||||
set -e
|
||||
source "${0%/*}/_blackbox_common.sh"
|
||||
|
||||
function register_new_file() {
|
||||
unencrypted_file=$(get_unencrypted_filename "$1")
|
||||
encrypted_file=$(get_encrypted_filename "$1")
|
||||
|
||||
@@ -44,6 +45,12 @@ vcs_ignore "$unencrypted_file"
|
||||
echo 'NOTE: "already tracked!" messages are safe to ignore.'
|
||||
vcs_add "$BB_FILES" "$encrypted_file"
|
||||
vcs_commit "registered in blackbox: ${unencrypted_file}" "$BB_FILES" "$encrypted_file"
|
||||
}
|
||||
|
||||
for target in "$@"; do
|
||||
register_new_file "$target"
|
||||
done
|
||||
|
||||
echo "========== UPDATING VCS: DONE"
|
||||
echo "Local repo updated. Please push when ready."
|
||||
echo " $(which_vcs) push"
|
||||
|
||||
@@ -448,6 +448,17 @@ assert_line_not_exists 'mistake.txt' 'keyrings/live/blackbox-files.txt'
|
||||
assert_file_missing 'mistake.txt.gpg'
|
||||
assert_file_exists 'mistake.txt'
|
||||
|
||||
PHASE 'Bob enrolls multiple files: multi1.txt and multi2.txt'
|
||||
echo 'One singular sensation.' >'multi1.txt'
|
||||
echo 'Another singular sensation.' >'multi2.txt'
|
||||
blackbox_register_new_file 'multi1.txt' 'multi2.txt'
|
||||
assert_file_missing 'multi1.txt'
|
||||
assert_file_exists 'multi1.txt'.gpg
|
||||
assert_line_exists '/multi1.txt' .gitignore
|
||||
assert_file_missing 'multi2.txt'
|
||||
assert_file_exists 'multi2.txt'.gpg
|
||||
assert_line_exists '/multi2.txt' .gitignore
|
||||
|
||||
PHASE 'Alice returns. She should be locked out'
|
||||
assert_file_missing 'secret.txt'
|
||||
become_alice
|
||||
|
||||
Reference in New Issue
Block a user