#!/bin/sh
#
# 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=/usr
exec_prefix=/usr
sbindir=/usr/sbin
AMANDA_HOME=~amanda

AM_AESPIPE=/usr/sbin/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
