Re: Script to delete zone from named.conf

2010-02-04 Thread Rick Dicaire
On Thu, Feb 4, 2010 at 12:12 PM, bsd  wrote:
> zone "abc.com" {
>       type slave;
>       masters  { 213.14.17.2 ; };
>       file "hosts.abc.com";
> };

You could put the whole statement on one line, then use grep or sed
based on the zone name.
Operationally, it'd work, and no doubt others will argue aesthetic
reasons not to do this. Alternately
a more complicated script could be written to handle the format as you
currently have it.

-- 
aRDy Music and Rick Dicaire present:
http://www.ardynet.com
http://www.ardynet.com:9000/ardymusic.ogg.m3u
___
bind-users mailing list
bind-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users


Re: Script to delete zone from named.conf

2010-02-04 Thread bsd
Thanks for your reply… 

I know I can do that with grep, but you see I have 270 domains to delete from 
my named.conf. 

My question was more: has anyone got a working script that I can use in order 
to delete name from my "named.conf" file ? 


Idealy It should be a script that I can use in a "for do done" sequence like 

for i in `cat list_to_delete.txt` 
do my_remove_script.(sh|pl|xx) $i done


Thanks. 

Le 4 févr. 2010 à 18:22, Rick Dicaire a écrit :

> On Thu, Feb 4, 2010 at 12:12 PM, bsd  wrote:
>> zone "abc.com" {
>>   type slave;
>>   masters  { 213.14.17.2 ; };
>>   file "hosts.abc.com";
>> };
> 
> You could put the whole statement on one line, then use grep or sed
> based on the zone name.
> Operationally, it'd work, and no doubt others will argue aesthetic
> reasons not to do this. Alternately
> a more complicated script could be written to handle the format as you
> currently have it.
> 
> -- 
> aRDy Music and Rick Dicaire present:
> http://www.ardynet.com
> http://www.ardynet.com:9000/ardymusic.ogg.m3u


Gregober ---> PGP ID --> 0x1BA3C2FD
bsd @at@ todoo.biz


P "Please consider your environmental responsibility before printing this 
e-mail"


___
bind-users mailing list
bind-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users


Re: Script to delete zone from named.conf

2010-02-04 Thread Evan Hunt
> I know I can do that with grep, but you see I have 270 domains to delete
> from my named.conf. 
> 
> My question was more: has anyone got a working script that I can use in
> order to delete name from my "named.conf" file ? 

cat named.conf | \
awk 'BEGIN {suppress = 0}
 /zone "whatever.com"/ {suppress = 1}
 {if (suppress == 0) print; if ($1 == "};" && NF == 1) suppress = 0}'

Or words to that effect.  Works as long as the zones are always formatted
the same way.

--
Evan Hunt -- e...@isc.org
Internet Systems Consortium, Inc.
___
bind-users mailing list
bind-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users


Re: Script to delete zone from named.conf

2010-02-04 Thread bsd
Thanks Evan, 

I'll try that and maybe try to embed that on a bash script… 

The formatting should be the same for most of my domains… Anyway I'll test that 
on copy of my zone file ;-) 

sed and awk haven't got so friendly syntax; but they are indeed very powerful… 


Sincerly yours. 

Le 4 févr. 2010 à 19:19, Evan Hunt a écrit :

>> I know I can do that with grep, but you see I have 270 domains to delete
>> from my named.conf. 
>> 
>> My question was more: has anyone got a working script that I can use in
>> order to delete name from my "named.conf" file ? 
> 
> cat named.conf | \
>awk 'BEGIN {suppress = 0}
> /zone "whatever.com"/ {suppress = 1}
> {if (suppress == 0) print; if ($1 == "};" && NF == 1) suppress = 0}'
> 
> Or words to that effect.  Works as long as the zones are always formatted
> the same way.
> 
> --
> Evan Hunt -- e...@isc.org
> Internet Systems Consortium, Inc.


Gregober ---> PGP ID --> 0x1BA3C2FD
bsd @at@ todoo.biz


P "Please consider your environmental responsibility before printing this 
e-mail"


___
bind-users mailing list
bind-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users


Re: Script to delete zone from named.conf

2010-02-04 Thread James O'Gorman
On 4 Feb 2010, at 17:12, bsd wrote:

> Hello, 
> 
> I am looking for a script to delete a zone from named.conf and maybe also 
> from server (zone file). 
> 
> My zone file looks like that (but could have some variations). Everything 
> inside brackets should be deleted… and eventually the host file. 

Assuming all zone statements are identically formatted (as per your examples), 
then the following will work:

sed -e '/^zone "bar.com" {$/,/^};$/ d' -i .bak named.conf 

That looks for a line that is exactly "zone "..." {" and another that is 
exactly "};" - and then deletes those lines and everything in between.

If you want to create a script to do this, you could do:

#!/bin/sh

zone=$1
sed -e "/^zone \"$zone\" {/,/^};$/ d" -i .bak named.conf
rm $zone

James
___
bind-users mailing list
bind-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users


Re: Script to delete zone from named.conf

2010-02-04 Thread Justin T Pryzby
On Thu, Feb 04, 2010 at 06:19:07PM +, Evan Hunt wrote:
> > I know I can do that with grep, but you see I have 270 domains to delete
> > from my named.conf. 
> > 
> > My question was more: has anyone got a working script that I can use in
> > order to delete name from my "named.conf" file ? 
> 
> cat named.conf | \
> awk 'BEGIN {suppress = 0}
>  /zone "whatever.com"/ {suppress = 1}
>  {if (suppress == 0) print; if ($1 == "};" && NF == 1) suppress = 0}'
> 
> Or words to that effect.  Works as long as the zones are always formatted
> the same way.
As an alternative:

To remove the "toxtracker.info" zone:
awk -v s=toxtracker.info 'BEGIN{RS=""; s="zone \""s"\""} $0~s{print $0"\n"}'

Justin
___
bind-users mailing list
bind-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users


Re: Script to delete zone from named.conf

2010-02-04 Thread Justin T Pryzby
On Thu, Feb 04, 2010 at 02:27:27PM -0700, Justin T Pryzby wrote:
> awk -v s=toxtracker.info 'BEGIN{RS=""; s="zone \""s"\""} $0~s{print $0"\n"}'
Doh, should be:
 awk -v s=toxtracker.info 'BEGIN{RS=""; s="zone \""s"\""} $0!~s{print $0"\n"}'
___
bind-users mailing list
bind-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users


Re: Script to delete zone from named.conf

2010-02-04 Thread Mark Andrews

In message <20100204212727.ga23...@norchemlab.com>, Justin T Pryzby writes:
> On Thu, Feb 04, 2010 at 06:19:07PM +, Evan Hunt wrote:
> > > I know I can do that with grep, but you see I have 270 domains to delete
> > > from my named.conf. 
> > > 
> > > My question was more: has anyone got a working script that I can use in
> > > order to delete name from my "named.conf" file ? 
> > 
> > cat named.conf | \
> > awk 'BEGIN {suppress = 0}
> >  /zone "whatever.com"/ {suppress = 1}
> >  {if (suppress == 0) print; if ($1 == "};" && NF == 1) suppress = 
> > 0}'
> > 
> > Or words to that effect.  Works as long as the zones are always formatted
> > the same way.
> As an alternative:
> 
> To remove the "toxtracker.info" zone:
> awk -v s=toxtracker.info 'BEGIN{RS=""; s="zone \""s"\""} $0~s{print $0"\n"}'
> 
> Justin
> ___
> bind-users mailing list
> bind-users@lists.isc.org
> https://lists.isc.org/mailman/listinfo/bind-users

Recent version of named-checkconf have a -p (print) option which
will emit named.conf, sans comments, in a consistent style which
will then be easy to post process.
-- 
Mark Andrews, ISC
1 Seymour St., Dundas Valley, NSW 2117, Australia
PHONE: +61 2 9871 4742 INTERNET: ma...@isc.org
___
bind-users mailing list
bind-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users


Re: Script to delete zone from named.conf

2010-02-05 Thread Sam Wilson
In article ,
 Mark Andrews  wrote:

> Recent version of named-checkconf have a -p (print) option which
> will emit named.conf, sans comments, in a consistent style which
> will then be easy to post process.

Shame about the "sans comments" - easy comprehension or easy management 
- take your pick.  (Yes, I know it's a difficult task to preserve 
commenting - BTDT.)

Sam
___
bind-users mailing list
bind-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users