Commit 20125ba1 authored by Silvio Rhatto's avatar Silvio Rhatto
Browse files

New action 'cp' (2)

parent cb21ca66
#!/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"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment