-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdelete-subnet
executable file
·50 lines (37 loc) · 918 Bytes
/
delete-subnet
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/local/bin/perl -w
#
# $Id$
#
# script to manually add a subnet to our database
#
use strict;
use HOSTDB;
use Getopt::Long;
use vars qw ($opt_debug $opt_force $opt_quiet);
my %o = ();
my $res = GetOptions (
"debug",
"force",
"quiet"
);
my $debug = defined ($opt_debug);
my $subnet_name = shift;
if (! $subnet_name) {
die(<<EOT);
Syntax: [options] $0 subnet
options:
--force really delete the subnet
EOT
}
my $hostdb = HOSTDB::DB->new (inifile => HOSTDB::get_inifile (),
debug => $debug
);
my $subnet = $hostdb->findsubnet ($subnet_name);
die ("Could not find subnet '$subnet_name' in database\n") if (! $subnet);
if (! defined ($opt_force)) {
die ("Not removing subnet $subnet_name, you have to delete with force.\n");
}
if (! $subnet->delete ($opt_force?"YES":"WELL, UHH")) {
die ("Could not delete subnet '$subnet_name': $subnet->{error}\n");
}
exit (0);