Created
September 25, 2015 16:33
-
-
Save rushipkar90/5852827c9bb1cec26520 to your computer and use it in GitHub Desktop.
find_dup_accts.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Directory to store log files in | |
DST=/root/logs | |
# Any logs older than this will be deleted first | |
KEEPDAYS=5 | |
# Create DST if it doesn't exist | |
if [ ! -d "$DST" ]; then | |
mkdir $DST | |
fi | |
# Remove logs older than KEEPDAYS in DST | |
find ${DST} -type f -mtime +${KEEPDAYS} -exec rm -f {} \; | |
# Flush | |
echo -n > $DST/`hostname`_duplicate_list_`date +%F`.txt | |
local_ip_addresses="" | |
for i in `/sbin/ifconfig | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1 }' | grep -v 127.0.0.1 | grep -v 192.168.` | |
do | |
local_ip_addresses=$local_ip_addresses\|$i | |
done | |
local_ip_addresses=$local_ip_addresses\| | |
for dms in `cat /etc/trueuserdomains | awk '{print $1}' | tr -d ":"` | |
do | |
answer=`dig +nocmd $dms A +noall +answer @208.67.222.222` | |
echo $answer | egrep -vi "\($local_ip_addresses\)" > /dev/null | |
if [ $? -eq 0 ]; then | |
echo -n $answer >> $DST/`hostname`_duplicate_list_`date +%F`.txt | |
echo $answer | egrep "\(|67.215.65.132|67.215.66.132|\)" > /dev/null | |
if [ $? -eq 0 ]; then | |
echo " unresolvable" >> $DST/`hostname`_duplicate_list_`date +%F`.txt | |
else | |
echo >> $DST/`hostname`_duplicate_list_`date +%F`.txt | |
fi | |
#else | |
# echo Local: $answer | |
fi | |
done | |
sed -i '/^$/d' $DST/`hostname`_duplicate_list_`date +%F`.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment