This commit is contained in:
Junxiang Huang 2024-04-24 16:28:09 +08:00
parent b9baacaa88
commit 90be33d226
2 changed files with 0 additions and 189 deletions

View File

@ -1,148 +0,0 @@
# Run ClamAV as a Daemon
## For Ubuntu 16.04
### Install clamav-daemon & clamav-freshclam
```
apt-get install clamav-daemon clamav-freshclam
```
You should run Clamd with a root permission to scan any files.
Edit the conf `/etc/clamav/clamd.conf`,change the following line:
```
LocalSocketGroup root
User root
```
### Start the clamav-daemon
```
systemctl start clamav-daemon
```
* Test the software
```
$ curl https://www.eicar.org/download/eicar.com.txt | clamdscan -
```
The output must include:
```
stream: Eicar-Test-Signature FOUND
```
## For CentOS 7
### Install Clamd
```
yum install epel-release
yum install clamav-server clamav-data clamav-filesystem clamav-lib clamav-update clamav clamav-devel
```
### Run freshclam
* Configure the freshclam to updating database
```
cp /etc/freshclam.conf /etc/freshclam.conf.bak
sed -i '/^Example/d' /etc/freshclam.conf
```
* Create the init script
```
cat > /usr/lib/systemd/system/clam-freshclam.service << 'EOF'
# Run the freshclam as daemon
[Unit]
Description = freshclam scanner
After = network.target
[Service]
Type = forking
ExecStart = /usr/bin/freshclam -d -c 4
Restart = on-failure
PrivateTmp = true
[Install]
WantedBy=multi-user.target
EOF
```
* Boot up
```
systemctl enable clam-freshclam.service
systemctl start clam-freshclam.service
```
### Configure Clamd
```
cp /usr/share/clamav/template/clamd.conf /etc/clamd.conf
sed -i '/^Example/d' /etc/clamd.conf
```
You should run Clamd with a root permission to scan any files.
Edit the `/etc/clamd.conf`,change the following line:
```
User root
...
LocalSocket /var/run/clamd.sock
```
### Run Clamd
* Create the init script
```
cat > /etc/init.d/clamd << 'EOF'
case "$1" in
start)
echo -n "Starting Clam AntiVirus Daemon... "
/usr/sbin/clamd
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/clamd
;;
stop)
echo -n "Stopping Clam AntiVirus Daemon... "
pkill clamd
rm -f /var/run/clamav/clamd.sock
rm -f /var/run/clamav/clamd.pid
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/clamd
;;
esac
EOF
```
```
chmod +x /etc/init.d/clamd
```
* Boot up
```
chkconfig clamd on
service clamd start
```
* Test the software
```
$ curl https://www.eicar.org/download/eicar.com.txt | clamdscan -
```
The output must include:
```
stream: Eicar-Test-Signature FOUND
```

View File

@ -1,41 +0,0 @@
# Deploy Clamav with Docker
## Add Clamav to docker-compose.yml
The following section needs to be added to docker-compose.yml in the services section
```yml
services:
...
av:
image: mkodockx/docker-clamav:alpine
container_name: seafile-clamav
networks:
- seafile-net
```
## Modify seafile.conf
Add this to seafile.conf
```conf
[virus_scan]
scan_command = clamdscan
virus_code = 1
nonvirus_code = 0
scan_interval = 5
scan_size_limit = 20
threads = 2
```
## Restart docker container
```shell
docker compose down
docker compose up -d
```
Wait some minutes until Clamav finished initializing.
Now Clamav can be used.