]> gitweb.fluxo.info Git - keyringer.git/commitdiff
Integrating shell with all commands (#34)
authorSilvio Rhatto <rhatto@riseup.net>
Tue, 10 Dec 2013 16:15:51 +0000 (14:15 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Tue, 10 Dec 2013 16:15:51 +0000 (14:15 -0200)
14 files changed:
keyringer
lib/keyringer/actions/append
lib/keyringer/actions/decrypt
lib/keyringer/actions/del
lib/keyringer/actions/edit
lib/keyringer/actions/encrypt
lib/keyringer/actions/genpair
lib/keyringer/actions/help [new symlink]
lib/keyringer/actions/ls
lib/keyringer/actions/recrypt
lib/keyringer/actions/shell
lib/keyringer/actions/tree
lib/keyringer/actions/usage
lib/keyringer/functions

index e65bef03562e5f57420a972632d34314cc9eff2e..33d19ff7627e89ea88fffbba0312bbf481aff8ab 100755 (executable)
--- a/keyringer
+++ b/keyringer
@@ -131,11 +131,12 @@ ACTION="$2"
 # 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
index e307056529c0eef5d60e21bb45d76b1249506cbc..818a7ac5665bee3e757436e12cd7accb63309910 100755 (executable)
@@ -8,7 +8,7 @@ LIB="`dirname $0`/../functions"
 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
@@ -17,4 +17,4 @@ fi
 
 # Append content to an existing secret
 ( keyringer_exec decrypt "$BASEDIR" "$FILE" && cat ) | \
-  keyringer_exec encrypt-batch $BASEDIR $FILE
+  keyringer_exec encrypt-batch "$BASEDIR" "$FILE"
index 2b1401c70f32367215a0ac0d775ee14b2c47be65..aab7881134ffb69496a061c98b37b0690ed87080 100755 (executable)
@@ -8,7 +8,7 @@ LIB="`dirname $0`/../functions"
 source "$LIB" || exit 1
 
 # Get file
-keyringer_get_file "$2"
+keyringer_get_file "$RELATIVE_PATH/$2"
 
 # Decrypt
 $GPG --quiet --use-agent -d "$KEYDIR/$FILE"
index d160ac4d1972bc7273610a75cc6a0a1cbaeb3fbc..a2514d7c9819a7a39a564a452a288cabc719981d 100755 (executable)
@@ -8,7 +8,7 @@ LIB="`dirname $0`/../functions"
 source "$LIB" || exit 1
 
 # Get file
-keyringer_get_file "$2"
+keyringer_get_file "$RELATIVE_PATH/$2"
 
 # Set options
 if [ ! -z "$3" ]; then
index 9a3e4881929c46dc96bfdf4f7815f41af6e3e428..d303bd5f5932e4c7da9670486247fc486ec646d3 100755 (executable)
@@ -8,7 +8,7 @@ LIB="`dirname $0`/../functions"
 source "$LIB" || exit 1
 
 # Get file
-keyringer_get_file "$2"
+keyringer_get_file "$RELATIVE_PATH/$2"
 
 # Set recipients file
 keyringer_set_recipients "$FILE"
index 0a40bc18b92988f6b895365dc93a4845279802da..526eaa180269c93ab7d14687460d6c51058335da 100755 (executable)
@@ -65,7 +65,7 @@ if [ ! -z "$3" ]; then
     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."
@@ -74,7 +74,7 @@ if [ ! -z "$3" ]; then
 else
   UNENCRYPTED_FILE="-"
   shift
-  keyringer_get_new_file $*
+  keyringer_get_new_file $RELATIVE_PATH/$*
 fi
 
 # Set recipients file
index f048bc7f38268b904e5b45f8d5e3f722be7075fe..6898b0ff4dee93a91605e142a38189feed54d1eb 100755 (executable)
@@ -184,7 +184,7 @@ source "$LIB" || exit 1
 
 # Aditional parameters
 KEYTYPE="$2"
-FILE="$3"
+FILE="$RELATIVE_PATH/$3"
 NODE="$4"
 OUTFILE="$5"
 CWD="`pwd`"
diff --git a/lib/keyringer/actions/help b/lib/keyringer/actions/help
new file mode 120000 (symlink)
index 0000000..ae18295
--- /dev/null
@@ -0,0 +1 @@
+usage
\ No newline at end of file
index bb662637082b9e0d93cb55f9bed20d682204a64c..93f5f7541195de8bad73274b7c0dc4c628d7ed6c 100755 (executable)
@@ -15,5 +15,5 @@ shift
 ARGS="`echo "$*" | sed -e "s|^/*||"`"
 
 # Run list command
-cd "$KEYDIR" && ls $ARGS
+cd "$KEYDIR/$RELATIVE_PATH" && ls $ARGS
 cd "$CWD"
index 014fef71539774368473cc746f425577f858c2dd..7d5c6ae0c323ebdebe55b7142563be0a823d1371 100755 (executable)
@@ -9,7 +9,7 @@ source "$LIB" || exit 1
 
 function keyringer_recrypt {
   # Get file
-  keyringer_get_file "$1"
+  keyringer_get_file "$RELATIVE_PATH/$1"
 
   # Set recipients file
   keyringer_set_recipients "$FILE"
index d9a3e074f0243afab5fb6f1dde468d7deee4f063..955dfe8ec5c06ec11886c3b55727adc5e53c3889 100755 (executable)
@@ -12,8 +12,10 @@ SHELLPATH="/"
 
 # 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
index 8e94cb0eca9803fffc4254b08d725c623fe5a7f7..a2e272da7360dd2f9291890c146961df5e107a3b 100755 (executable)
@@ -27,5 +27,5 @@ else
 fi
 
 # Run list command
-cd "$KEYDIR" && $TREE $ARGS
+cd "$KEYDIR/$RELATIVE_PATH" && $TREE $ARGS
 cd "$CWD"
index f4ac0fa9cd23b2b7f1ee529cc8a660331bf3ef8e..e3369cc05bb864edf33bb9f55352798956fc4597 100755 (executable)
@@ -7,4 +7,4 @@
 LIB="`dirname $0`/../functions"
 source "$LIB" || exit 1
 
-keyringer_usage
+keyringer_usage $KEYRING
index bef00d9759ec9202906a675cf49bed477d40a6dd..f387c464ff4cc34ef5106d94cf71b002d8219b37 100755 (executable)
@@ -474,9 +474,10 @@ function keyringer_usage {
   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
 }