Skip to content

Commit

Permalink
Test NC with newer version/enable proxy usage
Browse files Browse the repository at this point in the history
  • Loading branch information
asteel-gsa committed Nov 21, 2024
1 parent a2f2007 commit f3bf935
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 14 deletions.
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ COPY --from=build /go/src/clamav-rest/clamav-rest /usr/bin/
# Update & Install tzdata
RUN apk update && apk upgrade && apk add --no-cache tzdata

# Update & Install netcat-openbsd
RUN apk update && apk upgrade && apk add --no-cache netcat-openbsd

# Enable Bash & logrotate
RUN apk add bash logrotate

Expand Down
50 changes: 36 additions & 14 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,42 @@ if [ -z "$(ls -A /clamav/data)" ]; then
cp /var/lib/clamav/* /clamav/data/
fi

(
freshclam --config-file=/clamav/etc/freshclam.conf --daemon &
clamd --config-file=/clamav/etc/clamd.conf &
/usr/bin/clamav-rest &
# Force reload the virus database through the clamd socket after 120s.
# Starting freshclam and clamd async ends up that a newer database version is loaded with
# freshclam, but the clamd still keep the old version existing before the update because
# the socket from clamd is not yet ready to inform, what is indicated in the log
# during the startup of the container (WARNING: Clamd was NOT notified: Can't connect to clamd through /run/clamav/clamd.sock: No such file or directory).
# So only if a newer database version is available clamd will be notified next time, and this can take hours/days.
# Remarks: The socket port is configured in the .Dockerfile itself.
sleep 120s
echo "RELOAD" | nc 127.0.0.1 3310 &
) 2>&1 | tee -a /var/log/clamav/clamav.log
if [ -n "$PROXY_PORT" ]; then
echo "Proxy Detected: $PROXY_SERVER with port $PROXY_PORT"
(
freshclam --config-file=/clamav/etc/freshclam.conf --daemon &
clamd --config-file=/clamav/etc/clamd.conf &
/usr/bin/clamav-rest &
# Force reload the virus database through the clamd socket after 120s.
# Starting freshclam and clamd async ends up that a newer database version is loaded with
# freshclam, but the clamd still keep the old version existing before the update because
# the socket from clamd is not yet ready to inform, what is indicated in the log
# during the startup of the container (WARNING: Clamd was NOT notified: Can't connect to clamd through /run/clamav/clamd.sock: No such file or directory).
# So only if a newer database version is available clamd will be notified next time, and this can take hours/days.
# Remarks: The socket port is configured in the .Dockerfile itself.
sleep 60s
echo "RELOAD" | nc -X connect -x "$PROXY_SERVER":"$PROXY_PORT" 127.0.0.1 3310 &
#echo "RELOAD" | nc 127.0.0.1 3310 &
) 2>&1 | tee -a /var/log/clamav/clamav.log
else
echo "No Proxy Detected"
(
freshclam --config-file=/clamav/etc/freshclam.conf --daemon &
clamd --config-file=/clamav/etc/clamd.conf &
/usr/bin/clamav-rest &
# Force reload the virus database through the clamd socket after 120s.
# Starting freshclam and clamd async ends up that a newer database version is loaded with
# freshclam, but the clamd still keep the old version existing before the update because
# the socket from clamd is not yet ready to inform, what is indicated in the log
# during the startup of the container (WARNING: Clamd was NOT notified: Can't connect to clamd through /run/clamav/clamd.sock: No such file or directory).
# So only if a newer database version is available clamd will be notified next time, and this can take hours/days.
# Remarks: The socket port is configured in the .Dockerfile itself.
sleep 60s
#echo "RELOAD" | nc -X connect -x $PROXY_SERVER:$PROXY_PORT 127.0.0.1 3310 &
echo "RELOAD" | nc 127.0.0.1 3310 &
) 2>&1 | tee -a /var/log/clamav/clamav.log
fi



pids=`jobs -p`
Expand Down

0 comments on commit f3bf935

Please sign in to comment.