summaryrefslogtreecommitdiff
path: root/FS/bin
diff options
context:
space:
mode:
authorjeff <jeff>2007-02-13 00:45:15 +0000
committerjeff <jeff>2007-02-13 00:45:15 +0000
commit2ad0e0e11a03687ffa22da4750c831933bc6268b (patch)
tree85156cd3c4f65407b635c479bc7c92c75ff68af0 /FS/bin
parent2f7205c859dd4d36aaa86c11e98ec1b48f4cc34b (diff)
for dumping addr_blocks
Diffstat (limited to 'FS/bin')
-rwxr-xr-xFS/bin/freeside-delete-addr_blocks31
1 files changed, 31 insertions, 0 deletions
diff --git a/FS/bin/freeside-delete-addr_blocks b/FS/bin/freeside-delete-addr_blocks
new file mode 100755
index 000000000..a7e99766a
--- /dev/null
+++ b/FS/bin/freeside-delete-addr_blocks
@@ -0,0 +1,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";
+}