Add Multi Targets
Signed-off-by: Patrick Niebeling <patrick.niebeling@adacor.com>
This commit is contained in:
28
rspamd-learn-ham-multi.sh
Normal file
28
rspamd-learn-ham-multi.sh
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#!/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/learnham" "http://otherhost:11334/learnham")
|
||||||
|
PASSWORD="p455w0rD"
|
||||||
|
|
||||||
|
|
||||||
|
for SERVER in ${SERVER_LIST[@]}; do
|
||||||
|
log "Trying to report ham 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 "Ham reported to ${SERVER}: ${RETURN}"
|
||||||
|
#exit 0
|
||||||
|
else
|
||||||
|
log_error "Reporting SPAM failed ${SERVERS[@]}"
|
||||||
|
if [ $STATUS -eq 28 ]; then
|
||||||
|
log_error "Reporting Ham to ${SERVER} failed: Connection timed out."
|
||||||
|
else
|
||||||
|
log_error "Reporting Ham to ${SERVER} failed: CURL exit status ${STATUS}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
exit 1
|
@ -8,24 +8,24 @@ MAIL=$(tee)
|
|||||||
SERVER_LIST="['10.10.115.15', '10.10.115.16']"
|
SERVER_LIST="['10.10.115.15', '10.10.115.16']"
|
||||||
PASSWORD="p455w0rD"
|
PASSWORD="p455w0rD"
|
||||||
|
|
||||||
SERVERS=($(python -c "from random import shuffle; server=${SERVER_LIST}; shuffle(server); print(' '.join(server))"))
|
SERVERS=($(python3 -c "from random import shuffle; server=${SERVER_LIST}; shuffle(server); print(' '.join(server))"))
|
||||||
|
|
||||||
|
|
||||||
for SERVER in ${SERVERS[@]}; do
|
for SERVER in ${SERVERS[@]}; do
|
||||||
log "Trying to report spam to ${SERVER}"
|
log "Trying to report ham to ${SERVER}"
|
||||||
RETURN=$(/usr/bin/curl -s --connect-timeout 1 -H "Password: ${PASSWORD}" --data-binary --url "http://${SERVER}:11334/learnham" -d "${MAIL}")
|
RETURN=$(/usr/bin/curl -s --connect-timeout 1 -H "Password: ${PASSWORD}" --data-binary --url "http://${SERVER}:11334/learnham" -d "${MAIL}")
|
||||||
STATUS=$?
|
STATUS=$?
|
||||||
if [ $STATUS -eq 0 ]; then
|
if [ $STATUS -eq 0 ]; then
|
||||||
log "Spam reported to ${SERVER}: ${RETURN}"
|
log "HAM reported to ${SERVER}: ${RETURN}"
|
||||||
exit 0
|
exit 0
|
||||||
else
|
else
|
||||||
if [ $STATUS -eq 28 ]; then
|
if [ $STATUS -eq 28 ]; then
|
||||||
log_error "Reporting SPAM to ${SERVER} failed: Connection timed out."
|
log_error "Reporting HAM to ${SERVER} failed: Connection timed out."
|
||||||
else
|
else
|
||||||
log_error "Reporting SPAM to ${SERVER} failed: CURL exit status ${STATUS}"
|
log_error "Reporting HAM to ${SERVER} failed: CURL exit status ${STATUS}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
log_error "Reporting SPAM failed ${SERVERS[@]}"
|
log_error "Reporting HAM failed ${SERVERS[@]}"
|
||||||
exit 1
|
exit 1
|
28
rspamd-learn-spam-multi.sh
Normal file
28
rspamd-learn-spam-multi.sh
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#!/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
|
Reference in New Issue
Block a user