rspamd/init
2018-07-02 22:13:36 +10:00

27 lines
601 B
Bash
Executable File

#!/bin/bash
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 [ "$1" == "start" ]; then
if [ -z "${NO_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
[ -x /usr/bin/rspamd ] && exec /usr/bin/rspamd -u _rspamd -g _rspamd -c /etc/rspamd/rspamd.conf -f -p /var/run/rspamd.pid &
wait
else
exec $@
fi