#!/usr/bin/perl # # Start Date: Mon, 26 Mar 2001 14:24:09 +0200 # Time-stamp: # File: leaseconvertor.pl # RCSId: $Id: 3.0b1-lease-convert,v 1.1.1.1 2012/10/09 09:06:54 misho Exp $ # # Description: Convert 3.0b1 to 3.0b2/final lease file format # require 5.004; my $rcsID =<<'EOM'; $Id: 3.0b1-lease-convert,v 1.1.1.1 2012/10/09 09:06:54 misho Exp $ EOM use strict; my $revstatement =<<'EOS'; switch (ns-update (delete (1, 12, ddns-rev-name, null))) { case 0: unset ddns-rev-name; break; } EOS my $fwdstatement =<<'EOS'; switch (ns-update (delete (1, 1, ddns-fwd-name, leased-address))) { case 0: unset ddns-fwd-name; break; } EOS if (@ARGV && $ARGV[0] =~ m!^-!) { usage(); } # read stdin and write stdout. while (<>) { if (! /^lease\s/) { print; } else { my $lease = $_; while (<>) { $lease .= $_; # in a b1 file we should only see a left curly brace on a lease # lines. Seening it anywhere else means the user is probably # running a b2 or later file through this. # Ditto for a 'set' statement. if (m!\{! || m!^\s*set\s!) { warn "this doesn't look like a 3.0b1 file. Ignoring rest.\n"; print $lease; dumpRestAndExit(); } last if m!^\}\s*$!; } # $lease contains all the lines for the lease entry. $lease = makeNewLease($lease); print $lease; } } sub usage { my $prog = $0; $prog =~ s!.*/!!; print STDERR <) { print; } exit (0); }