Add 'opennic-extract-domains'

This commit is contained in:
Alexander Andreev 2020-07-10 01:48:50 +04:00
parent d1f3e206e5
commit 5ff5acc548

31
opennic-extract-domains Normal file
View File

@ -0,0 +1,31 @@
#!/usr/bin/sh
# $1 - save path, default is 'onic-domains' created in working directory
onic_zone_path=/var/named/onic
onic_domains_path="onic-domains"
if [ -n "$1" ]; then
$onic_domains_path=$1
fi
mkdir -p $onic_domains_path
for f in $onic_zone_path/*.zone; do
zone=$(basename $f)
zone=(${zone//.zone/})
echo -n "Processing $zone... "
named-compilezone -q -f raw -F text -o /tmp/$zone.text $zone $f
grep -v "*" /tmp/$zone.text \
| awk '{ print substr($1, 1, length($1)-1) | "sort -u"; NF > 0; }' \
> $onic_domains_path/$zone.list
rm /tmp/$zone.text
while read domain; do
if [ -n "$(dig +short $domain)" ]; then
echo $domain >> $onic_domains_path/$zone.list.withip
fi
done < $onic_domains_path/$zone.list
echo "Done"
done