summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2010-09-16 12:12:17 -0300
committerSilvio Rhatto <rhatto@riseup.net>2010-09-16 12:12:17 -0300
commitae2c26a64065e48bc2f863d9f7648b7a49b072f7 (patch)
treee323d55d32695baa8f82001a4de139c2ba9360bb /share
parentfc8b45759049af4e1077bb28d53545c4c967212f (diff)
downloadkeyringer-ae2c26a64065e48bc2f863d9f7648b7a49b072f7.tar.gz
keyringer-ae2c26a64065e48bc2f863d9f7648b7a49b072f7.tar.bz2
Adding 'append' action
Diffstat (limited to 'share')
-rwxr-xr-xshare/keyringer/append43
1 files changed, 43 insertions, 0 deletions
diff --git a/share/keyringer/append b/share/keyringer/append
new file mode 100755
index 0000000..4422e29
--- /dev/null
+++ b/share/keyringer/append
@@ -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