Skip to content

Instantly share code, notes, and snippets.

@rxw1
Created May 30, 2017 14:55
Show Gist options
  • Save rxw1/95ae822a990e6b82051607012047d85f to your computer and use it in GitHub Desktop.
Save rxw1/95ae822a990e6b82051607012047d85f to your computer and use it in GitHub Desktop.
clamscan wrapper
function now () {
if [[ $1 == "Y" ]]
then
shift
y="%Y"
else
y="%y"
fi
case $1 in
(h) shift
date +$y${+3:-$1}%m${+3:-$1}%d${+2:-$1}%H ;;
(m) shift
date +$y${+3:-$1}%m${+3:-$1}%d${+2:-$1}%H$1%M ;;
(s) shift
date +$y${+3:-$1}%m${+3:-$1}%d${+2:-$1}%H$1%M$1%S ;;
(*) date +${y}${+3:-$1}%m${+3:-$1}%d ;;
esac
}
function virusscan () {
if [[ $1 == "." ]]
then
echo "Please give a full path ($PWD) as argument"
return 1
fi
a=${1//\//-}
date=$(now s "" _)
tmpdir=/tmp/clamscan-infected$a-$date
logfile=clamscan$a-$(now s "" _).log
mkdir $tmpdir
if [[ -f $logfile ]]
then
echo "Logfile exists"
return 1
fi
clamscan -r --bell -i / --move=$tmpdir --log=$logfile $1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment