SHARE
TWEET

spamfind.sh

zombic Jan 20th, 2016 137 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. #========================================================================#
  4. # Скрипт для поиска писем в спаме и их восстановление при необходимости. #
  5. #========================================================================#
  6. echo -e "\\033[1;37m"
  7. echo "   ВЫБЕРИТЕ НУЖНЫЙ ПУНКТ"
  8. PS3=">> "
  9. echo -e "\\033[00m"
  10. select OPT_MENU in "Поиск письма в папке SPAM" "Фильтр FROM-TO" "Восстановить из папки SPAM" "Добавить адрес в white-list" "Выход"
  11. do
  12. case $OPT_MENU in
  13.     Поиск*)
  14.     echo -en "\\033[1;34m"
  15.     echo " Введите слово, по которому будем искать:"
  16.     echo -en "\\033[1;35m"
  17.     echo -n ">> "
  18.     echo -en "\\033[00m"
  19.     read VAR
  20.     FLTR=$VAR
  21.     mail1=mail.log
  22.     mail2=mail.log.0
  23.     mail3=mail.log.*.gz
  24.     echo
  25.     cat /var/log/$mail1 | grep "spam-" | awk '{print $1" "$2" "$3" "$11"\t====> "$13"\t\tSpamID: "$15}' | grep $FLTR
  26.     cat /var/log/$mail2 | grep "spam-" | awk '{print $1" "$2" "$3" "$11"\t====> "$13"\t\tSpamID: "$15}' | grep $FLTR
  27.     zcat /var/log/$mail3 | grep "spam-" | awk '{print $1" "$2" "$3" "$11"\t====> "$13"\t\tSpamID: "$15}' | grep $FLTR
  28.     echo -e "\\033[1;32m"
  29.     echo " Найдено совпадений:"
  30.     echo " Сегодня -  " `cat /var/log/$mail1 | grep "spam-" | awk '{print $1" "$2" "$3" "$11"\t====> "$13"\t\tSpamID: "$15}' | grep $FLTR -c`
  31.     echo " Вчера -    " `cat /var/log/$mail2 | grep "spam-" | awk '{print $1" "$2" "$3" "$11"\t====> "$13"\t\tSpamID: "$15}' | grep $FLTR -c`
  32.     echo " В архиве - " `zcat /var/log/$mail3 | grep "spam-" | awk '{print $1" "$2" "$3" "$11"\t====> "$13"\t\tSpamID: "$15}' | grep $FLTR -c`
  33.     echo -e "\\033[00m"
  34.     exec spamfind
  35.     ;;
  36.     Фильтр*)
  37.     echo -en "\\033[1;34m"
  38.     echo " Введите через пробел адреса отправителя и получателя:"
  39.     echo -en "\\033[1;35m"
  40.     echo -n " Первый адрес >> "
  41.     echo -en "\\033[00m"
  42.     read VAR1
  43.     echo -en "\\033[1;35m"
  44.     echo -n " Второй адрес >> "
  45.     echo -en "\\033[00m"
  46.     read VAR2
  47.     FLTR1=$VAR1
  48.     FLTR2=$VAR2
  49.     mail1=mail.log
  50.     mail2=mail.log.0
  51.     mail3=mail.log.*.gz
  52.     echo
  53.     cat /var/log/$mail1 | grep "$FLTR1" | grep "$FLTR2"
  54.     cat /var/log/$mail2 | grep "$FLTR1" | grep "$FLTR2"
  55.     zcat /var/log/$mail3 | grep "$FLTR1" | grep "$FLTR2"
  56.     echo -e "\\033[1;32m"
  57.     echo " Найдено совпадений:"
  58.     echo " Сегодня -  " `cat /var/log/$mail1 | grep "$FLTR1" | grep "$FLTR2" -c`
  59.     echo " Вчера -    " `cat /var/log/$mail2 | grep "$FLTR1" | grep "$FLTR2" -c`
  60.     echo " В архиве - " `zcat /var/log/$mail3 | grep "$FLTR1" | grep "$FLTR2" -c`
  61.     echo -e "\\033[00m"
  62.     exec spamfind
  63.     ;;
  64.     Восст*)
  65.     echo -e "\\033[1;34m"
  66.     echo " Введите SpamID:"
  67.         echo -en "\\033[1;35m"
  68.     echo -n ">> "
  69.         echo -en "\\033[00m"
  70.     read SPAMID
  71.     amavisd-release $SPAMID
  72.     exec spamfind
  73.     ;;
  74.     Добавить*)
  75.     echo -e "\\033[1;34m"
  76.     echo " Введите адрес (например, mail@mail.com или *@mail.com):"
  77.         echo -en "\\033[1;35m"
  78.     echo -n ">> "
  79.     echo -en "\\033[00m"
  80.     read MAILADR
  81.         echo whitelist_from $MAILADR >> /etc/spamassassin/local.cf
  82.     /etc/init.d/spamassassin restart
  83.     /etc/init.d/amavis restart
  84.     exec spamfind
  85.     ;;
  86.     Выход) break
  87.     ;;
  88.     *)
  89.     echo -e "\\033[1;31m"
  90.     echo " Неверно. Повторите ввод"
  91.     exec spamfind
  92. esac
  93. break
  94. done
  95. echo
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top