filtrage sur les domaines
pas de dépollution pour les domaines présents dans /tmp/docker-mailserver/file_domaines_non_depollues.txt
This commit is contained in:
parent
eb5b3b3ec7
commit
c2656fd377
@ -72,18 +72,22 @@ MAX_FINAL_SIZE=2097152 # 2Mi
|
||||
ARCHIVE_TITLE="archive_content"
|
||||
ARCHIVE_MIME="text/kaz_email_archive"
|
||||
|
||||
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=
|
||||
DEBUG=true
|
||||
|
||||
#################### FONCTIONS ############################################
|
||||
BOLD='[1m'
|
||||
RED='[0;31m'
|
||||
GREEN='[0;32m'
|
||||
YELLOW='[0;33m'
|
||||
BLUE='[0;34m'
|
||||
MAGENTA='[0;35m'
|
||||
CYAN='[0;36m'
|
||||
NC='[0m' # No Color
|
||||
BOLD='[1m'
|
||||
RED='[0;31m'
|
||||
GREEN='[0;32m'
|
||||
YELLOW='[0;33m'
|
||||
BLUE='[0;34m'
|
||||
MAGENTA='[0;35m'
|
||||
CYAN='[0;36m'
|
||||
NC='[0m' # No Color
|
||||
NL='
|
||||
'
|
||||
|
||||
@ -137,6 +141,26 @@ curlJirafeauSend () {
|
||||
echo "${OUTPUT}"
|
||||
}
|
||||
|
||||
# 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"
|
||||
|
||||
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
|
||||
done
|
||||
|
||||
# Si aucun domaine n'a été trouvé, retourner "no"
|
||||
echo "no"
|
||||
}
|
||||
|
||||
#################### MAIN #################################################
|
||||
echo "${NL}${BLUE}$(date +%d-%m-%Y-%H-%M-%S)${NC} : ${GREEN}######################################## filter start (log in ${TMP_LOG})${NC}" >> "${FIC_LOG}"
|
||||
LOG_FIC "${GREEN}######################################## ${TMP_LOG} ${NC}"
|
||||
@ -145,6 +169,14 @@ if ! mkdir -p "${MAILS}"; then
|
||||
LOG_FIC "${RED}Can't mkdir ${MAILS} ${NC}"
|
||||
quitFilter "${EX_UNAVAILABLE}"
|
||||
fi
|
||||
|
||||
#$@ 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}_$$"
|
||||
@ -157,11 +189,11 @@ PERIOD=$(curl "${JIRAFEAU_LOCAL}/a.php?p=${MAIL_SOURCE}" 2>/dev/null )
|
||||
[[ "${PERIOD}" =~ ^(minute|hour|day|week|month|quarter)$ ]] || PERIOD="${DEFAULT_PERIOD}"
|
||||
|
||||
LOG_FIC "${NL}" \
|
||||
" MAIL_SOURCE : ${YELLOW}${MAIL_SOURCE}${NC}${NL}" \
|
||||
" DATE_TEMPS : ${YELLOW}${DATE_TEMPS=}${NC}${NL}" \
|
||||
" MODE : ${YELLOW}${MODE}${NC}${NL}" \
|
||||
" TRACK : ${YELLOW}${TRACK}${NC}${NL}" \
|
||||
" PERIOD : ${YELLOW}${PERIOD}${NC}${NL}"
|
||||
" MAIL_SOURCE : ${YELLOW}${MAIL_SOURCE}${NC}${NL}" \
|
||||
" DATE_TEMPS : ${YELLOW}${DATE_TEMPS=}${NC}${NL}" \
|
||||
" MODE : ${YELLOW}${MODE}${NC}${NL}" \
|
||||
" TRACK : ${YELLOW}${TRACK}${NC}${NL}" \
|
||||
" PERIOD : ${YELLOW}${PERIOD}${NC}${NL}"
|
||||
|
||||
if ! cd "${INSPECT_DIR}"; then
|
||||
echo "${INSPECT_DIR} does not exist"
|
||||
@ -194,12 +226,19 @@ mkdir -p "${REP_PIECE_JOINTE}/"
|
||||
>"${OLD_LINKS}"
|
||||
>"${ARCHIVE_CONTENT}"
|
||||
|
||||
if [ "${MODE}" = "none" ]; then
|
||||
if [ "${MODE}" = "none"]; then
|
||||
LOG_FIC " - ${GREEN}send without change (MODE=none)${NC}"
|
||||
${SENDMAIL} "$@" < "${INSPECT_DIR}/in.$$"
|
||||
quitFilter 0
|
||||
fi
|
||||
|
||||
|
||||
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
|
||||
fi
|
||||
|
||||
# Etape de rafraichissement des anciens fichiers inclus
|
||||
echo "time: ${DATE_TEMPS}${NL}id: $(date +%s)" > "${ARCHIVE_CONTENT}"
|
||||
[ -n "${TRACK}" ] && echo "sender: ${MAIL_SOURCE}" >> "${ARCHIVE_CONTENT}"
|
||||
@ -322,3 +361,4 @@ fi
|
||||
quitFilter 0
|
||||
|
||||
##########################################################################
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user