fix exclusion domain list

This commit is contained in:
François 2024-12-09 10:08:20 +01:00
parent 56572b5b76
commit 15dbc26592
2 changed files with 15 additions and 13 deletions

View File

@ -47,8 +47,8 @@ DEFAULT_MODE="both"
DEFAULT_PERIOD="month"
DEFAULT_TRACK=""
cd $(dirname $0)
DOMAINEDEPOT=$(cat config/domainedepot)
cd "$(dirname $0)"
DOMAINEDEPOT="$(cat config/domainedepot)"
# Exit codes from <sysexits.h>
EX_TEMPFAIL=75
EX_UNAVAILABLE=69
@ -62,7 +62,7 @@ MAILS=/tmp/FILTER
MAX_KEEP_IN_MAIL=5ki
MAX_UPLOAD_SIZE=1Gi
SHRINK_CMD=/home/filter/eMailShrinker
JIRAFEAU_URL=https://depot.${DOMAINEDEPOT:-"kaz.bzh"}
JIRAFEAU_URL="https://depot.${DOMAINEDEPOT:-"kaz.bzh"}"
JIRAFEAU_LOCAL=http://depot
MD5_CMD=/usr/bin/md5sum
DISCLAMER_CMD=altermime
@ -72,7 +72,7 @@ ARCHIVE_MIME="text/kaz_email_archive"
FILE_SKIP_DOMAINS="config/file_domaines_non_depollues.txt"
#on enlève les commentaires et les lignes vides
SKIP_DOMAINS=$(grep -Ev '^#|^[[:space:]]*$' $FILE_SKIP_DOMAINS 2>/dev/null)
SKIP_DOMAINS="$(sed 's:#.*$::g' 's/[[:blank:]]//g' "${FILE_SKIP_DOMAINS}" 2>/dev/null)"
KEEP_FAILED=true
DEBUG=true
@ -144,15 +144,17 @@ function check_skip_domains() {
local SKIP_DOMAINS="$1"
local LIST_EMAILS="$2"
for email in $LIST_EMAILS; do
for email in ${LIST_EMAILS}; do
# Extraire le domaine de l'email (partie après le "@")
local domain="${email##*@}"
# 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
for domain in ${SKIP_DOMAINS}; do
# vérification si le domaine est dans la liste des domaines à sauter
if [[ " ${email} " =~ "${domain} " ]] ; then
echo "yes"
return
fi
done
done
# Si aucun domaine n'a été trouvé, retourner "no"
@ -172,8 +174,8 @@ fi
#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)
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")
@ -231,7 +233,7 @@ if [ "${MODE}" = "none" ]; then
fi
if [ "$(check_skip_domains "$SKIP_DOMAINS" "$LIST_EMAILS")" = "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

0
src/bash/testCopyInOut.sh Normal file → Executable file
View File