38 lines
644 B
Bash
Executable File
38 lines
644 B
Bash
Executable File
#!/bin/sh
|
|
set -e
|
|
|
|
NAME="RSPAMD"
|
|
CLAMAV="clamav"
|
|
WAIT=15
|
|
TRIES=5
|
|
|
|
function stop {
|
|
echo "Stopping ${NAME}"
|
|
kill $(cat /var/run/rspamd.pid)
|
|
}
|
|
|
|
trap 'stop' SIGTERM
|
|
|
|
if [ -z "$@" ]; then
|
|
if [ -n "${ENABLE_CLAMAV}" ]; then
|
|
x=0;
|
|
until ping -c1 ${CLAMAV} &>/dev/null; do
|
|
echo "Waiting for [${CLAMAV}]...";
|
|
let x=$x+1;
|
|
if [ $x -ge ${TRIES} ]; then
|
|
NOTON=1;
|
|
break;
|
|
fi
|
|
sleep ${WAIT};
|
|
done
|
|
[ -n "${NOTON}" ] && echo "No [${CLAMAV}]?" && exit 1
|
|
fi
|
|
|
|
mkdir -p /run/rspamd
|
|
[ -x /usr/bin/rspamd ] && exec /usr/bin/rspamd -u rspamd -g rspamd -c /etc/rspamd/rspamd.conf -f -p /run/rspamd/rspamd.pid &
|
|
|
|
wait
|
|
else
|
|
exec $@
|
|
fi
|