]> gitweb.fluxo.info Git - keyringer.git/commitdiff
Adding 'append' action
authorSilvio Rhatto <rhatto@riseup.net>
Thu, 16 Sep 2010 15:12:17 +0000 (12:12 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Thu, 16 Sep 2010 15:12:17 +0000 (12:12 -0300)
README
share/keyringer/append [new file with mode: 0755]

diff --git a/README b/README
index f6be24ddfb5ed0d5e6956417a83e2e1199f348dd..c9a4741b54a07cf2c939635f9251ed1f19e41b2d 100644 (file)
--- a/README
+++ b/README
@@ -75,6 +75,11 @@ Re-encrypting a key
 
     keyringer <keyring> recrypt <file>
 
+Appending information to a key
+------------------------------
+
+    keyringer <keyring> append <file>
+
 Editing a key
 -------------
 
diff --git a/share/keyringer/append b/share/keyringer/append
new file mode 100755 (executable)
index 0000000..4422e29
--- /dev/null
@@ -0,0 +1,43 @@
+#!/bin/bash
+#
+# Append information into encrypted files.
+#
+
+# Load functions
+LIB="`dirname $0`/../../lib/keyringer/functions"
+source $LIB
+
+# Config
+ACTIONS="`dirname $0`"
+BASEDIR="$1"
+FILE="`keyringer_filename $2`"
+KEYDIR="$BASEDIR/keys"
+RECIPIENTS="$BASEDIR/config/recipients"
+BASENAME="`basename $0`"
+
+if [ -z "$FILE" ]; then
+  echo "Usage: keyringer <keyring> `basename $0` <file>"
+  exit 1
+elif [ ! -f "$RECIPIENTS" ]; then
+  echo "No recipient config was found"
+  exit 1
+elif [ ! -f "$KEYDIR/$FILE" ]; then
+  echo "File not found: $KEYDIR/$FILE"
+  exit 1
+fi
+
+CONTENT=($(keyringer_exec decrypt $BASEDIR $FILE))
+
+echo "This is the current content of $FILE:"
+echo " "
+echo "$CONTENT"
+echo " "
+echo "Now please write the content to be appended on $FILE, finnishing with Ctrl-D:"
+
+APPEND=($(cat -))
+
+NEW=( ${CONTENT[@]} ${APPEND[@]} )
+
+for element in $(seq 0 $((${#NEW[@]} - 1))); do
+  echo ${NEW[$element]}
+done | keyringer_exec encrypt $BASEDIR $FILE