Files
rspamd-learn/rspamd-learn-spam-multi.sh
Patrick Niebeling cd3a5891e6 Add Multi Targets
Signed-off-by: Patrick Niebeling <patrick.niebeling@adacor.com>
2022-02-28 15:11:13 +01:00

28 lines
897 B
Bash

#!/bin/bash
function log_error() { echo `date '+%Y-%m-%d %H:%M:%S'` ERROR: $1 >&2; }
function log() { echo `date '+%Y-%m-%d %H:%M:%S'` INFO: $1; }
MAIL=$(tee)
SERVER_LIST=("http://localhost:11334/learnspam" "http://otherhost:11334/learnspam")
PASSWORD="p455w0rD"
for SERVER in ${SERVER_LIST[@]}; do
log "Trying to report spam to ${SERVER}"
RETURN=$(/usr/bin/curl -s --connect-timeout 1 -H "Password: ${PASSWORD}" --data-binary --url "${SERVER}" -d "${MAIL}")
STATUS=$?
if [ $STATUS -eq 0 ]; then
log "Spam reported to ${SERVER}: ${RETURN}"
#exit 0
else
log_error "Reporting SPAM failed ${SERVERS[@]}"
if [ $STATUS -eq 28 ]; then
log_error "Reporting SPAM to ${SERVER} failed: Connection timed out."
else
log_error "Reporting SPAM to ${SERVER} failed: CURL exit status ${STATUS}"
fi
fi
done
exit 1