Account name:
Password
(OpenID?)
(Forgot it?)
Remember Me
You're viewing
jpnix
's journal
Create a Dreamwidth Account
Learn More
Interest
Region
Site and Account
FAQ
Email
Reload page in style:
light
Navigation
Recent Entries
Archive
Reading
Tags
Memories
Profile
James Permenter
Entries tagged with script
ClamAV automated install
May
.
22nd
,
2016
09:01 pm
There are a few moving parts to getting ClamAV installed and set up correctly to scan weekly so I threw together a useful script that does it automatically on any redhat based machine.
#!/bin/bash DIRTOSCAN="/home /var/spool /bin /sbin"; SCANDIR=/opt/company/scans/ GREEN=$(tput setaf 2) RESET=$(tput sgr0) function clamav_install () { echo -e "${GREEN}Installing and configuring ClamAV antivirus${RESET}" echo "" yum -y install clamav yum -y install clamav-update echo -e "${GREEN}Creating scan directory /opt/phishlabs/scans${RESET}" echo "" mkdir /opt/phishlabs/scans change_clamav_config echo -e "${GREEN}Updating the virus signature database. (This could take some time)${RESET}" /usr/bin/freshclam } function setup_autoscan () { echo -e "${GREEN}Creating autoscan script${RESET}" cat >/opt/company/scripts/virscan.sh <<EOF1 #!/bin/bash /usr/bin/freshclam for i in $DIRTOSCAN; do /usr/bin/clamscan -rv $DIRTOSCAN > $SCANDIR$HOSTNAME.$(date +%y%m%d); done EOF1 chmod +x /opt/company/scripts/virscan.sh echo -e "${GREEN}Adding script to root crontab${RESET}" COMMENT="#This is the virus scan script from ClamAV" LINE="0 0 * * 0 /opt/phishlabs/scripts/virscan.sh" SPACE=" " (crontab -u root -l; echo "$COMMENT"; echo "$LINE"; echo "$SPACE" ) | crontab -u root - } function change_clamav_config () { echo -e "${GREEN}Changing configuration to allow DB update${RESET}" sed -i 's/Example/#Example/g' /etc/freshclam.conf sed -i 's/FRESHCLAM_DELAY=disabled-warn/#FRESHCLAM_DELAY=disabled-warn/g' /etc/sysconfig/freshclam } function main() { clamav_install setup_autoscan } main echo -e "${GREEN}ClamAV installed and configured successfully for automated scanning${RESET}" exit
Profile
JPNIX
January
2023
S
M
T
W
T
F
S
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
Syndicate
Most Popular Tags
amazon
-
1 use
animation
-
1 use
attiny
-
1 use
avr
-
1 use
aws
-
6 uses
base64
-
1 use
bash
-
8 uses
bepush
-
1 use
c
-
2 uses
c++
-
1 use
cat
-
1 use
cloud
-
2 uses
cyber security
-
2 uses
debian
-
1 use
devops
-
2 uses
electronics
-
1 use
facebook
-
1 use
firefox
-
1 use
geoblock
-
1 use
hids
-
1 use
hpc
-
1 use
infrastructure
-
2 uses
interview
-
1 use
job
-
2 uses
linux
-
15 uses
monitoring
-
2 uses
nagios
-
2 uses
nrel
-
1 use
openbox
-
1 use
opensuse
-
1 use
phish
-
2 uses
plymouth
-
1 use
policy
-
1 use
pop-os
-
1 use
programming
-
2 uses
qt
-
1 use
scripting
-
1 use
security
-
2 uses
servers
-
1 use
shell script
-
1 use
sof
-
1 use
splash
-
1 use
supercomputer
-
1 use
sysadmin
-
1 use
tinkering
-
1 use
token theft
-
1 use
top500
-
1 use
work
-
1 use
workaround
-
1 use
workspaces
-
1 use
Page Summary
ClamAV automated install
Style Credit
Style:
Retro
for
Patsy
by
sforzinda
Expand Cut Tags
No cut tags
Page generated Oct. 8th, 2025 04:10 am
Powered by
Dreamwidth Studios