Welcome!

Please read this important information about Spectre and Meltdown vulnerabilities.
Please read this important information about MX sources lists.

News
  • MX Linux on social media: here
  • Mepis support still here
Current releases
  • MX-17.1 Final release info here
  • antiX-17 release info here
New users
  • Please read this first, and don't forget to add system and hardware information to posts!
  • Read Forum Rules

ClamAV script

Here you can exchange scripts that you created or have permission to share with other users.
Message
Author
User avatar
GDixon
Forum Regular
Forum Regular
Posts: 358
Joined: Fri Nov 02, 2007 4:39 pm

ClamAV script

#1 Postby GDixon » Fri Oct 31, 2014 2:43 pm

Heres something to use clamav from a desktop icon.
I'm working on constants and functions with if else scripting and log files or functions, if anyone has any suggestions on cleaning this script up or improving it let me know. I accept all comments both good and not so good.

This is for the desktop icon

Code: Select all

[Desktop Entry]
Categories=Applications;Utilities;
Comment[en_US]=use clamav to scan TvShows hard drive
Comment=use clamav to scan TvShows hard drive
Exec=/usr/local/bin/avscan
GenericName[en_US]=
GenericName=
Icon=/usr/share/icons/Mine/Clam_icon/Clam.png
MimeType=
Name[en_US]=Scan TvShows
Name=Scan TvShows
Path=
StartupNotify=true
Terminal=true
TerminalOptions=
Type=Application
Version=0.0.1
X-DBUS-ServiceName=
X-DBUS-StartupType=
X-KDE-SubstituteUID=false
X-KDE-Username=



Heres the avscan script

Code: Select all

#!/bin/bash

# Remember to make executable and check permisions

# To scan drives for a virus using ClamAV

# You will need clamav and it's depends installed.

# If you want to make use of any success and or error sounds using ogg or mp3
# I suggest installing mplayer and using it in a script.
# line below will run mplayer in the background avoiding
# mplayers quite verbose output, play the ogg file and close.
#
#     Example : use below in a script making needed changes for your system.
#
# mplayer /usr/share/sounds/clam_ogg/Clam-Success.ogg </dev/null >/dev/null 2>&1 &

# constants

RIGHT_NOW=$(date "+ %a %x %r")
TIME_STAMP="Updated on $RIGHT_NOW by $USER"
NO_DRIVE="Failed to scan: Not plugged in and or mounted"
YIKES="Yikes drive not plugged in and or mounted : Nothing to scan"

# variables

TARGET="/media/TvShows"                # usb 1T HDD
VIRUS="/home/Greg/.VIRUS/"             # directory you want the virus's moved to
HIDE="(hidden directory)"              # uncomment if VIRUS is a hidden directory
SCAN_LOG="/home/Greg/ScanLog/Clam.log" # directory you want the scan log placed


clear

if [ -d $TARGET ]; then

    echo
    echo -e  "Getting ready to scan $TARGET for any viruses\n"
    echo -e  "If any infected files are found they will be\n"
    echo -e  "moved to $VIRUS $HIDE\n"
    echo -e  "Scan Log will be in $SCAN_LOG\n"
    echo -e  "Scan will begin shortly, be patient $USER\n"

clamscan -r --move=$VIRUS $TARGET -l $SCAN_LOG  # clamscan command and arguments/options

# to play a sound script on success uncomment and edit as needed

/usr/local/bin/Clam-Success

# the commands below put stamps at the end of
# the clam.log file each time virusscan script
# runs as "Updated on day, date, time, user"
# the log appending after else gives a fail if no drive

    echo $TIME_STAMP >> $SCAN_LOG    # used when drive/directory is present

sleep 12; clear

# below is used for log when drive is missing or not mounted

else
    echo
    echo -e "$YIKES\n"
    echo >> $SCAN_LOG    # makes a blank line in log (for layout and formatting)
    echo -e "-------------------------------------------------------------------------------\n" >> $SCAN_LOG
    echo -e "----------- SCAN FAILED -----------" >> $SCAN_LOG
    echo $NO_DRIVE >> $SCAN_LOG
    echo $TIME_STAMP >> $SCAN_LOG   
    echo >> $SCAN_LOG    # makes a blank line in log (for layout and formatting)

# to play a sound script on error uncomment and edit as needed

/usr/local/bin/Clam-Error

sleep 4; clear

fi

exit


I'm also working on figuring out a way to get a progress bar instead of all the files output when scanning. clam av gives the options of nothing, infected files found or all. this is a work in progree. any suggestions ?


I have a cool clam icon but it's bigger than 300k , If anyone wants it send an e-mail and I'll send it that way.

Return to “Scripts”

Who is online

Users browsing this forum: No registered users and 1 guest