rspamd/init
2023-06-04 16:36:44 +10:00

45 lines
927 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
if [ -n "${SPAMHAUS_DQS_KEY}" ]; then
mv /usr/local/dqs/rbl.conf /usr/local/dqs/rbl_group.conf /etc/rspamd/local.d
mv /usr/local/dqs/rspamd.local.lua /etc/rspamd
sed -i -e "s/your_DQS_key/${SPAMHAUS_DQS_KEY}/g" /etc/rspamd/local.d/rbl*.conf /etc/rspamd/rspamd.local.lua
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