]> gitweb.fluxo.info Git - keyringer.git/commitdiff
Adding 'teardown' action
authorSilvio Rhatto <rhatto@riseup.net>
Wed, 11 Dec 2013 00:13:25 +0000 (22:13 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Wed, 11 Dec 2013 00:13:25 +0000 (22:13 -0200)
development.mdwn
lib/keyringer/actions/teardown [new file with mode: 0755]
lib/keyringer/functions
share/man/keyringer.1.mdwn

index 1f475b6fafbe224e81a9478191b7d53b2e3eeae7..8366b590686d4cd91a607eacb8c94f6d4142f454 100644 (file)
@@ -102,9 +102,7 @@ Setup:
 
 Teardown:
 
-    rm -rf ~/code/tests/keyringer
-    rm ~/.keyringer/test
-    sed -i -e '/^test=/d' ~/.keyringer/config
+    keyringer test teardown -y
 
 Translation
 -----------
diff --git a/lib/keyringer/actions/teardown b/lib/keyringer/actions/teardown
new file mode 100755 (executable)
index 0000000..3d33da4
--- /dev/null
@@ -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
index 872dac9c0025c9ab8d661dc7d498aeb938cc6cc3..0e795eea4fcb15db1cb3b34527daf81eb8803ae4 100755 (executable)
@@ -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
 }
 
index f8d243edccba870cfc2101253ae1136c189cc19d..ad9569b462753f7b4ac4232a6b08722cd89f1f9f 100644 (file)
@@ -74,6 +74,10 @@ shell
     All <*secret*> parameters from actions invoked from the shell are called
     relatively from the current selected directory.
 
+teardown
+:   Remove permanently a local copy of a repository, very dangerous if you
+    have just a single copy.
+
 # SECRET MANIPULATION ACTIONS
 
 All secret manipulation actions operate upon a *secret* which is the pathname