#!/bin/bash #Copyright 2008 (c) www.mhgoz.com #Programer : Dr. Ehab Diab #Email : ehab@ehabdiab.com #Website : www.ehabdiab.com # Remove NS3 & NS4 from Records: # sed -i -E '/NS\s+ns[34]\.mhgoz\.com\.\s*$/d' /var/named/*.db cd /var/named # Getting .db files with no spf word and remove the .db suffix: grep -iL spf *.db | sed 's/\.db//' > /root/domains-with-no-spf.txt # Getting users list for all domains: for i in `cat /root/domains-with-no-spf.txt`;do cat /etc/domainusers|grep $i;done|awk '{print $1}'|cut -d ':' -f1 > /root/domains-with-no-spf2.txt # Create spf records for all that users: for i in `cat /root/domains-with-no-spf2.txt`;do /usr/local/cpanel/bin/spf_installer $i;done # Replace all SPF TXT records original value with '"v=spf1 a:5818.submission.antispamcloud.com a:release.antispamcloud.com -all"' sed -i -E '/\s+TXT\s+"v=spf/{s/"[^"]+/"v=spf1 a:5818.submission.antispamcloud.com a:release.antispamcloud.com -all/g}' /var/named/*.db # Update DNS Zones after manual modification: find /var/named/*.db -mtime -1 -exec perl -pi -e 'if (/^\s+(\d{10})\s+;\s+serial/i) { my $i = $1+1; s/$1/$i/;}' '{}' \; # Removing files: rm -rf /root/domains-with-no-spf.txt /root/domains-with-no-spf2.txt exit 0