Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Provide firmware file advice for uploading firmware files #217

Merged
merged 4 commits into from Oct 10, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
51 changes: 39 additions & 12 deletions files/www/cgi-bin/admin
Expand Up @@ -102,6 +102,9 @@ $patch_install = 0;
"http://downloads.arednmesh.org/firmware/ubnt"
);

$hardwaretype = `/usr/local/bin/get_hardwaretype`;
chomp($hardwaretype);

# refresh fw
if($parms{button_refresh_fw})
{
Expand All @@ -110,8 +113,6 @@ if($parms{button_refresh_fw})
push @fw_output, "Downloading firmware list...\n";
unlink "/tmp/web/firmware.list";
$ok = 0;
$hardwaretype = `/usr/local/bin/get_hardwaretype`;
chomp($hardwaretype);
foreach $serverpath (@serverpaths)
{
system "$wget -O /tmp/web/firmware.list $serverpath/firmware.$hardwaretype.list >/dev/null 2>>$tmpdir/wget.err";
Expand Down Expand Up @@ -551,7 +552,30 @@ system "rm -rf /tmp/web/upload $tmpdir" unless $debug;
#

http_header();
html_header("$node administration", 1);
html_header("$node administration", 0);
print <<EOF;
<script>
function validateFirmwareFilename(elem){
var hwtype = "$hardwaretype";
if(hwtype=="nanostation-m") {
hwtype="nano-m";
}
var searchstring = ".*-" + hwtype + "-sysupgrade.bin$\";
var re = new RegExp(searchstring,"g");
if(elem.value.match(re)){
return true;
}else{
if (confirm('This filename is NOT appropriate for this device!\\n\\nThis device expects a file such as: aredn-$fw_version-<MANUFACTURER>-' + hwtype + '-sysupgrade.bin\\n\\n\\nClick OK to continue if you are CERTAIN that the file is correct.')) {
return true;
} else {
elem.value="";
return false;
}
}
}
</script>
EOF
print "</head>";
print "<body><center>\n";
alert_banner();
print "<form method=post action=admin enctype='multipart/form-data'>\n";
Expand Down Expand Up @@ -582,10 +606,13 @@ if(@fw_output)
}

print "<tr><td align=center colspan=3>current version: $fw_version</td></tr>\n";
$hardwaretype=`/usr/local/bin/get_hardwaretype`;
chomp($hardwaretype);
print "<tr><td align=center colspan=3>hardware type: $hardwaretype</td></tr>\n";

print "<tr>\n";
print "<td>Upload Firmware</td>\n";
print "<td><input type=file name=firmfile title='choose the firmware file to install from your hard drive'></td>\n";
print "<td><input type=file name=firmfile title='choose the firmware file to install from your hard drive' accept='.bin' onchange='validateFirmwareFilename(this)'></td>\n";
print "<td align=center><input type=submit name=button_ul_fw value=Upload title='install the firmware'";
if($tunnel_active) { print " disabled"; };
print "></td>\n";
Expand All @@ -594,10 +621,10 @@ print "</tr>\n";
print "<tr>\n";
print "<td>Download Firmware</td>\n";
print "<td><select name=dl_fw style='font-family:monospace'>\n";
selopt_pre("- Select Firmware -", "default", "default");
selopt("- Select Firmware -", "default", "default");
foreach(@fw_images)
{
selopt_pre($_, $_, "default");
selopt($_, $_, "default");
}
print "</select>\n";
print "<input type=submit name=button_refresh_fw value=Refresh title='download the list of available firmware versions'>\n";
Expand Down Expand Up @@ -640,10 +667,10 @@ print "</tr>\n";
print "<tr>\n";
print "<td>Download Package</td>\n";
print "<td><select name=dl_pkg style='font-family:monospace'>\n";
selopt_pre("- Select Package -", "default", "default");
selopt("- Select Package -", "default", "default");
foreach $pkg (@dl_pkgs)
{
selopt_pre("$pkg $dlpkgver{$pkg}", $pkg, "default");
selopt("$pkg $dlpkgver{$pkg}", $pkg, "default");
}
print "</select>\n";
print "<input type=submit name=button_refresh_pkg value=Refresh title='download the list of available packages (warning: this takes a lot of space)'>\n";
Expand All @@ -653,11 +680,11 @@ print "</tr>\n";
print "<tr>\n";
print "<td>Remove Package</td>\n";
print "<td><select name=rm_pkg style='font-family:monospace'>\n";
selopt_pre("- Select Package -", "default", "default");
selopt("- Select Package -", "default", "default");
foreach $pkg (@pkgs)
{
$opt = $permpkg{$pkg} ? "disabled" : "";
selopt_pre("$pkg $pkgver{$pkg}", $pkg, "default", $opt);
selopt("$pkg $pkgver{$pkg}", $pkg, "default", $opt);
}
print "</select></td>\n";
print "<td align=center><input type=submit name=button_rm_pkg value=Remove title='remove the selected package'></td>\n";
Expand Down Expand Up @@ -693,10 +720,10 @@ print "</tr>\n";
print "<tr>\n";
print "<td>Remove Key</td>\n";
print "<td><select name=rm_key style='font-family:monospace'>\n";
selopt_pre("- Select Key -", "default", "default");
selopt("- Select Key -", "default", "default");
foreach(@keys)
{
selopt_pre($_, $_, "default");
selopt($_, $_, "default");
}
print "</select>\n";
print "<td align=center><input type=submit name=button_rm_key value=Remove title='remove the selected key'></td>\n";
Expand Down