Merge pull request #316 from ae6xe/update3

bugfix: bogus warning when selecting firmware file to sysupgrade
This commit is contained in:
Joe AE6XE 2018-12-20 05:22:17 -08:00 committed by GitHub
commit 27f4356a46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 27 additions and 23 deletions

View File

@ -103,8 +103,8 @@ $uciserverpath=`uci get aredn.\@downloads[0].firmwarepath`;
chomp($uciserverpath);
push @serverpaths, $uciserverpath;
$hardwaretype = `/usr/local/bin/get_hardwaretype`;
chomp($hardwaretype);
${hardwaretype} = `/usr/local/bin/get_hardwaretype`;
chomp(${hardwaretype});
# handle TPLink and Mikrotik exception conditions
$mfg=`/usr/local/bin/get_hardware_mfg`;
@ -119,38 +119,42 @@ if($mfg=~ /Ubiquiti/i)
$mfgprefix="cpe";
}
if($hardwaretype eq "nanostation-m")
if(${hardwaretype} eq "nanostation-m")
{
$hardwaretypev="nano-m";
} elsif($hardwaretype eq "rb-952ui-5ac2nd") {
$hardwaretypev= "rb-nor-flash-16M-ac" ; # hAP AC Lite
} elsif($hardwaretype =~ /rb-912uag-[25]hpnd/i ) {
$hardwaretypev= "nand-large" ; # Basebox 2/5
${hardwaretypev}="nano-m";
} elsif(${hardwaretype} eq "rb-952ui-5ac2nd") {
${hardwaretypev}= "rb-nor-flash-16M-ac" ; # hAP AC Lite
} elsif(${hardwaretype} =~ /rb-911g-[25]hpnd/i or
${hardwaretype} =~ /rb-912uag-[25]hpnd/i ) {
${hardwaretypev}= "nand-large" ; # Basebox 2/5 and QRT 2/5
} elsif(${hardwaretype} =~ /rb-l[dfhg]+-[25]nd/i or
${hardwaretype} =~ /rb-lhg-[25]hpnd/i ) {
${hardwaretypev}= "rb-nor-flash-16M" ; # LHGs & LDFs
} elsif($mfgprefix eq "cpe" ) {
$hwmodel = `/usr/local/bin/get_model`;
chomp($hwmodel);
if($hwmodel =~ /CPE210 v1\.[01]/i)
{
$hardwaretypev= "210-220-v1" ; # v1.0/v1.1
${hardwaretypev}= "210-220-v1" ; # v1.0/v1.1
} elsif($hwmodel =~ /CPE210 v2\.0/i) {
$hardwaretypev= "210-v2" ; # v2.0
${hardwaretypev}= "210-v2" ; # v2.0
} elsif($hwmodel =~ /CPE210 v3\.0/i) {
$hardwaretypev= "210-v3" ; # v3.0
${hardwaretypev}= "210-v3" ; # v3.0
} elsif($hwmodel =~ /CPE220 v2\.0/i) {
$hardwaretypev= "220-v2" ; # v3.0
${hardwaretypev}= "220-v2" ; # v3.0
} elsif($hwmodel =~ /CPE220 v3\.0/i) {
$hardwaretypev= "220-v3" ; # v3.0
${hardwaretypev}= "220-v3" ; # v3.0
} elsif($hwmodel =~ /CPE510 v2\.0/i) {
$hardwaretypev= "510-v2" ; # v2.0
${hardwaretypev}= "510-v2" ; # v2.0
} elsif($hwmodel =~ /CPE510 v3\.0/i) {
$hardwaretypev= "510-v3" ; # v3.0
${hardwaretypev}= "510-v3" ; # v3.0
} elsif($hwmodel =~ /CPE510/i) {
$hardwaretypev= "510-520-v1" ; # CPE510 V1.0/v1.1
${hardwaretypev}= "510-520-v1" ; # CPE510 V1.0/v1.1
} elsif($hwmodel =~ /CPE610/i) {
$hardwaretypev= "610-v1" ; # CPE610 V1.0
${hardwaretypev}= "610-v1" ; # CPE610 V1.0
}
} else {
$hardwaretypev=$hardwaretype;
${hardwaretypev}=${hardwaretype};
}
# refresh fw
@ -163,7 +167,7 @@ if($parms{button_refresh_fw})
$ok = 0;
foreach $serverpath (@serverpaths)
{
system "$wget -O /tmp/web/firmware.list $serverpath/firmware.$hardwaretype.list >/dev/null 2>>$tmpdir/wget.err";
system "$wget -O /tmp/web/firmware.list $serverpath/firmware.${hardwaretype}.list >/dev/null 2>>$tmpdir/wget.err";
unless($?) { $ok = 1; last }
}
if($ok) { push @fw_output, "Done.\n" }
@ -605,15 +609,15 @@ print <<EOF;
<script>
function validateFirmwareFilename(elem){
var hwmfg = "$mfgprefix";
var hwtype = "$hardwaretypev";
var hwtype = "${hardwaretypev}";
var searchstring = "";
var efn = "";
if(hwmfg != "cpe"){
searchstring= ".*-" + hwtype + "-sysupgrade.bin$\";
efn = "aredn-$fw_version-$mfgprefix-$hardwaretypev-sysupgrade.bin";
efn = "aredn-$fw_version-$mfgprefix-${hardwaretypev}-sysupgrade.bin";
} else {
searchstring= ".*cpe" + hwtype + "-sysupgrade.bin$\";
efn = "aredn-$fw_version-$mfgprefix$hardwaretypev-sysupgrade.bin";
efn = "aredn-$fw_version-$mfgprefix${hardwaretypev}-sysupgrade.bin";
}
var re = new RegExp(searchstring,"g");
if(elem.value.match(re)){
@ -661,7 +665,7 @@ if(@fw_output)
print "<tr><td align=center colspan=3>current version: $fw_version</td></tr>\n";
print "<tr><td align=center colspan=3>hardware type: $mfgprefix ($hardwaretype)</td></tr>\n";
print "<tr><td align=center colspan=3>hardware type: $mfgprefix (${hardwaretype})</td></tr>\n";
print "<tr>\n";
print "<td>Upload Firmware</td>\n";