Files
blackbox/bin/blackbox_postdeploy

40 lines
1020 B
Plaintext
Raw Normal View History

#!/usr/bin/env bash
2014-07-07 20:30:16 -04:00
#
# blackbox_postdeploy.sh -- Decrypt all blackbox files.
#
# Usage:
# blackbox_postdeploy.sh [GROUP]
# GROUP is optional. If supplied, the resulting files
# are chgrp'ed to that group.
# 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
blackbox_home=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
2015-02-27 01:01:48 +07:00
source "${blackbox_home}/_blackbox_common.sh"
2014-07-07 20:30:16 -04:00
if [[ "$1" == "" ]]; then
FILE_GROUP=""
else
FILE_GROUP="$1"
fi
change_to_root
2014-07-07 20:30:16 -04:00
prepare_keychain
# Decrypt:
echo '========== Decrypting new/changed files: START'
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"
chmod g+r "$unencrypted_file"
if [[ ! -z "$FILE_GROUP" ]]; then
2015-02-27 01:01:48 +07:00
chgrp "$FILE_GROUP" "$unencrypted_file"
fi
done 99<"$BB_FILES"
2014-07-07 20:30:16 -04:00
echo '========== Decrypting new/changed files: DONE'