-
Notifications
You must be signed in to change notification settings - Fork 0
/
scan-clamav.sh
executable file
·61 lines (54 loc) · 1.89 KB
/
scan-clamav.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env bash
if ! command -v clamdscan >/dev/null 2>&1 && ! command -v clamscan >/dev/null 2>&1; then
kdialog --title "ClamAV not installed!" --sorry "<b>ClamAV not installed.</b><br>Please consider installing it to use this functionality."
exit 1
fi
if ! command -v kdialog >/dev/null 2>&1 ; then
if ! command -v notify-send >/dev/null 2>&1; then
printf "'kdialog' and 'notify-send' Not installed.\nPlease consider installing it to use this functionality.\n"
exit 2
else
notify_util="notify-send"
fi
else
notify_util="kdialog"
fi
function msg_ok() {
if [ "$notify_util" == "kdialog" ]; then
kdialog --title "ClamAV Scan Results" --msgbox "<b>No virus found :)</b>"
else
notify-send -a "ClamAV Scan Results" -u normal -t 5000 -i "dialog-information" "ClamAV Scan Results" "<b>No virus found :)</b>"
fi
}
function msg_found() {
if [ "$notify_util" == "kdialog" ]; then
kdialog --title "ClamAV Scan Results: Virus(es) Found!" --detailederror "<b>Virus(es) Found</b>" "$1"
else
notify-send -a "ClamAV Scan Results" -u normal -t 10000 -a -i "dialog-warning" "ClamAV Scan Results" "<b>Virus(es) Found</b>"
fi
}
function msg_error() {
if [ "$notify_util" == "kdialog" ]; then
kdialog --title "ClamAV Scan Results: Error(s) Occurred!" --detailederror "<b>Some error(s) occurred!</b>" "$1"
else
notify-send -a "ClamAV Scan Results" -u normal -t 7500 -i "dialog-error" "ClamAV Scan Results" "<b>Some error(s) occurred!</b>"
fi
}
# 0: no virus found
# 1: Virus(es) found
# 2: Some error(s) occurred
if pgrep clamd >/dev/null 2>&1; then
summary=$(clamdscan --fdpass -imz "$@")
r=$?
else
# this mush slower than using clamdscan
summary=$(clamscan -irz "$@")
r=$?
fi
if [ $r -eq 0 ]; then
msg_ok
elif [ $r -eq 1 ]; then
msg_found "$summary"
else
msg_error "$summary"
fi