aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2013-12-10 22:13:25 -0200
committerSilvio Rhatto <rhatto@riseup.net>2013-12-10 22:13:25 -0200
commit21e393464645c76c949d74180ce04b7507e0d738 (patch)
tree877bad044cc49ea185737d810ab82040b5f005c1 /lib
parentb2b3a02e33c9efbbfce46a658360189ecc8dda2a (diff)
downloadkeyringer-21e393464645c76c949d74180ce04b7507e0d738.tar.gz
keyringer-21e393464645c76c949d74180ce04b7507e0d738.tar.bz2
Adding 'teardown' action
Diffstat (limited to 'lib')
-rwxr-xr-xlib/keyringer/actions/teardown27
-rwxr-xr-xlib/keyringer/functions13
2 files changed, 37 insertions, 3 deletions
diff --git a/lib/keyringer/actions/teardown b/lib/keyringer/actions/teardown
new file mode 100755
index 0000000..3d33da4
--- /dev/null
+++ b/lib/keyringer/actions/teardown
@@ -0,0 +1,27 @@
+#!/bin/bash
+#
+# Remove a keyring.
+#
+
+# Load functions
+LIB="`dirname $0`/../functions"
+source "$LIB" || exit 1
+
+# Options
+CONFIRM="$2"
+
+if [ -z "$CONFIRM" ] || [ "$CONFIRM" != "-y" ]; then
+ echo "WARNING: about to remove the LOCAL copy of $KEYRING"
+ echo "WARNING: This will irrevocably destroy $KEYDIR"
+ echo "WARNING: the action cannot be undone!"
+
+ read -rep "Are you sure to WIPE keyring $KEYRING (type YES to confirm)? " key
+ if [ "$key" != "YES" ]; then
+ exit 1
+ fi
+fi
+
+# Teardown
+keyringer_shred `dirname $KEYDIR`
+keyringer_shred $HOME/.keyringer/$KEYRING
+sed -i -e "/^$KEYRING=/d" $HOME/.keyringer/config
diff --git a/lib/keyringer/functions b/lib/keyringer/functions
index 872dac9..0e795ee 100755
--- a/lib/keyringer/functions
+++ b/lib/keyringer/functions
@@ -206,10 +206,17 @@ function keyringer_shred {
echo "$message $path using $tool..."
if [ -d "$path" ]; then
- find $path -exec $tool -f {} \;
- rmdir $path
+ if [ "$tool" == "wipe" ] || [ "$tool" == "rm" ]; then
+ $tool -rf $path
+ else
+ find $path -exec $tool -uf {} \;
+ fi
else
- $tool -f "$path"
+ if [ "$tool" == "wipe" ] || [ "$tool" == "rm" ]; then
+ $tool -f "$path"
+ else
+ $tool -uf "$path"
+ fi
fi
}