5 use FS::UID qw(adminsuidsetup);
6 use FS::Record qw(qsearch qsearchs);
8 use FS::part_svc_router;
13 $FS::svc_Common::noexport_hack = 1; #Disable exports!
15 my $user = shift if $ARGV[0] or die &usage;
16 adminsuidsetup($user);
18 my $remapfile = shift if $ARGV[0] or die &usage;
19 my $old_blocknum = shift if $ARGV[0] or die &usage;
20 my $new_blocknum = shift if $ARGV[0] or die &usage;
21 my $old_svcnum = shift if $ARGV[0];
25 open(REMAP, "<$remapfile") or die $!;
27 next unless (/^([0-9\.]+)\s+([0-9\.]+)$/);
28 my ($old_ip, $new_ip) = ($1, $2);
29 $ipmap{$old_ip} = $new_ip;
35 @svcs = ( qsearchs('svc_broadband', { svcnum => $old_svcnum,
36 blocknum => $old_blocknum }) );
38 @svcs = qsearch('svc_broadband', { blocknum => $old_blocknum });
41 foreach my $old_sb (@svcs) {
43 my $old_ip = $old_sb->ip_addr;
44 my $new_ip = $ipmap{$old_ip};
45 print "Renumbering ${old_ip} (${old_blocknum}) => ${new_ip} (${new_blocknum})...\n";
48 my $new_sb = new FS::svc_broadband
51 blocknum => $new_blocknum,
52 svcpart => $old_sb->cust_svc->svcpart,
55 my $error = $new_sb->replace($old_sb);
68 svc_broadband.renumber user remapfile old_blocknum new_blocknum [ svcnum ]
71 old_ip_address new_ip_address
76 10.0.0.20 192.168.0.20
79 Warning: This assumes your routers have already been reconfigured with the
80 new addresses. Exports will not be run!