Mint Serena 64 bit using the Mate desktop environment. Most of the following scripts will run on this machine, although some have only been tested with the Gnome desktop. Extra software requirements can be met by the Ubuntu and safe PPA repositories. Scripts may be re-written or added to from time to time, the date serves as the version number. Syntax highlighting on these pages is provided by GVim's "Convert to HTML" option.

Alias scan

# Filename:
# Version: 230411
# Author: robz
# $HOME scanner with "ClamAV" run from a virtual terminal with a bash alias.
# Check first if you've any other programs called scan, try "man scan" to see
# if manual pages exist, If ok add the alias to the bottom of your ~/.bashrc
# file, modify so it's path points to your scripts directory location.
# "alias scan="/home/user/users_scripts/"" save, do "source ~/.bashrc"
# in a terminal to reload the bash configuration, type "scan" to scan.
# Scanning is done recursively on the directory you are in, terminal wise,
# ie. the $PWD - present working directory.
# If this script is likely to be run logged in as another user you'll need to
# be more specific with the path of the sound files.

export DISPLAY=:0                                       # Make sounds work.
LOGFILE="/tmp/ClamAV-$(date +%A-%H:%M).log"             # Make new logfile.
SOUND1=$HOME/Audio/DingLing.wav                         # OK sound.
SOUND2=$HOME/Audio/HyprBlip.wav                         # Warning sound.

echo -e "\n\033[37;1mScanning directory:\033[0m $(pwd)\n"
echo -e "\033[33;1mEnter password to update virus definitions\033[0m"

sudo -k freshclam                                       # Update definitions.
# Scan $PWD, do it nicely! exclude large pre-scanned or encrypted directories
# and, as this runs as user, files not belonging to the user.
nice -n 19 /usr/bin/clamscan -r ${pwd} -l $LOGFILE\
CLAMSCAN=$?                                             # Get exit status.

if [ "$CLAMSCAN" -eq "1" ]; then
    echo -e "\033[31;1m[VIRUS FOUND"\!"]\033[0m"
    /usr/bin/canberra-gtk-play --volume=4 -f $SOUND2 &
elif [ "$CLAMSCAN" -gt "1" ]; then
    echo -e "Scan found errors...\n"$(grep "Access denied" $LOGFILE) | more
    echo -e "\033[34;1m[ERROR $CLAMSCAN]\033[0m"
    /usr/bin/canberra-gtk-play --volume=4 -f $SOUND1 &
else echo -e "\033[32;1mNo virus found :)\033[0m"
    /usr/bin/canberra-gtk-play --volume=4 -f $SOUND1 &

echo -e "\033[1mFor scan details see logfile at $LOGFILE.\033[0m\n"

No comments: