-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FROM artifacts.developer.gov.bc.ca/docker-remote/clamav:1.2 | ||
RUN freshclam | ||
COPY "clamav/scripts/docker-entrypoint-unprivileged.sh" "/init" | ||
RUN chmod +x /init |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FROM clamav/clamav:1.2 | ||
RUN freshclam | ||
COPY "clamav/scripts/docker-entrypoint-unprivileged.sh" "/init" | ||
RUN chmod +x /init |
73 changes: 73 additions & 0 deletions
73
sources/packages/clamav/scripts/docker-entrypoint-unprivileged.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#!/sbin/tini /bin/sh | ||
# shellcheck shell=sh | ||
# SPDX-License-Identifier: GPL-2.0-or-later | ||
# | ||
# Copyright (C) 2021 Olliver Schinagl <[email protected]> | ||
# Copyright (C) 2021-2022 Cisco Systems, Inc. and/or its affiliates. All rights reserved. | ||
# | ||
# A beginning user should be able to docker run image bash (or sh) without | ||
# needing to learn about --entrypoint | ||
# https://github.com/docker-library/official-images#consistency | ||
|
||
set -eu | ||
|
||
# run command if it is not starting with a "-" and is an executable in PATH | ||
if [ "${#}" -gt 0 ] && | ||
[ "${1#-}" = "${1}" ] && | ||
command -v "${1}" >"/dev/null" 2>&1; then | ||
# Ensure healthcheck always passes | ||
CLAMAV_NO_CLAMD="true" exec "${@}" | ||
else | ||
if [ "${#}" -ge 1 ] && | ||
[ "${1#-}" != "${1}" ]; then | ||
# If an argument starts with "-" pass it to clamd specifically | ||
exec clamd "${@}" | ||
fi | ||
# else default to running clamav's servers | ||
|
||
# Ensure we have some virus data, otherwise clamd refuses to start | ||
if [ ! -f "/var/lib/clamav/main.cvd" ]; then | ||
echo "Updating initial database" | ||
freshclam --foreground --stdout | ||
fi | ||
|
||
if [ "${CLAMAV_NO_FRESHCLAMD:-false}" != "true" ]; then | ||
echo "Starting Freshclamd" | ||
freshclam \ | ||
--checks="${FRESHCLAM_CHECKS:-1}" \ | ||
--daemon \ | ||
--foreground \ | ||
--stdout \ | ||
--user="clamav" \ | ||
& | ||
fi | ||
|
||
if [ "${CLAMAV_NO_CLAMD:-false}" != "true" ]; then | ||
echo "Starting ClamAV" | ||
if [ -S "/tmp/clamd.sock" ]; then | ||
unlink "/tmp/clamd.sock" | ||
fi | ||
clamd --foreground & | ||
while [ ! -S "/tmp/clamd.sock" ]; do | ||
if [ "${_timeout:=0}" -gt "${CLAMD_STARTUP_TIMEOUT:=1800}" ]; then | ||
echo | ||
echo "Failed to start clamd" | ||
exit 1 | ||
fi | ||
printf "\r%s" "Socket for clamd not found yet, retrying (${_timeout}/${CLAMD_STARTUP_TIMEOUT}) ..." | ||
sleep 1 | ||
_timeout="$((_timeout + 1))" | ||
done | ||
echo "socket found, clamd started." | ||
fi | ||
|
||
if [ "${CLAMAV_NO_MILTERD:-true}" != "true" ]; then | ||
echo "Starting clamav milterd" | ||
clamav-milter & | ||
fi | ||
|
||
# Wait forever (or until canceled) | ||
exec tail -f "/dev/null" | ||
fi | ||
|
||
exit 0 |