#!/bin/sh

file=$1
named_file=/etc/bind/temp.conf
template=/home/server/named/templates/internetx
base_dir=/home/server/named
log=/var/log/syslog

for domain in `cat $file`; do
   BASE=`echo $domain | sed 's/\..*$//g'`
   EXT=`echo $domain | sed 's/.*\.\(.*\)/\1/g'`
#   echo $BASE
#   echo $EXT

   cat << EOF >> "$named_file" 

# schottelius 
zone "$domain" {
	type master;
	file "$EXT/$BASE";
};
EOF

cp "$template" "$base_dir/$EXT/$BASE"
done

killall -HUP named &
tail -f $log