PATH=$PATH:/usr/local/bin
export PATH
TempDir="/tmp/clamav.$$"
ClamUser="clamav"
ClamGroup="clamav"
ExtraScanOptions='-d 10.0.3.3'
echo $ExtraScanOptions
ClamScan=$1/bin/clamd-stream-client
shift
if [ ! -x $ClamScan ]; then
ClamScan=/usr/local/bin/clamd-stream-client
fi
if [ "x$1" = "x-IsItInstalled" ]; then
[ -x $ClamScan ] && exit 0
exit 1
fi
# Check if the tmpdir exists, if so delete so we start with a clean slate
if [ -x "${TempDir}" ]; then
rm -rf ${TempDir} >/dev/null 2>&1
fi
# Make the Temp dir
umask 0077
mkdir "${TempDir}" >/dev/null 2>&1
# In case we get interupted....
trap "rm -rf ${TempDir}" EXIT
if [ $? ]; then
ExtraScanOptions="$ExtraScanOptions --tempdir=${TempDir}"
# If we are root chown it to the clamav user/group
if [ `whoami` = "root" ]; then
chown ${ClamUser}:${ClamGroup} "${TempDir}"
fi
fi
$ClamScan "$ExtraScanOptions" < "$@"
retval=$?
#Clean up the temp directory
if [ -x "${TempDir}" ]; then
rm -rf ${TempDir}
fi
trap '' EXIT
if [ "$retval" = "40" ]; then
# Clam complained we passed an illegal command-line option
# (As this calls without external unpackers the temp dir isn't used)
echo "gi"
exec $ClamScan "$ExtraScanOptions" "$@"
else
exit $retval
fi