summaryrefslogtreecommitdiff
path: root/lib/keyringer/actions/mv
diff options
context:
space:
mode:
Diffstat (limited to 'lib/keyringer/actions/mv')
-rwxr-xr-xlib/keyringer/actions/mv28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/keyringer/actions/mv b/lib/keyringer/actions/mv
new file mode 100755
index 0000000..aaf6772
--- /dev/null
+++ b/lib/keyringer/actions/mv
@@ -0,0 +1,28 @@
+#!/bin/bash
+#
+# Move secrets.
+#
+
+# Load functions
+LIB="`dirname $0`/../functions"
+source "$LIB" || exit 1
+
+# Avoid leading slash
+ORIG="$(keyringer_filename `echo "$2" | sed -e "s|^/*||"`)"
+DEST="`echo "$3" | sed -e "s|^/*||"`"
+
+# Set destination
+if [ ! -d "$KEYDIR/$RELATIVE_PATH/$DEST" ]; then
+ keyringer_get_new_file $DEST
+else
+ FILE="$DEST"
+fi
+
+# Check if secret exists
+if ! echo "$ORIG" | grep -q '*' && [ ! -e "$KEYDIR/$RELATIVE_PATH/$ORIG" ]; then
+ echo "Secret not found: $ORIG"
+ exit 1
+fi
+
+# Run move command
+keyringer_exec git "$BASEDIR" mv $ORIG $FILE