blob: a7e99766ab1c048e99550e62280d78279201d08e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#!/usr/bin/perl -Tw
use strict;
use vars qw( $user $block @blocks );
use FS::UID qw(adminsuidsetup);
use FS::Record qw(qsearch);
use FS::addr_block;
use FS::svc_broadband;
$user = shift or die &usage;
&adminsuidsetup( $user );
@blocks = qsearch('addr_block', {} );
die "No address blocks" unless (scalar(@blocks) > 0);
foreach $block (@blocks) {
my @devices = qsearch('svc_broadband', { 'blocknum' => $block->blocknum } );
if (@devices) {
print "Skipping block " . $block->ip_gateway . " / " . $block->ip_netmask;
print "\n";
}else{
print "Deleting block " . $block->ip_gateway . " / " . $block->ip_netmask;
print "\n";
$block->delete;
}
}
sub usage {
"Usage:\n freeside-delete-addr_blocks user \n";
}
|