version 1.12, 2005/12/29 18:41:17 |
version 1.14, 2005/12/30 19:26:06 |
|
|
#!/usr/bin/perl
|
#!/usr/bin/perl
|
# $RedRiver: update_trango.pl,v 1.11 2005/12/21 02:03:30 andrew Exp $
|
# $RedRiver: update_trango.pl,v 1.13 2005/12/30 01:02:41 andrew Exp $
|
########################################################################
|
########################################################################
|
# update_trango.pl *** Updates trango foxes with a new firmware
|
# update_trango.pl *** Updates trango foxes with a new firmware
|
#
|
#
|
|
|
$l->sp("Updating: $fox");
|
$l->sp("Updating: $fox");
|
|
|
## Connect and login.
|
## Connect and login.
|
my $t = new Net::Telnet::Trango ({
|
my $t = new Net::Telnet::Trango (
|
Host => $fox,
|
|
Timeout => 5,
|
Timeout => 5,
|
});
|
Errmode => 'return',
|
|
) or die "Couldn't make new connection: $!";
|
|
|
$l->p("Connecting to $fox");
|
$l->p("Connecting to $fox");
|
my ($type, $version) = $t->connect();
|
unless ( $t->open($fox) ) {
|
|
$l->sp("Error connecting: $!");
|
unless (defined $type && defined $version) {
|
|
$l->sp("Error connecting!");
|
|
next;
|
next;
|
}
|
}
|
|
|
if ($type ne $conf->{'type'}) {
|
if ($t->host_type ne $conf->{'type'}) {
|
$l->sp("Wrong type of unit ('$type' should be '$conf->{'type'}')");
|
$l->sp("Wrong type of unit ('$t->host_type' should be '$conf->{'type'}')");
|
$t->close;
|
$t->close;
|
next;
|
next;
|
}
|
}
|
|
|
if ($version eq $conf->{'ver'}) {
|
if ($t->firmware_version eq $conf->{'ver'}) {
|
$l->sp("Already up to date with firmware version '$version'");
|
$l->sp("Already up to date with firmware version '$t->firmware_version'");
|
$t->close;
|
$t->close;
|
next;
|
next;
|
}
|
}
|
|
|
|
|
$l->p("Sending commands");
|
$l->p("Sending commands");
|
## Send commands
|
## Send commands
|
|
#print Dump $t->login_banner;
|
|
#print Dump $t->sysinfo;
|
|
#print Dump $t->last_lines;
|
#print Dump $t->ver();
|
#print Dump $t->ver();
|
#print Dump $t->tftpd();
|
print Dump $t->tftpd();
|
if ( upload($t, $conf->{'file_name'}) ) {
|
print Dump $t->enable_tftpd();
|
$l->p("Rebooting");
|
#print Dump [ "Exit", $t->exit ];
|
$t->reboot;
|
print Dump $t->tftpd();
|
} else {
|
print Dump $t->disable_tftpd();
|
|
print Dump $t->tftpd();
|
|
#if ( upload($t, $conf->{'file_name'}) ) {
|
|
# $l->p("Rebooting");
|
|
# $t->reboot;
|
|
#} else {
|
$l->p("Exiting");
|
$l->p("Exiting");
|
$t->exit;
|
$t->exit;
|
}
|
#}
|
|
|
$t->close;
|
|
$l->sp("");
|
$l->sp("");
|
}
|
}
|
|
|
|
|
|
|
$l->p("Updating flash (new checksum '$conf->{'cksum'}')");
|
$l->p("Updating flash (new checksum '$conf->{'cksum'}')");
|
unless ($results = $t->updateflash(
|
unless ($results = $t->updateflash(
|
$ver->{'Firmware Checksum'}, $conf->{'cksum'}
|
args => 'mainimage ' . $ver->{'Firmware Checksum'} .
|
|
' ' . $conf->{'cksum'},
|
|
Timeout => 90,
|
) ) {
|
) ) {
|
$l->sp("Couldn't update flash: $!");
|
$l->sp("Couldn't update flash: $!");
|
next;
|
next;
|