#!/bin/bash

for arg in $@; do
  if [ "$arg" = "--help" -o "$arg" = "-h" -o "$arg" = "-?" ]; then
    argHelp="1"
  elif [ "$arg" = "--update" -o "$arg" = "-u" ]; then
    argUpdate="1"
  fi
done

if [ "$argHelp" = "1" ]; then
  echo
  echo 'Usage: avscan [filepath/directory]'
  echo
  echo 'Leave [filepath/directory] blank to scan current directory (i.e. $PWD)'
  echo
  echo '[--help -h -?]    show this list'
  echo '[--update -u]     update aspiesoft-clamav-scanner'
  echo
  exit
elif [ "$argUpdate" = "1" ]; then
  bash /etc/aspiesoft-clamav-scanner/update.sh
  exit
fi

local scanDir="$1"
if [ "$scanDir" = "" ]; then
  scanDir="$PWD"
fi

nice -n 15 clamscan -r --bell --move="/VirusScan/quarantine" --exclude-dir="/VirusScan/quarantine" --exclude-dir="/home/*/.clamtk/viruses" --exclude-dir="smb4k" --exclude-dir="/run/user/*/gvfs" --exclude-dir="/home/*/.gvfs" --exclude-dir=".thunderbird" --exclude-dir=".mozilla-thunderbird" --exclude-dir=".evolution" --exclude-dir="Mail" --exclude-dir="kmail" --exclude-dir="^/sys" "$scanDir"
