Skip to content
Browse files

Enhancement: Encrypted notes

 * Adding encrypted notes, doesn't use pki, but plain passwords.
  • Loading branch information...
1 parent f4ba979 commit 192541750a4e075b0e1cf60457c8542aa8bd8936 @the1ts committed Nov 6, 2011
View
9 actions/enotes/enc
@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+action=$1
+shift
+
+if [ "$1" = "useage" ]; then
+ "$TODO_FULL_SH" enotescat useage
+else
+ "$TODO_FULL_SH" enotescat "$@"
+fi
View
9 actions/enotes/ene
@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+action=$1
+shift
+
+if [ "$1" = "useage" ]; then
+ "$TODO_FULL_SH" enotesedit useage
+else
+ "$TODO_FULL_SH" enotesedit "$@"
+fi
View
40 actions/enotes/enotesarchive
@@ -0,0 +1,40 @@
+#!/usr/bin/env bash
+# 2009 Paul Mansfield <paul.mansfield@mansteck.co.uk>
+# License: GPL, http://www.gnu.org/copyleft/gpl.html
+
+case $1 in
+ "useage")
+ echo " $(basename $0)"
+ echo " archive encrypted notes files nolonger in todo file."
+ echo " If BASENAME is not given, defaults to 'todo'."
+ echo ""
+ ;;
+
+ *)
+ # construct file name
+ PRE=$(basename $TODO_FILE | sed 's/.txt$//g')
+ PRETICKLER=$(basename $TODO_FILE | sed 's/_todo.txt$//g')
+ cd $TODO_DIR/notes || exit 1
+ NOTES=$(find . -maxdepth 1 -name "$PRE*" | sed 's/\.\///g')
+
+ # Create file from todo and 'tickled' files
+ cat $TODO_FILE>> $TMP_FILE
+ if [ -n $TICKLER_DIR ]; then
+ find $TICKLER_DIR -mindepth 2 -size 1b -exec cat {} >>$TMP_FILE \;
+ fi
+
+ # for each file, remove $PRE and see if its in todo or 'tickled' files
+ for i in $NOTES ; do
+ NOTE_FILE=$(echo $i | sed -e "s/$PRE-//g" -e "s/\.txt//g")
+ # if filename isn't in our todo file, archive in notes/archive/$file
+ if [ $(grep -o '[^ ]*enote:[^ ]\+' "$TMP_FILE" | grep '^enote:' | sort -u| sed "s/^enote://g"| grep -c $NOTE_FILE) -eq 0 ] ;then
+ cat $TODO_DIR/notes/${PRE}-${NOTE_FILE}.enc >> $TODO_DIR/notes/archive/${PRE}-${NOTE_FILE}.$(date +%s).txt || exit 1
+ rm $TODO_DIR/notes/${PRE}-${NOTE_FILE}.enc
+ # If we are using commit action then add to git
+ if [ -e $TODOTXT_ACTIONS_DIR/commit ]; then
+ git add $TODO_DIR/notes/archive/${PRE}-${NOTE_FILE}.$(date +%s).enc
+ fi
+ fi
+ done
+ ;;
+esac
View
26 actions/enotes/enotescat
@@ -0,0 +1,26 @@
+#!/usr/bin/env bash
+# 2009 Paul Mansfield <paul.mansfield@mansteck.co.uk>
+# License: GPL, http://www.gnu.org/copyleft/gpl.html
+
+case $1 in
+"useage")
+ echo " $(basename $0) [NOTESFILE]"
+ echo " Cat encyrpted notes file, use lsenotes to get list of notes"
+ echo ""
+;;
+
+*)
+ if [ $# -lt 2 ]; then
+ $0 useage
+ exit 1
+ fi
+ NOTE_FILE=$(echo $2 | sed 's/^enote://g')
+ PRE=$(basename $TODO_FILE | sed 's/.enc$//g')
+ if [ -e $TODO_DIR/notes/${PRE}-${NOTE_FILE}.enc ]; then
+ gpg -d $TODO_DIR/notes/${PRE}-${NOTE_FILE}.enc
+ echo ""
+ else
+ echo "No such encrypted notes file, use lsenotes to find encrypted notes files"
+ fi
+;;
+esac
View
60 actions/enotes/enotesedit
@@ -0,0 +1,60 @@
+#!/usr/bin/env bash
+# 2011 Paul Mansfield <paul.mansfield@mansteck.co.uk>
+# License: GPL, http://www.gnu.org/copyleft/gpl.html
+
+useage () {
+ echo " $(basename $0) [NOTESFILE]"
+ echo " Edit encrypted NOTESFILE in \$EDITOR."
+ echo " Use listenotes to show all encrypted notesfiles."
+ echo ""
+ }
+
+case $1 in
+ "useage")
+ useage
+ ;;
+
+ *)
+ if [ $# -lt 2 ]; then
+ $0 useage
+ exit 1
+ fi
+ cd $TODO_DIR
+
+ # construct file name
+ NOTE_FILE=$(echo $2 | sed 's/^enote://g')
+ PRE=$(basename $TODO_FILE | sed 's/.txt$//g')
+
+ # Create file from todo and 'tickled' files
+ cat $TODO_FILE>> $TMP_FILE
+ if [ -n $TICKER_DIR ]; then
+ find $TICKLER_DIR -mindepth 2 -size 1b -exec cat {} >>$TMP_FILE \;
+ fi
+
+ # If file exists edit it else check lsenotes for pointer then edit
+ # and add to git if commit action file exists
+ if [ -e $TODO_DIR/notes/${PRE}-${NOTE_FILE}.enc ]; then
+ # Decrypt, move old aside, edit, encrypt and tidy up
+ gpg -d -o $TMP_FILE.encrypt $TODO_DIR/notes/${PRE}-${NOTE_FILE}.enc
+ mv $TODO_DIR/notes/${PRE}-${NOTE_FILE}.enc $TODO_DIR/notes/${PRE}-${NOTE_FILE}.enc.bak
+ editor $TMP_FILE.encrypt
+ gpg -c --force-mdc -o $TODO_DIR/notes/${PRE}-${NOTE_FILE}.enc $TMP_FILE.encrypt
+ if [ $? -eq 0 ] ; then
+ rm -rf $TODO_DIR/notes/${PRE}-${NOTE_FILE}.enc.bak
+ else
+ mv $TODO_DIR/notes/${PRE}-${NOTE_FILE}.enc.bak $TODO_DIR/notes/${PRE}-${NOTE_FILE}.enc
+ fi
+ rm -rf $TMP_FILE.encrypt
+ else
+ # If note link in todo.enc exists then edit
+ if [ $(grep -o '[^ ]*enote:[^ ]\+' "$TMP_FILE" | grep '^enote:' | grep "$2$" | sort -u| sed "s/^enote://g"| grep -c $NOTE_FILE) -ge 1 ] ; then
+ # edit file, encrypt and tidy up
+ editor $TMP_FILE.encrypt
+ gpg -c --force-mdc -o $TODO_DIR/notes/${PRE}-${NOTE_FILE}.enc $TMP_FILE.encrypt
+ rm -rf $TMP_FILE.encrypt
+ else
+ echo "No such encrypted Notes file, use lsenotes to find notes files"
+ fi
+ fi
+ ;;
+esac
View
32 actions/enotes/listenotes
@@ -0,0 +1,32 @@
+#!/usr/bin/env bash
+# 2009 Paul Mansfield <paul.mansfield@mansteck.co.uk>
+# License: GPL, http://www.gnu.org/copyleft/gpl.html
+
+if [ $1 != "useage" ]; then
+ action=$1;shift
+fi
+set -x
+useage() {
+ echo " $(basename $0)"
+ echo " List notes"
+ echo ""
+}
+
+case $1 in
+ "useage")
+ useage
+ ;;
+
+ "-h")
+ useage
+ ;;
+
+ *)
+ # Create file from todo and 'tickled' files
+ cat $TODO_FILE>> $TMP_FILE
+ if [ -n $TICKER_DIR ]; then
+ find $TICKLER_DIR -mindepth 2 -size 1b -exec cat {} >>$TMP_FILE \;
+ fi
+ grep -o '\benote\:\w*' "$TMP_FILE" | sed 's/\benote://g' | sort -u
+ ;;
+esac
View
7 actions/enotes/lsen
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+
+if [ "$1" = "useage" ]; then
+ "$TODO_FULL_SH" listenotes useage
+else
+ "$TODO_FULL_SH" listenotes "$@"
+fi

0 comments on commit 1925417

Please sign in to comment.
Something went wrong with that request. Please try again.