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.
This commit is contained in:
@@ -7,7 +7,13 @@
|
|||||||
# Usage:
|
# Usage:
|
||||||
#
|
#
|
||||||
# set -e
|
# set -e
|
||||||
# . _blackbox_common.sh
|
# source "${0%/*}/_blackbox_common.sh"
|
||||||
|
|
||||||
|
# Load additional useful functions
|
||||||
|
source "${0%/*}"/_stack_lib.sh
|
||||||
|
|
||||||
|
# Where are we?
|
||||||
|
: "${BLACKBOX_HOME:=$(cd "${0%/*}" ; pwd)}" ;
|
||||||
|
|
||||||
# Where in the VCS repo should the blackbox data be found?
|
# Where in the VCS repo should the blackbox data be found?
|
||||||
: "${BLACKBOXDATA:=keyrings/live}" ; # If BLACKBOXDATA not set, set it.
|
: "${BLACKBOXDATA:=keyrings/live}" ; # If BLACKBOXDATA not set, set it.
|
||||||
|
|||||||
@@ -9,9 +9,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
blackbox_home=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
source "${0%/*}/_blackbox_common.sh"
|
||||||
source ${blackbox_home}/_blackbox_common.sh
|
|
||||||
source ${blackbox_home}/_stack_lib.sh
|
|
||||||
|
|
||||||
fail_if_not_in_repo
|
fail_if_not_in_repo
|
||||||
|
|
||||||
|
|||||||
@@ -4,14 +4,13 @@
|
|||||||
# blackbox_cat -- Decrypt a file, cat it, shred it
|
# blackbox_cat -- Decrypt a file, cat it, shred it
|
||||||
#
|
#
|
||||||
set -e
|
set -e
|
||||||
blackbox_home=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
source "${0%/*}/_blackbox_common.sh"
|
||||||
source "${blackbox_home}/_blackbox_common.sh"
|
|
||||||
|
|
||||||
for param in "$@" ; do
|
for param in "$@" ; do
|
||||||
shreddable=0
|
shreddable=0
|
||||||
unencrypted_file=$(get_unencrypted_filename "$param")
|
unencrypted_file=$(get_unencrypted_filename "$param")
|
||||||
if [[ ! -e "$unencrypted_file" ]]; then
|
if [[ ! -e "$unencrypted_file" ]]; then
|
||||||
"${blackbox_home}/blackbox_edit_start" "$param"
|
"${BLACKBOX_HOME}/blackbox_edit_start" "$param"
|
||||||
shreddable=1
|
shreddable=1
|
||||||
fi
|
fi
|
||||||
cat "$unencrypted_file"
|
cat "$unencrypted_file"
|
||||||
|
|||||||
@@ -7,8 +7,7 @@
|
|||||||
# encrypted file will also be removed from the filesystem.
|
# encrypted file will also be removed from the filesystem.
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
blackbox_home=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
source "${0%/*}/_blackbox_common.sh"
|
||||||
source "${blackbox_home}/_blackbox_common.sh"
|
|
||||||
_determine_vcs_base_and_type
|
_determine_vcs_base_and_type
|
||||||
|
|
||||||
unencrypted_file=$(get_unencrypted_filename "$1")
|
unencrypted_file=$(get_unencrypted_filename "$1")
|
||||||
|
|||||||
@@ -5,8 +5,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
blackbox_home=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
source "${0%/*}/_blackbox_common.sh"
|
||||||
source "${blackbox_home}/_blackbox_common.sh"
|
|
||||||
|
|
||||||
if [[ -z $GPG_AGENT_INFO ]]; then
|
if [[ -z $GPG_AGENT_INFO ]]; then
|
||||||
echo 'WARNING: You probably want to run gpg-agent as'
|
echo 'WARNING: You probably want to run gpg-agent as'
|
||||||
|
|||||||
@@ -4,8 +4,7 @@
|
|||||||
# blackbox_edit -- Decrypt a file temporarily for edition, then re-encrypts it again
|
# blackbox_edit -- Decrypt a file temporarily for edition, then re-encrypts it again
|
||||||
#
|
#
|
||||||
set -e
|
set -e
|
||||||
blackbox_home=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
source "${0%/*}/_blackbox_common.sh"
|
||||||
source "${blackbox_home}/_blackbox_common.sh"
|
|
||||||
|
|
||||||
for param in "$@" ; do
|
for param in "$@" ; do
|
||||||
unencrypted_file=$(get_unencrypted_filename "$param")
|
unencrypted_file=$(get_unencrypted_filename "$param")
|
||||||
@@ -13,7 +12,7 @@ for param in "$@" ; do
|
|||||||
read -r -p "Encrypt file $param? (y/n) " ans
|
read -r -p "Encrypt file $param? (y/n) " ans
|
||||||
case "$ans" in
|
case "$ans" in
|
||||||
y* | Y*)
|
y* | Y*)
|
||||||
"${blackbox_home}/blackbox_register_new_file" "$param"
|
"${BLACKBOX_HOME}/blackbox_register_new_file" "$param"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo 'Skipping...'
|
echo 'Skipping...'
|
||||||
@@ -21,7 +20,7 @@ for param in "$@" ; do
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
"${blackbox_home}/blackbox_edit_start" "$param"
|
"${BLACKBOX_HOME}/blackbox_edit_start" "$param"
|
||||||
"$EDITOR" "$(get_unencrypted_filename "$param")"
|
"$EDITOR" "$(get_unencrypted_filename "$param")"
|
||||||
"${blackbox_home}/blackbox_edit_end" "$param"
|
"${BLACKBOX_HOME}/blackbox_edit_end" "$param"
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -5,8 +5,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
blackbox_home=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
source "${0%/*}/_blackbox_common.sh"
|
||||||
source "${blackbox_home}/_blackbox_common.sh"
|
|
||||||
|
|
||||||
unencrypted_file=$(get_unencrypted_filename "$1")
|
unencrypted_file=$(get_unencrypted_filename "$1")
|
||||||
encrypted_file=$(get_encrypted_filename "$1")
|
encrypted_file=$(get_encrypted_filename "$1")
|
||||||
|
|||||||
@@ -5,8 +5,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
blackbox_home=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
source "${0%/*}/_blackbox_common.sh"
|
||||||
source "${blackbox_home}/_blackbox_common.sh"
|
|
||||||
|
|
||||||
for param in "$@" ; do
|
for param in "$@" ; do
|
||||||
unencrypted_file=$(get_unencrypted_filename "$param")
|
unencrypted_file=$(get_unencrypted_filename "$param")
|
||||||
|
|||||||
@@ -9,8 +9,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
blackbox_home=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
source "${0%/*}/_blackbox_common.sh"
|
||||||
source "${blackbox_home}/_blackbox_common.sh"
|
|
||||||
|
|
||||||
_determine_vcs_base_and_type # Sets VCS_TYPE
|
_determine_vcs_base_and_type # Sets VCS_TYPE
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,5 @@
|
|||||||
# blackbox_list_files -- List files that black box is tracking
|
# blackbox_list_files -- List files that black box is tracking
|
||||||
#
|
#
|
||||||
set -e
|
set -e
|
||||||
blackbox_home=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
source "${0%/*}/_blackbox_common.sh"
|
||||||
source "${blackbox_home}/_blackbox_common.sh"
|
|
||||||
cat "$BB_FILES"
|
cat "$BB_FILES"
|
||||||
|
|||||||
@@ -14,8 +14,7 @@
|
|||||||
export PATH=/usr/bin:/bin:"$PATH"
|
export PATH=/usr/bin:/bin:"$PATH"
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
blackbox_home=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
source "${0%/*}/_blackbox_common.sh"
|
||||||
source "${blackbox_home}/_blackbox_common.sh"
|
|
||||||
|
|
||||||
if [[ "$1" == "" ]]; then
|
if [[ "$1" == "" ]]; then
|
||||||
FILE_GROUP=""
|
FILE_GROUP=""
|
||||||
|
|||||||
@@ -9,8 +9,7 @@
|
|||||||
# blackbox_postdeploy.sh to decrypt all the files.
|
# blackbox_postdeploy.sh to decrypt all the files.
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
blackbox_home=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
source "${0%/*}/_blackbox_common.sh"
|
||||||
source "${blackbox_home}/_blackbox_common.sh"
|
|
||||||
|
|
||||||
unencrypted_file=$(get_unencrypted_filename "$1")
|
unencrypted_file=$(get_unencrypted_filename "$1")
|
||||||
encrypted_file=$(get_encrypted_filename "$1")
|
encrypted_file=$(get_encrypted_filename "$1")
|
||||||
|
|||||||
@@ -10,9 +10,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
blackbox_home=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
source "${0%/*}/_blackbox_common.sh"
|
||||||
source "${blackbox_home}/_blackbox_common.sh"
|
|
||||||
source "${blackbox_home}/_stack_lib.sh"
|
|
||||||
|
|
||||||
fail_if_not_in_repo
|
fail_if_not_in_repo
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,7 @@
|
|||||||
# have been decrypted for editing, you will see an empty list.
|
# have been decrypted for editing, you will see an empty list.
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
blackbox_home=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
source "${0%/*}/_blackbox_common.sh"
|
||||||
source "${blackbox_home}/_blackbox_common.sh"
|
|
||||||
|
|
||||||
change_to_vcs_root
|
change_to_vcs_root
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
blackbox_home=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
source "${0%/*}/_blackbox_common.sh"
|
||||||
source "${blackbox_home}/_blackbox_common.sh"
|
|
||||||
|
|
||||||
if [[ -z $GPG_AGENT_INFO ]]; then
|
if [[ -z $GPG_AGENT_INFO ]]; then
|
||||||
echo 'WARNING: You probably want to run gpg-agent as'
|
echo 'WARNING: You probably want to run gpg-agent as'
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
# blackbox_whatsnew - show what has changed in the last commit for a given file
|
# blackbox_whatsnew - show what has changed in the last commit for a given file
|
||||||
#
|
#
|
||||||
|
|
||||||
blackbox_home=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
|
set -e
|
||||||
source "${blackbox_home}/_blackbox_common.sh"
|
source "${0%/*}/_blackbox_common.sh"
|
||||||
|
|
||||||
if [[ $# -ne 1 ]]
|
if [[ $# -ne 1 ]]
|
||||||
then
|
then
|
||||||
@@ -39,7 +39,7 @@ cat_commit()
|
|||||||
git checkout $COMMIT $FILE
|
git checkout $COMMIT $FILE
|
||||||
echo "[$COMMIT] $FILE"
|
echo "[$COMMIT] $FILE"
|
||||||
echo "---------------------"
|
echo "---------------------"
|
||||||
"${blackbox_home}/blackbox_cat" $FILE | sed '/========== PLAINFILE/,/========== EXTRACTING/d'
|
"${BLACKBOX_HOME}/blackbox_cat" $FILE | sed '/========== PLAINFILE/,/========== EXTRACTING/d'
|
||||||
}
|
}
|
||||||
|
|
||||||
CURR_CONTENT=`cat_commit $CURR_COMMIT`
|
CURR_CONTENT=`cat_commit $CURR_COMMIT`
|
||||||
|
|||||||
Reference in New Issue
Block a user