32 lines
560 B
Bash
Executable File
32 lines
560 B
Bash
Executable File
#!/bin/bash
|
|
|
|
if [[ "$1" = "-" ]]; then
|
|
pv "$1" | gpg -c
|
|
exit $?
|
|
fi
|
|
|
|
if [[ -z "$1" ]]; then
|
|
echo "File missing, or use -"
|
|
exit 1
|
|
fi
|
|
|
|
if [[ -e "$1".gpg ]]; then
|
|
echo "Target already exists"
|
|
exit 1
|
|
fi
|
|
|
|
echo Creating "$1".gpg
|
|
if [[ -z "$GPGPASS" ]]; then
|
|
pv "$1" | gpg --symmetric -o "$1".gpg || {
|
|
echo ""
|
|
echo "If agent doesnt work, then:"
|
|
echo "Give password with env GPGPASS ( GPGPASS=secret gpg-encrypt $1 )"
|
|
}
|
|
else
|
|
{
|
|
echo "$GPGPASS";
|
|
pv "$1";
|
|
} | \
|
|
gpg -o "$1".gpg --passphrase-fd 0 --batch --yes --symmetric
|
|
fi
|