diff --git a/src/bash/filter.sh b/src/bash/filter.sh index 6be24a4..675ed41 100755 --- a/src/bash/filter.sh +++ b/src/bash/filter.sh @@ -71,7 +71,7 @@ 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" KEEP_FAILED=true DEBUG= @@ -137,6 +137,23 @@ curlJirafeauSend () { echo "${OUTPUT}" } +get_domaine() { + [[ $1 =~ @ ]] || return + echo ${1/#*@/} +} + +skip_domain () { + LEFT=":" + for ARG in $@; do + [ "${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 ################################################# 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}" @@ -194,12 +211,22 @@ mkdir -p "${REP_PIECE_JOINTE}/" >"${OLD_LINKS}" >"${ARCHIVE_CONTENT}" -if [ "${MODE}" = "none" ]; then +if + ${SENDMAIL} "$@" < "${INSPECT_DIR}/in.$$" +fi + +if [ "${MODE}" = "none"]; then LOG_FIC " - ${GREEN}send without change (MODE=none)${NC}" ${SENDMAIL} "$@" < "${INSPECT_DIR}/in.$$" quitFilter 0 fi +if [ "$(get_domain_dest $*)" = "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}"