Mise à jour de 'src/bash/filter.sh'

This commit is contained in:
fab 2023-10-21 02:07:06 +02:00
parent 4c61cf5c81
commit 3ac1bec5d9

View File

@ -73,17 +73,17 @@ ARCHIVE_TITLE="archive_content"
ARCHIVE_MIME="text/kaz_email_archive" ARCHIVE_MIME="text/kaz_email_archive"
SKIP_DEST_DOMAIN="/tmp/docker-mailserver/dest-domain-no-depol.txt" SKIP_DEST_DOMAIN="/tmp/docker-mailserver/dest-domain-no-depol.txt"
KEEP_FAILED=true KEEP_FAILED=true
DEBUG= DEBUG=true
#################### FONCTIONS ############################################ #################### FONCTIONS ############################################
BOLD='' BOLD='[1m'
RED='' RED='[0;31m'
GREEN='' GREEN='[0;32m'
YELLOW='' YELLOW='[0;33m'
BLUE='' BLUE='[0;34m'
MAGENTA='' MAGENTA='[0;35m'
CYAN='' CYAN='[0;36m'
NC='' # No Color NC='[0m' # No Color
NL=' NL='
' '
@ -142,16 +142,24 @@ get_domaine() {
echo ${1/#*@/} echo ${1/#*@/}
} }
#skip_domain () {
# LEFT=":"
# for ARG in $@; do
#
#LOG_FIC "${GREEN}####################in skip domaine#################### ${ARG}"
#
# [ "${ARG}" = "--" ] && LEFT="" && continue
# DOM=$(get_domaine ${ARG})
# [ -n "${DOM}" ] || continue
# if [ -z "${LEFT}" ]; then
# grep -q "^${DOM}$" "${SKIP_DEST_DOMAIN}" 2>/dev/null && echo "yes"
# fi
# done
#}
skip_domain () { skip_domain () {
LEFT=":" DOM=$(get_domaine ${1})
for ARG in $@; do grep -q ${DOM} ${SKIP_DEST_DOMAIN} 2>/dev/null && echo "yes"
[ "${ARG}" = "--" ] && LEFT="" && continue
DOM=$(get_domaine ${ARG})
[ -n "${DOM}" ] || continue
if [ -z "${LEFT}" ]; then
grep -q "^${DOM}$" "${SKIP_DEST_DOMAIN}" 2>/dev/null && echo "yes"
fi
done
} }
#################### MAIN ################################################# #################### MAIN #################################################
@ -162,6 +170,7 @@ if ! mkdir -p "${MAILS}"; then
LOG_FIC "${RED}Can't mkdir ${MAILS} ${NC}" LOG_FIC "${RED}Can't mkdir ${MAILS} ${NC}"
quitFilter "${EX_UNAVAILABLE}" quitFilter "${EX_UNAVAILABLE}"
fi fi
MAIL_SOURCE_V0=$(echo $@)
MAIL_SOURCE=$(echo $@ | awk 'BEGIN{FS=" "} {print $2}') MAIL_SOURCE=$(echo $@ | awk 'BEGIN{FS=" "} {print $2}')
DATE_TEMPS=$(date "+%Y-%m-%d-%H:%M:%S") DATE_TEMPS=$(date "+%Y-%m-%d-%H:%M:%S")
REP_PIECE_JOINTE="${MAILS}/${DATE_TEMPS}_${MAIL_SOURCE}_$$" REP_PIECE_JOINTE="${MAILS}/${DATE_TEMPS}_${MAIL_SOURCE}_$$"
@ -175,6 +184,7 @@ PERIOD=$(curl "${JIRAFEAU_LOCAL}/a.php?p=${MAIL_SOURCE}" 2>/dev/null )
LOG_FIC "${NL}" \ LOG_FIC "${NL}" \
" MAIL_SOURCE : ${YELLOW}${MAIL_SOURCE}${NC}${NL}" \ " MAIL_SOURCE : ${YELLOW}${MAIL_SOURCE}${NC}${NL}" \
" MAIL_SOURCE_V0 : ${YELLOW}${MAIL_SOURCE_V0}${NC}${NL}" \
" DATE_TEMPS : ${YELLOW}${DATE_TEMPS=}${NC}${NL}" \ " DATE_TEMPS : ${YELLOW}${DATE_TEMPS=}${NC}${NL}" \
" MODE : ${YELLOW}${MODE}${NC}${NL}" \ " MODE : ${YELLOW}${MODE}${NC}${NL}" \
" TRACK : ${YELLOW}${TRACK}${NC}${NL}" \ " TRACK : ${YELLOW}${TRACK}${NC}${NL}" \
@ -217,7 +227,7 @@ if [ "${MODE}" = "none"]; then
quitFilter 0 quitFilter 0
fi fi
if [ "$(skip_domain $*)" = "yes"]; then if [ "$(skip_domain ${MAIL_SOURCE})" = "yes" ]; then
LOG_FIC " - ${GREEN}send without change (skip domain)${NC}" LOG_FIC " - ${GREEN}send without change (skip domain)${NC}"
${SENDMAIL} "$@" < "${INSPECT_DIR}/in.$$" ${SENDMAIL} "$@" < "${INSPECT_DIR}/in.$$"
quitFilter 0 quitFilter 0