2014-09-04 11:29:23 -03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
|
|
#
|
2015-06-02 15:37:06 +00:00
|
|
|
# blackbox_edit -- Decrypt a file temporarily for edition, then re-encrypts it again
|
2014-09-04 11:29:23 -03:00
|
|
|
#
|
2014-09-08 20:25:38 +00:00
|
|
|
set -e
|
2015-06-16 13:21:51 -05:00
|
|
|
source "${0%/*}/_blackbox_common.sh"
|
2014-09-04 11:29:23 -03:00
|
|
|
|
2015-06-12 13:27:42 -05:00
|
|
|
for param in "$@" ; do
|
2015-07-24 09:57:34 -04:00
|
|
|
|
2014-10-19 20:55:47 -07:00
|
|
|
unencrypted_file=$(get_unencrypted_filename "$param")
|
2015-07-24 09:57:34 -04:00
|
|
|
encrypted_file=$(get_encrypted_filename "$param")
|
|
|
|
|
|
|
|
|
|
echo >&2 ========== PLAINFILE '"'$unencrypted_file'"'
|
|
|
|
|
echo >&2 ========== ENCRYPTED '"'$encrypted_file'"'
|
|
|
|
|
|
|
|
|
|
if ! is_on_cryptlist "$encrypted_file" && ! is_on_cryptlist "$unencrypted_file" ; then
|
2014-11-05 16:48:10 +00:00
|
|
|
read -r -p "Encrypt file $param? (y/n) " ans
|
2014-09-09 20:32:48 +00:00
|
|
|
case "$ans" in
|
|
|
|
|
y* | Y*)
|
2015-07-24 09:57:34 -04:00
|
|
|
"${BLACKBOX_HOME}/blackbox_register_new_file" "$unencrypted_file"
|
2014-09-09 20:32:48 +00:00
|
|
|
;;
|
|
|
|
|
*)
|
2015-07-24 09:57:34 -04:00
|
|
|
echo >&2 'Skipping...'
|
2014-09-09 20:32:48 +00:00
|
|
|
continue
|
|
|
|
|
;;
|
|
|
|
|
esac
|
2014-09-04 11:29:23 -03:00
|
|
|
fi
|
2015-07-24 09:57:34 -04:00
|
|
|
"${BLACKBOX_HOME}/blackbox_edit_start" "$unencrypted_file"
|
|
|
|
|
"$EDITOR" "$(get_unencrypted_filename "$unencrypted_file")"
|
|
|
|
|
"${BLACKBOX_HOME}/blackbox_edit_end" "$unencrypted_file"
|
|
|
|
|
|
2014-09-04 11:29:23 -03:00
|
|
|
done
|