update_postscreen_whitelist.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/usr/bin/env bash
  2. SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
  3. WORKING_DIR=${SCRIPT_DIR}/postwhite_tmp
  4. SPFTOOLS_DIR=${WORKING_DIR}/spf-tools
  5. POSTWHITE_DIR=${WORKING_DIR}/postwhite
  6. POSTWHITE_CONF=${POSTWHITE_DIR}/postwhite.conf
  7. CUSTOM_HOSTS='"web.de gmx.net mail.de freenet.de arcor.de unity-mail.de"'
  8. STATIC_HOSTS=(
  9. "194.25.134.0/24 permit # t-online.de"
  10. )
  11. mkdir ${SCRIPT_DIR}/postwhite_tmp
  12. git clone https://github.com/spf-tools/spf-tools.git ${SPFTOOLS_DIR}
  13. git clone https://github.com/stevejenkins/postwhite.git ${POSTWHITE_DIR}
  14. function set_config() {
  15. sudo sed -i "s@^\($1\s*=\s*\).*\$@\1$2@" ${POSTWHITE_CONF}
  16. }
  17. set_config custom_hosts "${CUSTOM_HOSTS}"
  18. set_config reload_postfix no
  19. set_config postfixpath /.
  20. set_config spftoolspath ${WORKING_DIR}/spf-tools
  21. set_config whitelist .${SCRIPT_DIR}/../data/conf/postfix/postscreen_access.cidr
  22. set_config yahoo_static_hosts ${POSTWHITE_DIR}/yahoo_static_hosts.txt
  23. #Fix URL for Yahoo!: https://github.com/stevejenkins/postwhite/issues/59
  24. sudo sed -i \
  25. -e 's#yahoo_url="https://help.yahoo.com/kb/SLN23997.html"#yahoo_url="https://senders.yahooinc.com/outbound-mail-servers/"#' \
  26. -e 's#echo "ipv6:$line";#echo "ipv6:$line" | grep -v "ipv6:::";#' \
  27. -e 's#`command -v wget`#`command -v skip-wget`#' \
  28. ${POSTWHITE_DIR}/scrape_yahoo
  29. cd ${POSTWHITE_DIR}
  30. ./postwhite ${POSTWHITE_CONF}
  31. ( IFS=$'\n'; echo "${STATIC_HOSTS[*]}" >> "${SCRIPT_DIR}/../data/conf/postfix/postscreen_access.cidr")
  32. rm -r ${WORKING_DIR}