2. a function in the script inserts secondary zone lines in named.conf based on the output of dig. you have to make this script smart enough to check and not to add lines if the zone name already exists in named.conf (you can grep it of course)

3. nsupdate <file_of_2nd_step_above>
this should delete the TXT record