feature: Allow supporttool to be run from shell

Allows the supporttool to generate support files
when run from the shell for times that it may
be required when the web interface is offline.

Change-Id: I696289ea10c2e5b57f3e93d81ec7004469c4bba0
This commit is contained in:
Conrad Lara - KG6JEI 2016-12-25 13:40:57 -08:00 committed by KG6JEI
parent 1e08847db0
commit e5ff9ebdfb
1 changed files with 21 additions and 6 deletions

View File

@ -144,11 +144,26 @@ chomp($tstamp);
open(my $SDFH, '<', "/tmp/supportdata.tgz") or exit(1);
binmode $SDFH;
print "Content-type: application/x-gzip\r\n";
print "Content-Disposition: attachment; filename=supportdata-$nodename-$tstamp.tgz\r\n";
print "\r\n";
if (exists $ENV{GATEWAY_INTERFACE}) {
print "Content-type: application/x-gzip\r\n";
print "Content-Disposition: attachment; filename=supportdata-$nodename-$tstamp.tgz\r\n";
print "\r\n";
print while <$SDFH>;
undef ($SDFH);
print while <$SDFH>;
undef ($SDFH);
unlink("/tmp/supportdata.tgz");
unlink("/tmp/supportdata.tgz");
} else {
undef ($SDFH);
unlink ("/tmp/supportdata-$nodename-$tstamp.tgz"); # Shouldn't exist but lets be sure
system ("mv", "/tmp/supportdata.tgz", "/tmp/supportdata-$nodename-$tstamp.tgz");
if ($? != 0) {
print "Failed to rename the support data file.\n It may be present at /tmp/supportdata.tgz\n";
exit(1);
} else {
print "File created: /tmp/supportdata-$nodename-$tstamp.tgz\n";
print "Please copy this file and remove from the node\n";
print "to free up resources.\n"
}
}