Spaces:
Sleeping
Sleeping
pengdaqian
commited on
Commit
•
18a38eb
1
Parent(s):
e0eb42c
change
Browse files
init
CHANGED
@@ -83,91 +83,4 @@ else
|
|
83 |
exec tail -f "/dev/null"
|
84 |
fi
|
85 |
|
86 |
-
exit 0
|
87 |
-
/ $ cat /init
|
88 |
-
#!/sbin/tini /bin/sh
|
89 |
-
# SPDX-License-Identifier: GPL-2.0-or-later
|
90 |
-
#
|
91 |
-
# Copyright (C) 2021 Olliver Schinagl <oliver@schinagl.nl>
|
92 |
-
# Copyright (C) 2021-2022 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
|
93 |
-
#
|
94 |
-
# A beginning user should be able to docker run image bash (or sh) without
|
95 |
-
# needing to learn about --entrypoint
|
96 |
-
# https://github.com/docker-library/official-images#consistency
|
97 |
-
|
98 |
-
set -eu
|
99 |
-
|
100 |
-
if [ ! -d "/run/clamav" ]; then
|
101 |
-
install -d -g "clamav" -m 775 -o "clamav" "/run/clamav"
|
102 |
-
fi
|
103 |
-
|
104 |
-
# Assign ownership to the database directory, just in case it is a mounted volume
|
105 |
-
#chown -R clamav:clamav /var/lib/clamav
|
106 |
-
|
107 |
-
# run command if it is not starting with a "-" and is an executable in PATH
|
108 |
-
if [ "${#}" -gt 0 ] && \
|
109 |
-
[ "${1#-}" = "${1}" ] && \
|
110 |
-
command -v "${1}" > "/dev/null" 2>&1; then
|
111 |
-
# Ensure healthcheck always passes
|
112 |
-
CLAMAV_NO_CLAMD="true" exec "${@}"
|
113 |
-
else
|
114 |
-
if [ "${#}" -ge 1 ] && \
|
115 |
-
[ "${1#-}" != "${1}" ]; then
|
116 |
-
# If an argument starts with "-" pass it to clamd specifically
|
117 |
-
exec clamd "${@}"
|
118 |
-
fi
|
119 |
-
# else default to running clamav's servers
|
120 |
-
|
121 |
-
# Help tiny-init a little
|
122 |
-
mkdir -p "/run/lock"
|
123 |
-
ln -f -s "/run/lock" "/var/lock"
|
124 |
-
|
125 |
-
# Ensure we have some virus data, otherwise clamd refuses to start
|
126 |
-
if [ ! -f "/var/lib/clamav/main.cvd" ]; then
|
127 |
-
echo "Updating initial database"
|
128 |
-
freshclam --foreground --stdout
|
129 |
-
fi
|
130 |
-
|
131 |
-
if [ "${CLAMAV_NO_FRESHCLAMD:-false}" != "true" ]; then
|
132 |
-
echo "Starting Freshclamd"
|
133 |
-
freshclam \
|
134 |
-
--checks="${FRESHCLAM_CHECKS:-1}" \
|
135 |
-
--daemon \
|
136 |
-
--foreground \
|
137 |
-
--stdout \
|
138 |
-
--user="clamav" \
|
139 |
-
&
|
140 |
-
fi
|
141 |
-
|
142 |
-
if [ "${CLAMAV_NO_CLAMD:-false}" != "true" ]; then
|
143 |
-
echo "Starting ClamAV"
|
144 |
-
if [ -S "/run/clamav/clamd.sock" ]; then
|
145 |
-
unlink "/run/clamav/clamd.sock"
|
146 |
-
fi
|
147 |
-
if [ -S "/tmp/clamd.sock" ]; then
|
148 |
-
unlink "/tmp/clamd.sock"
|
149 |
-
fi
|
150 |
-
clamd --foreground &
|
151 |
-
while [ ! -S "/run/clamav/clamd.sock" ] && [ ! -S "/tmp/clamd.sock" ]; do
|
152 |
-
if [ "${_timeout:=0}" -gt "${CLAMD_STARTUP_TIMEOUT:=1800}" ]; then
|
153 |
-
echo
|
154 |
-
echo "Failed to start clamd"
|
155 |
-
exit 1
|
156 |
-
fi
|
157 |
-
printf "\r%s" "Socket for clamd not found yet, retrying (${_timeout}/${CLAMD_STARTUP_TIMEOUT}) ..."
|
158 |
-
sleep 1
|
159 |
-
_timeout="$((_timeout + 1))"
|
160 |
-
done
|
161 |
-
echo "socket found, clamd started."
|
162 |
-
fi
|
163 |
-
|
164 |
-
if [ "${CLAMAV_NO_MILTERD:-true}" != "true" ]; then
|
165 |
-
echo "Starting clamav milterd"
|
166 |
-
clamav-milter &
|
167 |
-
fi
|
168 |
-
|
169 |
-
# Wait forever (or until canceled)
|
170 |
-
exec tail -f "/dev/null"
|
171 |
-
fi
|
172 |
-
|
173 |
exit 0
|
|
|
83 |
exec tail -f "/dev/null"
|
84 |
fi
|
85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
exit 0
|