From 3ac1bec5d9669b5d9f7e5f229f8e0c5d82e56181 Mon Sep 17 00:00:00 2001 From: fab Date: Sat, 21 Oct 2023 02:07:06 +0200 Subject: [PATCH] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'src/bash/filter.sh?= =?UTF-8?q?'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bash/filter.sh | 60 +++++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 25 deletions(-) diff --git a/src/bash/filter.sh b/src/bash/filter.sh index 706992b..b41eb4c 100755 --- a/src/bash/filter.sh +++ b/src/bash/filter.sh @@ -73,17 +73,17 @@ 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= +DEBUG=true #################### FONCTIONS ############################################ -BOLD='' -RED='' -GREEN='' -YELLOW='' -BLUE='' -MAGENTA='' -CYAN='' -NC='' # 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=' ' @@ -142,17 +142,25 @@ get_domaine() { echo ${1/#*@/} } +#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 +#} + 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 -} + DOM=$(get_domaine ${1}) + grep -q ${DOM} ${SKIP_DEST_DOMAIN} 2>/dev/null && echo "yes" +} #################### MAIN ################################################# echo "${NL}${BLUE}$(date +%d-%m-%Y-%H-%M-%S)${NC} : ${GREEN}######################################## filter start (log in ${TMP_LOG})${NC}" >> "${FIC_LOG}" @@ -162,6 +170,7 @@ if ! mkdir -p "${MAILS}"; then LOG_FIC "${RED}Can't mkdir ${MAILS} ${NC}" quitFilter "${EX_UNAVAILABLE}" fi +MAIL_SOURCE_V0=$(echo $@) 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}_$$" @@ -174,11 +183,12 @@ 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}" \ + " 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}" \ + " PERIOD : ${YELLOW}${PERIOD}${NC}${NL}" if ! cd "${INSPECT_DIR}"; then echo "${INSPECT_DIR} does not exist" @@ -217,7 +227,7 @@ if [ "${MODE}" = "none"]; then quitFilter 0 fi -if [ "$(skip_domain $*)" = "yes"]; then +if [ "$(skip_domain ${MAIL_SOURCE})" = "yes" ]; then LOG_FIC " - ${GREEN}send without change (skip domain)${NC}" ${SENDMAIL} "$@" < "${INSPECT_DIR}/in.$$" quitFilter 0