Skip to content

Commit 75dbe04

Browse files
updated bootstrap.sh to include new environment variables CLAM_DELAY and DELAY_CREATE_ONLY
1 parent c43c0de commit 75dbe04

File tree

3 files changed

+86
-19
lines changed

3 files changed

+86
-19
lines changed

alpine/edge/bootstrap.sh

+26-8
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,34 @@ if ! [ -z $HTTPProxyPort ]; then echo "HTTPProxyPort $HTTPProxyPort" >> /etc/c
1212
DB_DIR=$(sed -n 's/^DatabaseDirectory\s\(.*\)\s*$/\1/p' /etc/clamav/freshclam.conf )
1313
DB_DIR=${DB_DIR:-'/var/lib/clamav'}
1414
MAIN_FILE="$DB_DIR/main.cvd"
15-
echo "[bootstrap] Checking for Clam DB in $MAIN_FILE"
1615

17-
if [ ! -f ${MAIN_FILE} ]; then
18-
echo "[bootstrap] Initial clam DB download."
19-
/usr/bin/freshclam
20-
fi
16+
function clam_start () {
17+
if [[ ! -e /var/run/clamav/created ]]
18+
then
19+
touch /var/run/clamav/created
20+
fi
21+
freshclam -d &
22+
echo -e "waiting for clam to update..."
23+
until [[ -e ${MAIN_FILE} ]]
24+
do
25+
:
26+
done
27+
echo -e "starting clamd..."
28+
clamd &
29+
}
2130

22-
# start clam service itself and the updater in background as daemon
23-
freshclam -d &
24-
clamd &
31+
if [[ ! -z "${CLAM_DELAY}" ]]
32+
then
33+
if [[ ! -z "${DELAY_CREATE_ONLY}" && -e /var/run/clamav/created ]]
34+
then
35+
clam_start
36+
else
37+
echo -e "waiting for ${CLAM_DELAY} before starting clamav..."
38+
sleep ${CLAM_DELAY} && clam_start
39+
fi
40+
else
41+
clam_start
42+
fi
2543

2644
# recognize PIDs
2745
pidlist=$(jobs -p)

alpine/main/bootstrap.sh

+26-8
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,34 @@ if ! [ -z $HTTPProxyPort ]; then echo "HTTPProxyPort $HTTPProxyPort" >> /etc/c
1212
DB_DIR=$(sed -n 's/^DatabaseDirectory\s\(.*\)\s*$/\1/p' /etc/clamav/freshclam.conf )
1313
DB_DIR=${DB_DIR:-'/var/lib/clamav'}
1414
MAIN_FILE="$DB_DIR/main.cvd"
15-
echo "[bootstrap] Checking for Clam DB in $MAIN_FILE"
1615

17-
if [ ! -f ${MAIN_FILE} ]; then
18-
echo "[bootstrap] Initial clam DB download."
19-
/usr/bin/freshclam
20-
fi
16+
function clam_start () {
17+
if [[ ! -e /var/run/clamav/created ]]
18+
then
19+
touch /var/run/clamav/created
20+
fi
21+
freshclam -d &
22+
echo -e "waiting for clam to update..."
23+
until [[ -e ${MAIN_FILE} ]]
24+
do
25+
:
26+
done
27+
echo -e "starting clamd..."
28+
clamd &
29+
}
2130

22-
# start clam service itself and the updater in background as daemon
23-
freshclam -d &
24-
clamd &
31+
if [[ ! -z "${CLAM_DELAY}" ]]
32+
then
33+
if [[ ! -z "${DELAY_CREATE_ONLY}" && -e /var/run/clamav/created ]]
34+
then
35+
clam_start
36+
else
37+
echo -e "waiting for ${CLAM_DELAY} before starting clamav..."
38+
sleep ${CLAM_DELAY} && clam_start
39+
fi
40+
else
41+
clam_start
42+
fi
2543

2644
# recognize PIDs
2745
pidlist=$(jobs -p)

debian/buster/bootstrap.sh

+34-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,40 @@ set -m
66
# configure freshclam.conf and clamd.conf from env variables if present
77
source /envconfig.sh
88

9-
# start clam service itself and the updater in background as daemon
10-
freshclam -d &
11-
clamd &
9+
if ! [ -z $HTTPProxyServer ]; then echo "HTTPProxyServer $HTTPProxyServer" >> /etc/clamav/freshclam.conf; fi && \
10+
if ! [ -z $HTTPProxyPort ]; then echo "HTTPProxyPort $HTTPProxyPort" >> /etc/clamav/freshclam.conf; fi && \
11+
12+
DB_DIR=$(sed -n 's/^DatabaseDirectory\s\(.*\)\s*$/\1/p' /etc/clamav/freshclam.conf )
13+
DB_DIR=${DB_DIR:-'/var/lib/clamav'}
14+
MAIN_FILE="$DB_DIR/main.cvd"
15+
16+
function clam_start () {
17+
if [[ ! -e /var/run/clamav/created ]]
18+
then
19+
touch /var/run/clamav/created
20+
fi
21+
freshclam -d &
22+
echo -e "waiting for clam to update..."
23+
until [[ -e ${MAIN_FILE} ]]
24+
do
25+
:
26+
done
27+
echo -e "starting clamd..."
28+
clamd &
29+
}
30+
31+
if [[ ! -z "${CLAM_DELAY}" ]]
32+
then
33+
if [[ ! -z "${DELAY_CREATE_ONLY}" && -e /var/run/clamav/created ]]
34+
then
35+
clam_start
36+
else
37+
echo -e "waiting for ${CLAM_DELAY} before starting clamav..."
38+
sleep ${CLAM_DELAY} && clam_start
39+
fi
40+
else
41+
clam_start
42+
fi
1243

1344
# recognize PIDs
1445
pidlist=$(jobs -p)

0 commit comments

Comments
 (0)