2014-08-29 20:21:02 +00:00
|
|
|
#!/usr/bin/env bash
|
2014-07-07 20:30:16 -04:00
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# blackbox_postdeploy.sh -- Decrypt all blackbox files.
|
|
|
|
|
#
|
|
|
|
|
|
2014-09-02 22:10:37 +00:00
|
|
|
# Usage:
|
|
|
|
|
# blackbox_postdeploy.sh [GROUP]
|
|
|
|
|
# GROUP is optional. If supplied, the resulting files
|
|
|
|
|
# are chgrp'ed to that group.
|
|
|
|
|
|
2014-08-28 20:47:32 +00:00
|
|
|
# Since this is often run in a security-critical situation, we
|
|
|
|
|
# force /usr/bin and /bin to the front of the PATH.
|
|
|
|
|
export PATH=/usr/bin:/bin:"$PATH"
|
2014-07-07 20:30:16 -04:00
|
|
|
|
2014-09-08 20:25:38 +00:00
|
|
|
set -e
|
2014-08-28 20:47:32 +00:00
|
|
|
. _blackbox_common.sh
|
2014-07-07 20:30:16 -04:00
|
|
|
|
2014-09-02 22:10:37 +00:00
|
|
|
if [[ "$1" == "" ]]; then
|
|
|
|
|
FILE_GROUP=""
|
|
|
|
|
else
|
|
|
|
|
FILE_GROUP="$1"
|
|
|
|
|
fi
|
|
|
|
|
|
2014-11-06 00:28:53 -08:00
|
|
|
change_to_root
|
2014-07-07 20:30:16 -04:00
|
|
|
prepare_keychain
|
|
|
|
|
|
|
|
|
|
# Decrypt:
|
|
|
|
|
echo '========== Decrypting new/changed files: START'
|
2014-11-05 16:47:53 +00:00
|
|
|
while IFS= read <&99 -r unencrypted_file; do
|
2014-07-07 20:30:16 -04:00
|
|
|
encrypted_file=$(get_encrypted_filename "$unencrypted_file")
|
|
|
|
|
decrypt_file_overwrite "$encrypted_file" "$unencrypted_file"
|
2014-09-23 23:44:48 -04:00
|
|
|
chmod g+r "$unencrypted_file"
|
2014-09-02 22:10:37 +00:00
|
|
|
if [[ ! -z "$FILE_GROUP" ]]; then
|
|
|
|
|
chgrp $FILE_GROUP "$unencrypted_file"
|
|
|
|
|
fi
|
2014-11-05 16:47:53 +00:00
|
|
|
done 99<"$BB_FILES"
|
2014-07-07 20:30:16 -04:00
|
|
|
echo '========== Decrypting new/changed files: DONE'
|