#!/bin/sh

MASTER=Plesk Computer IP Address
NAMED_ROOT=/var/named/run-root/etc
HTTPDOCS=/var/www/vhosts/The directory where zone list will be saved 

egrep "^zone" $NAMED_ROOT/named.conf |egrep -iv "arpa|\"\." | awk -F\" '{print $2}' > $NAMED_ROOT/domains

echo > $HTTPDOCS/secondaries.include
for i in `cat $NAMED_ROOT/domains`; do
  echo "zone \"$i\" {"                      >> $HTTPDOCS/secondaries.include
  echo "	type slave;"                >> $HTTPDOCS/secondaries.include
  echo "	file \"plesk/$i.zoneinfo\";"         >> $HTTPDOCS/secondaries.include
  echo "	masters { $MASTER; };"      >> $HTTPDOCS/secondaries.include
  echo "	allow-transfer { none; };"  >> $HTTPDOCS/secondaries.include
  echo "};"                                 >> $HTTPDOCS/secondaries.include
  echo                                      >> $HTTPDOCS/secondaries.include
done

chmod 644 $HTTPDOCS/secondaries.include

