Compare commits

...

6 Commits

Author SHA1 Message Date
fab
94659482cf Mise à jour de 'src/bash/filter.sh' 2023-10-23 12:22:39 +02:00
fab
3ac1bec5d9 Mise à jour de 'src/bash/filter.sh' 2023-10-21 02:07:06 +02:00
fab
4c61cf5c81 Mise à jour de 'src/bash/filter.sh' 2023-10-21 01:21:25 +02:00
fab
aea24bbe89 Mise à jour de 'src/bash/filter.sh' 2023-10-20 22:51:11 +02:00
bd3a2bc0c8 update var name 2023-10-20 19:29:20 +02:00
b0e3c5b390 test skip 2023-10-20 19:25:26 +02:00

View File

@ -72,18 +72,22 @@ MAX_FINAL_SIZE=2097152 # 2Mi
ARCHIVE_TITLE="archive_content" ARCHIVE_TITLE="archive_content"
ARCHIVE_MIME="text/kaz_email_archive" 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 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='
' '
@ -137,6 +141,26 @@ curlJirafeauSend () {
echo "${OUTPUT}" 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 ################################################# #################### MAIN #################################################
echo "${NL}${BLUE}$(date +%d-%m-%Y-%H-%M-%S)${NC} : ${GREEN}######################################## filter start (log in ${TMP_LOG})${NC}" >> "${FIC_LOG}" 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}" LOG_FIC "${GREEN}######################################## ${TMP_LOG} ${NC}"
@ -145,6 +169,14 @@ 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
#$@ 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}') 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}_$$"
@ -194,12 +226,19 @@ mkdir -p "${REP_PIECE_JOINTE}/"
>"${OLD_LINKS}" >"${OLD_LINKS}"
>"${ARCHIVE_CONTENT}" >"${ARCHIVE_CONTENT}"
if [ "${MODE}" = "none" ]; then if [ "${MODE}" = "none"]; then
LOG_FIC " - ${GREEN}send without change (MODE=none)${NC}" LOG_FIC " - ${GREEN}send without change (MODE=none)${NC}"
${SENDMAIL} "$@" < "${INSPECT_DIR}/in.$$" ${SENDMAIL} "$@" < "${INSPECT_DIR}/in.$$"
quitFilter 0 quitFilter 0
fi 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 # Etape de rafraichissement des anciens fichiers inclus
echo "time: ${DATE_TEMPS}${NL}id: $(date +%s)" > "${ARCHIVE_CONTENT}" echo "time: ${DATE_TEMPS}${NL}id: $(date +%s)" > "${ARCHIVE_CONTENT}"
[ -n "${TRACK}" ] && echo "sender: ${MAIL_SOURCE}" >> "${ARCHIVE_CONTENT}" [ -n "${TRACK}" ] && echo "sender: ${MAIL_SOURCE}" >> "${ARCHIVE_CONTENT}"
@ -322,3 +361,4 @@ fi
quitFilter 0 quitFilter 0
########################################################################## ##########################################################################