From: Ted Lemon Date: Wed, 18 Apr 2001 19:17:34 +0000 (+0000) Subject: Convert 3.0b1 lease to current. X-Git-Tag: V3-0-3-PBSG0~2^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ca53ccc8be6059d5a0c6ab4275331ed19117cf6f;p=thirdparty%2Fdhcp.git Convert 3.0b1 lease to current. --- diff --git a/contrib/3.0b1-lease-convert b/contrib/3.0b1-lease-convert new file mode 100755 index 000000000..049a3a7a9 --- /dev/null +++ b/contrib/3.0b1-lease-convert @@ -0,0 +1,126 @@ +#!/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 2001/04/18 19:17:34 mellon 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 2001/04/18 19:17:34 mellon 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); +}