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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
#!/usr/bin/perl
sub install
{
my $config_file;
if (-e ($config_file = "/etc/snmp/snmpd.conf") ||
-e ($config_file = "/etc/snmpd.conf"))
{
my $tag = "dlmod iscsiTargetMib /usr/lib/snmp/dlmod/iscsiTargetMib.so\n";
my $body = `cat $config_file`;
$body =~ s/dlmod.*iscsiTargetMib.so\n//g;
$body .= $tag;
$body =~ s/view.*.*.enterprises.1055\n//g;
$body =~ s/^(view\s+systemview\s+included)/view systemview included enterprises.1055\n$1/m;
$body =~ s/rocommunity\s+public\s+127.0.0.1/rocommunity public/g;
open(FILE,">$config_file") || die "Could not recreate $config_file";
print FILE $body;
close FILE;
}
}
sub uninstall
{
my $config_file;
if (-e ($config_file = "/etc/snmp/snmpd.conf") ||
-e ($config_file = "/etc/snmpd.conf"))
{
my $body = `cat $config_file`;
$body =~ s/view.*.*.enterprises.1055\n//g;
$body =~ s/dlmod.*iscsiTargetMib.so\n//g;
open(FILE,">$config_file") || die "Could not recreate $config_file";
print FILE $body;
close FILE;
}
}
$action = shift @ARGV;
if ($action eq "install")
{
install(@ARGV);
}
elsif ($action eq "uninstall")
{
uninstall(@ARGV);
}
else
{
die "Error";
}
|