To get you started
Code:
$ cat source1
accounttest.com. IN A 35.45.68.21
$ cat source2
gorilla.org. IN A 11.22.33.44
$ cat zone2vhost
#!/bin/sh
FILE="$1"
IP=$(awk '/^[^ ]+ +IN +A +/ { print $4 }' <${FILE} )
name=$(awk '/^[^ ]+ +IN +A +/ { print $1 }' <${FILE} )
NAME=$( echo ${name} | sed -e 's!\.$!!' )
#echo $IP
#echo $NAME
cat <<END
<VirtualHost ${IP} >
ServerName ${NAME}
ServerAdmin webmaster@${NAME}
DocumentRoot /www/docs/${NAME}
ErrorLog logs/error_${NAME}.log
</VirtualHost>
END
$ for FILE in source1 source2 ; do zone2vhost ${FILE} ; done
<VirtualHost 35.45.68.21 >
ServerName accounttest.com
ServerAdmin webmaster@accounttest.com
DocumentRoot /www/docs/accounttest.com
ErrorLog logs/error_accounttest.com.log
</VirtualHost>
<VirtualHost 11.22.33.44 >
ServerName gorilla.org
ServerAdmin webmaster@gorilla.org
DocumentRoot /www/docs/gorilla.org
ErrorLog logs/error_gorilla.org.log
</VirtualHost>
There is a slight problem if there are more IN A records in a file, or when the delimiters are not spaces but tabs
Actually it would be better to first extract all IN A records into a separate file. After the file has been checked for sanity, then process it.