# Turn off pathname expansion so expansion can work properly
set -f
-# Export preferences and version for other scripts
+# Export globals for other scripts
export PREFERENCES="`dirname $CONFIG`/$KEYRING"
export KEYRINGER_VERSION
export CONFIG_VERSION
export KEYRING
+export CONFIG
# Set functions location
if [ -e "`dirname $(readlink -f $0)`/lib/$NAME/functions" ]; then
source "$LIB" || exit 1
# Get file
-keyringer_get_file "$2"
+keyringer_get_file "$RELATIVE_PATH/$2"
# Only display directions if we're running append, not append-batch
if [ "$BASENAME" == "append" ]; then
# Append content to an existing secret
( keyringer_exec decrypt "$BASEDIR" "$FILE" && cat ) | \
- keyringer_exec encrypt-batch $BASEDIR $FILE
+ keyringer_exec encrypt-batch "$BASEDIR" "$FILE"
source "$LIB" || exit 1
# Get file
-keyringer_get_file "$2"
+keyringer_get_file "$RELATIVE_PATH/$2"
# Decrypt
$GPG --quiet --use-agent -d "$KEYDIR/$FILE"
source "$LIB" || exit 1
# Get file
-keyringer_get_file "$2"
+keyringer_get_file "$RELATIVE_PATH/$2"
# Set options
if [ ! -z "$3" ]; then
source "$LIB" || exit 1
# Get file
-keyringer_get_file "$2"
+keyringer_get_file "$RELATIVE_PATH/$2"
# Set recipients file
keyringer_set_recipients "$FILE"
FILE="$BASEPATH"
fi
- keyringer_get_new_file $FILE
+ keyringer_get_new_file $RELATIVE_PATH/$FILE
if [ ! -e "$UNENCRYPTED_FILE" ]; then
echo "Error: cannot encrypt $UNENCRYPTED_FILE: path not found."
else
UNENCRYPTED_FILE="-"
shift
- keyringer_get_new_file $*
+ keyringer_get_new_file $RELATIVE_PATH/$*
fi
# Set recipients file
# Aditional parameters
KEYTYPE="$2"
-FILE="$3"
+FILE="$RELATIVE_PATH/$3"
NODE="$4"
OUTFILE="$5"
CWD="`pwd`"
--- /dev/null
+usage
\ No newline at end of file
ARGS="`echo "$*" | sed -e "s|^/*||"`"
# Run list command
-cd "$KEYDIR" && ls $ARGS
+cd "$KEYDIR/$RELATIVE_PATH" && ls $ARGS
cd "$CWD"
function keyringer_recrypt {
# Get file
- keyringer_get_file "$1"
+ keyringer_get_file "$RELATIVE_PATH/$1"
# Set recipients file
keyringer_set_recipients "$FILE"
# While a "quit" command isn't entered, read STDIN
while read -rep "keyringer:/${KEYRING}${SHELLPATH}> " STDIN; do
- if [ "$STDIN" == "quit" ]; then
+ if [ "$STDIN" == "quit" ] || [ "$STDIN" == "exit" ] || [ "$STDIN" == "bye" ]; then
break
+ elif [ "$STDIN" == "shell" ]; then
+ echo "Why you need nesting?"
elif [[ "$STDIN" == "cd"* ]]; then
# Update current path
fi
# Run list command
-cd "$KEYDIR" && $TREE $ARGS
+cd "$KEYDIR/$RELATIVE_PATH" && $TREE $ARGS
cd "$CWD"
LIB="`dirname $0`/../functions"
source "$LIB" || exit 1
-keyringer_usage
+keyringer_usage $KEYRING
printf "Usage: %s <keyring> <action> [arguments]\n\n" "$BASENAME"
printf "Available commands: \n\n"
keyringer_show_actions | sed -e 's/^/\t/'
- printf "\tinit <path> [remote]\n\n" $BASENAME
- if [ ! -z "$keyrings" ]; then
+ # Display only when not in a keyring context
+ if [ ! -z "$keyrings" ] && [ -z "$1" ]; then
+ printf "\tinit <path> [remote]\n\n" $BASENAME
printf "Available keyrings: %s \n" "$keyrings"
fi
}