Mise à jour de 'src/bash/filter.sh'
This commit is contained in:
parent
3ac1bec5d9
commit
94659482cf
@ -71,7 +71,11 @@ DISCLAMER_CMD=altermime
|
||||
MAX_FINAL_SIZE=2097152 # 2Mi
|
||||
ARCHIVE_TITLE="archive_content"
|
||||
ARCHIVE_MIME="text/kaz_email_archive"
|
||||
SKIP_DEST_DOMAIN="/tmp/docker-mailserver/dest-domain-no-depol.txt"
|
||||
|
||||
FILE_SKIP_DOMAINS="/tmp/docker-mailserver/file_domaines_non_depollues.txt"
|
||||
#on enlève les commentaires et les lignes vides
|
||||
SKIP_DOMAINS=`grep -Ev '^#|^[[:space:]]*$' $FILE_SKIP_DOMAINS`
|
||||
|
||||
KEEP_FAILED=true
|
||||
DEBUG=true
|
||||
|
||||
@ -137,29 +141,24 @@ curlJirafeauSend () {
|
||||
echo "${OUTPUT}"
|
||||
}
|
||||
|
||||
get_domaine() {
|
||||
[[ $1 =~ @ ]] || return
|
||||
echo ${1/#*@/}
|
||||
}
|
||||
# Définir une fonction pour vérifier si le domaine d'un email est dans la liste SKIP_DOMAINS
|
||||
function check_skip_domains() {
|
||||
local SKIP_DOMAINS="$1"
|
||||
local LIST_EMAILS="$2"
|
||||
|
||||
#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
|
||||
#}
|
||||
for email in $LIST_EMAILS; do
|
||||
# Extraire le domaine de l'email (partie après le "@")
|
||||
local domain="${email##*@}"
|
||||
|
||||
skip_domain () {
|
||||
DOM=$(get_domaine ${1})
|
||||
grep -q ${DOM} ${SKIP_DEST_DOMAIN} 2>/dev/null && echo "yes"
|
||||
# Utiliser grep pour vérifier si le domaine est dans la liste des domaines à sauter
|
||||
if echo "$SKIP_DOMAINS" | grep -q -w "$domain"; then
|
||||
echo "yes"
|
||||
return
|
||||
fi
|
||||
done
|
||||
|
||||
# Si aucun domaine n'a été trouvé, retourner "no"
|
||||
echo "no"
|
||||
}
|
||||
|
||||
#################### MAIN #################################################
|
||||
@ -170,7 +169,14 @@ if ! mkdir -p "${MAILS}"; then
|
||||
LOG_FIC "${RED}Can't mkdir ${MAILS} ${NC}"
|
||||
quitFilter "${EX_UNAVAILABLE}"
|
||||
fi
|
||||
MAIL_SOURCE_V0=$(echo $@)
|
||||
|
||||
#$@ contient le sender et les destinataires
|
||||
#format "-f sender -- dest1 [...dest(i)] "
|
||||
LIST_EMAILS=$(echo $@)
|
||||
#on nettoie
|
||||
LIST_EMAILS=$(sed 's/-f//g' <<< $LIST_EMAILS)
|
||||
LIST_EMAILS=$(sed 's/--//g' <<< $LIST_EMAILS)
|
||||
|
||||
MAIL_SOURCE=$(echo $@ | awk 'BEGIN{FS=" "} {print $2}')
|
||||
DATE_TEMPS=$(date "+%Y-%m-%d-%H:%M:%S")
|
||||
REP_PIECE_JOINTE="${MAILS}/${DATE_TEMPS}_${MAIL_SOURCE}_$$"
|
||||
@ -184,7 +190,6 @@ PERIOD=$(curl "${JIRAFEAU_LOCAL}/a.php?p=${MAIL_SOURCE}" 2>/dev/null )
|
||||
|
||||
LOG_FIC "${NL}" \
|
||||
" MAIL_SOURCE : ${YELLOW}${MAIL_SOURCE}${NC}${NL}" \
|
||||
" MAIL_SOURCE_V0 : ${YELLOW}${MAIL_SOURCE_V0}${NC}${NL}" \
|
||||
" DATE_TEMPS : ${YELLOW}${DATE_TEMPS=}${NC}${NL}" \
|
||||
" MODE : ${YELLOW}${MODE}${NC}${NL}" \
|
||||
" TRACK : ${YELLOW}${TRACK}${NC}${NL}" \
|
||||
@ -227,7 +232,8 @@ if [ "${MODE}" = "none"]; then
|
||||
quitFilter 0
|
||||
fi
|
||||
|
||||
if [ "$(skip_domain ${MAIL_SOURCE})" = "yes" ]; then
|
||||
|
||||
if [ "$(check_skip_domains "$SKIP_DOMAINS" "$LIST_EMAILS")" = "yes" ]; then
|
||||
LOG_FIC " - ${GREEN}send without change (skip domain)${NC}"
|
||||
${SENDMAIL} "$@" < "${INSPECT_DIR}/in.$$"
|
||||
quitFilter 0
|
||||
@ -355,3 +361,4 @@ fi
|
||||
quitFilter 0
|
||||
|
||||
##########################################################################
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user