TTL record changes in All domains
Adam Tkac
atkac at redhat.com
Tue Jul 17 11:35:38 UTC 2007
Stephane Bortzmeyer napsal(a):
> On Tue, Jul 17, 2007 at 12:42:04PM +0200,
> Adam Tkac <atkac at redhat.com> wrote
> a message of 22 lines which said:
>
>
>> I don't know about any utility but I think you could write simple bash
>> script (something like this example)
>>
>> for zone in `find zones`; do
>> cat "${zone}" | sed 's/$TTL.*/$TTL 2D/' > "${zone}.new"
>> mv "${zone}.new" "${zone}"
>> done
>>
>
> Warning, if there is a bug in the sed script, this will destroy the
> old file with a new and empty one, without remorse.
>
> Perl may be a better idea, specially since it keeps a backup:
>
> perl -i.bak -p -e 's/^ *\$TTL *(.*)$/\$TTL 2D/' `find zones`
>
> -i : keeps a backup
> -p : loops over the original file
> -e : executes this instruction
>
> s/.../.../ : substitutes the new TTL
>
I don't think there's a bug. It exists three type of RE - basic,
extended and perl. sed uses basic RE and perl uses his own so it if you
use perl and sed with same expressions results will be different. Only
one problem in my sample could be if you have '$TTL' string somewhere
else in zone (not only on start of zone configfile). ...$TTL... could be
replaced by ...$TTL 2D. More safety could be substiture mv command with
cp and substitute 's/$TTL.*/$TTL 2D/' by 's/^$TTL/$TTL 2D/'.
Adam
More information about the bind-users
mailing list