diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2014-08-21 17:16:45 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2014-08-21 17:16:45 -0300 |
commit | cffe8137d024091d0f1bee9c2484c28d2986febc (patch) | |
tree | 8510b026f614e87d551d12bfdfcec9113b5d995e /lib/keyringer/actions | |
parent | e61a77485989f9237fbf410df7daf5ed7f1b880b (diff) | |
parent | 4bc8b8e6fa81c38ce8c76027074feef1c7f69530 (diff) | |
download | keyringer-cffe8137d024091d0f1bee9c2484c28d2986febc.tar.gz keyringer-cffe8137d024091d0f1bee9c2484c28d2986febc.tar.bz2 |
Merge branch 'release/0.3.7'0.3.7
Diffstat (limited to 'lib/keyringer/actions')
-rwxr-xr-x | lib/keyringer/actions/cp | 33 | ||||
-rwxr-xr-x | lib/keyringer/actions/edit | 4 |
2 files changed, 35 insertions, 2 deletions
diff --git a/lib/keyringer/actions/cp b/lib/keyringer/actions/cp new file mode 100755 index 0000000..0629b61 --- /dev/null +++ b/lib/keyringer/actions/cp @@ -0,0 +1,33 @@ +#!/bin/bash +# +# Copy secrets. +# + +# Load functions +LIB="`dirname $0`/../functions" +source "$LIB" || exit 1 + +# Aditional parameters +CWD="`pwd`" + +# 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 +cd "$KEYDIR" && cp -a "./$RELATIVE_PATH/$ORIG" "./$FILE" +keyringer_exec git "$BASEDIR" add "keys/$FILE" +cd "$CWD" diff --git a/lib/keyringer/actions/edit b/lib/keyringer/actions/edit index a5f14d4..c9f3f12 100755 --- a/lib/keyringer/actions/edit +++ b/lib/keyringer/actions/edit @@ -59,9 +59,9 @@ wait echo "Press any key when done using the file and you're sure that $APPNAME is closed." read -s -n 1 -# Encrypt again +# Encrypt again. Unset RELATIVE_PATH as it was already used to determine FILE path export KEYRINGER_ADD_EXTENSION=false -keyringer_exec encrypt "$BASEDIR" "$FILE" "$TMPWORK" +RELATIVE_PATH="" keyringer_exec encrypt "$BASEDIR" "$FILE" "$TMPWORK" # Check exit status errcrypt="$?" |