#!@SHELL@
#
# Original wrapper by Paul Bijnens
#
# worked by Stefan G. Weichinger
# to enable gpg-encrypted dumps via aespipe
# also worked by Matthieu Lochegnies for server-side encryption

prefix=@prefix@
exec_prefix=@exec_prefix@
sbindir=@sbindir@
AMANDA_HOME=~@CLIENT_LOGIN@

AM_AESPIPE=@sbindir@/amaespipe
AM_PASSPHRASE=$AMANDA_HOME/.am_passphrase
PATH=/usr/bin:/usr/local/bin:/sbin:/usr/sbin
export PATH

AESPIPE=`which aespipe`

if [ $? -ne 0 ] ; then
	echo "amcrypt: aespipe not found in $PATH" >&2
        exit 2
fi

if [ ! -x $AESPIPE ] ; then
        echo "amcrypt: aespipe it's not executable" >&2
        exit 2
fi

if [ ! -x $AM_AESPIPE ] ; then
        echo "amcrypt: $AM_AESPIPE not found or it's not executable"  >&2
        exit 2
fi

$AM_AESPIPE "$@" 3< $AM_PASSPHRASE

rc=$?
exit $rc
