rspamd/init
2023-05-17 00:50:22 +10:00

41 lines
808 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
# Set password
[ -n "${RSPAMD_PASSWD}" ] && sed -i -e 's/^#\s*password/ password/' -e "s/@PASSWORD@/${RSPAMD_PASSWD}/" /etc/rspamd/rspamd.conf.local.override
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