mirror of https://github.com/aredn/aredn.git
feature: Add the ability to upgrade in place and keep settings.
By checking the "Keep Settings" box the node will run sysupgrade instead of mtd. Core settings are stored between installs and the _setup files are updated by pulling in missing items from the _setup.default files.
This commit is contained in:
parent
422e40c5ea
commit
cccf5a2ad7
|
@ -4,6 +4,8 @@
|
||||||
START=99
|
START=99
|
||||||
boot() {
|
boot() {
|
||||||
|
|
||||||
|
[ -x /usr/local/bin/bbhn-postupgrade ] && /usr/local/bin/bbhn-postupgrade
|
||||||
|
|
||||||
# extract kamikaze generated vlan config
|
# extract kamikaze generated vlan config
|
||||||
#CMLARA Not needed on BULLETM's maybe needed on other devices
|
#CMLARA Not needed on BULLETM's maybe needed on other devices
|
||||||
#[ -f /etc/vlan ] || head -n5 /etc/config/network > /etc/vlan
|
#[ -f /etc/vlan ] || head -n5 /etc/config/network > /etc/vlan
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
/etc/config.ap/_setup
|
||||||
|
/etc/config.ap/_setup.dhcp
|
||||||
|
/etc/config.ap/_setup.ports
|
||||||
|
/etc/config.client/_setup
|
||||||
|
/etc/config.client/_setup.dhcp
|
||||||
|
/etc/config.client/_setup.ports
|
||||||
|
/etc/config.mesh/_setup
|
||||||
|
/etc/config.mesh/_setup.dhcp.dmz
|
||||||
|
/etc/config.mesh/_setup.dhcp.nat
|
||||||
|
/etc/config.mesh/_setup.ports.dmz
|
||||||
|
/etc/config.mesh/_setup.ports.nat
|
||||||
|
/etc/config.mesh/_setup.services.dmz
|
||||||
|
/etc/config.mesh/_setup.services.nat
|
||||||
|
/etc/config.mesh_ap/_setup
|
||||||
|
/etc/config.mesh_ap/_setup.dhcp
|
||||||
|
/etc/config.mesh_ap/_setup.ports
|
||||||
|
/etc/config.router/_setup
|
||||||
|
/etc/config.router/_setup.dhcp
|
||||||
|
/etc/config.router/_setup.ports
|
||||||
|
/etc/httpd.conf
|
||||||
|
/etc/local/services
|
||||||
|
/etc/local/uci/hsmmmesh
|
|
@ -0,0 +1,73 @@
|
||||||
|
#!/usr/bin/perl -w -I/www/cgi-bin
|
||||||
|
|
||||||
|
use perlfunc;
|
||||||
|
|
||||||
|
$needsrun=nvram_get("nodeupgraded");
|
||||||
|
|
||||||
|
if ( ! $needsrun ){
|
||||||
|
print "Node not upgraded, exiting\n";
|
||||||
|
exit 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#Prep some variables
|
||||||
|
$node = nvram_get("node");
|
||||||
|
$tactical = nvram_get("tactical");
|
||||||
|
$mac2 = mac2ip(get_mac("wlan0"), 0);
|
||||||
|
$dtdmac = mac2ip(get_mac("eth0"), 0);
|
||||||
|
|
||||||
|
|
||||||
|
foreach $config ("ap","client","mesh","mesh_ap","router")
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
$cfg = ();
|
||||||
|
$defaultcfg = ();
|
||||||
|
|
||||||
|
open(TMPCONFFILE, ">/tmp/.${config}_setup") or die;
|
||||||
|
|
||||||
|
foreach $line (`cat /etc/config.$config/_setup`)
|
||||||
|
{
|
||||||
|
next if $line =~ /^\s*#/;
|
||||||
|
next if $line =~ /^\s*$/;
|
||||||
|
$line =~ /^(\w+)\s*=\s*(.*)$/;
|
||||||
|
|
||||||
|
$cfg{$1} = $2;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach $line (`cat /etc/config.$config/_setup.default`)
|
||||||
|
{
|
||||||
|
next if $line =~ /^\s*#/;
|
||||||
|
next if $line =~ /^\s*$/;
|
||||||
|
$line =~ s/<NODE>/$node/;
|
||||||
|
$line =~ s/<MAC2>/$mac2/;
|
||||||
|
$line =~ s/<DTDMAC>/$dtdmac/;
|
||||||
|
$line =~ /^(\w+)\s*=\s*(.*)$/;
|
||||||
|
$defaultcfg{$1} = $2;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach $variable( sort keys %defaultcfg )
|
||||||
|
{
|
||||||
|
if ( $cfg{$variable} )
|
||||||
|
{
|
||||||
|
print TMPCONFFILE "$variable = $cfg{$variable}\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print TMPCONFFILE "$variable = $defaultcfg{$variable}\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
close (TMPCONFFILE);
|
||||||
|
|
||||||
|
system ("mv /tmp/.${config}_setup /etc/config.$config/_setup");
|
||||||
|
print "Updated mode: $config\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$LASTMODE=nvram_get('config');
|
||||||
|
|
||||||
|
#Commit the new combined config
|
||||||
|
system ("/usr/local/bin/node-setup -a $LASTMODE");
|
||||||
|
nvram_set("nodeupgraded","0");
|
||||||
|
print "Rebooting node";
|
||||||
|
system ("reboot");
|
|
@ -174,8 +174,9 @@ if($parms{button_dl_fw} and $parms{dl_fw} ne "default")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# install fw -- Force overwrite using MTD device
|
|
||||||
# Needs a "not $overwrite_firmware" clause once we get sysupgrade working
|
# install fw
|
||||||
|
|
||||||
if($fw_install and -f "$tmpdir/firmware")
|
if($fw_install and -f "$tmpdir/firmware")
|
||||||
{
|
{
|
||||||
my $junk;
|
my $junk;
|
||||||
|
@ -185,56 +186,44 @@ if($fw_install and -f "$tmpdir/firmware")
|
||||||
print "<h2>The firmware is being updated.</h2>\n";
|
print "<h2>The firmware is being updated.</h2>\n";
|
||||||
print "<h1>DO NOT REMOVE POWER UNTIL UPDATE IS FINISHED</h1>\n";
|
print "<h1>DO NOT REMOVE POWER UNTIL UPDATE IS FINISHED</h1>\n";
|
||||||
print "</center><br>\n";
|
print "</center><br>\n";
|
||||||
print "Writing firmware<br><br>\n";
|
|
||||||
|
|
||||||
unless($debug)
|
unless($debug)
|
||||||
{
|
{
|
||||||
#system "nvram unset config; nvram commit >/dev/null 2>&1";
|
if ( $parms{checkbox_keep_settings} )
|
||||||
nvram_set("config", "");
|
{
|
||||||
|
nvram_set("nodeupgraded","1");
|
||||||
|
print "
|
||||||
|
<center><h2>Firmware will be written in the background.</h2>
|
||||||
|
<h3>If you are connected to the LAN of this node you may need to acquire a new<br>
|
||||||
|
DHCP lease and reset any name service caches you may be using.</h3>
|
||||||
|
<h3>The node will reboot twice while the configuration is applied<br>
|
||||||
|
Wait for the Status 4 LED to start blinking, then stop blinking twice.<br>
|
||||||
|
When the Status 4 LED is solid on you can get your new DHCP lease and reconnect with<br>
|
||||||
|
<a href='http://localnode.local.mesh:8080/'>http://localnode.local.mesh:8080/</a></h3>
|
||||||
|
</center></body></html>
|
||||||
|
";
|
||||||
|
open(FILE, "/sbin/sysupgrade -q $tmpdir/firmware 2>&1 |") or die;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print "Writing firmware<br><br>\n";
|
||||||
open(FILE, "/sbin/mtd write $tmpdir/firmware firmware 2>&1 |") or die;
|
open(FILE, "/sbin/mtd write $tmpdir/firmware firmware 2>&1 |") or die;
|
||||||
while(read FILE, $junk, 7) { print "|" }
|
while(read FILE, $junk, 7) { print "|" }
|
||||||
}
|
|
||||||
|
|
||||||
print "
|
print "
|
||||||
<center><h2>The node is rebooting</h2>
|
<center><h2>The node is rebooting</h2>
|
||||||
<h3>If you are connected to the LAN of this node you may need to acquire a new<br>
|
<h3>If you are connected to the LAN of this node you may need to acquire a new<br>
|
||||||
DHCP lease and reset any name service caches you may be using.</h3>
|
DHCP lease and reset any name service caches you may be using.</h3>
|
||||||
<h3>Wait for the Power LED to start blinking, then stop blinking.<br>
|
<h3>Wait for the Status 4 LED to start blinking, then stop blinking.<br>
|
||||||
When the DMZ LED turns off you can get your new DHCP lease and reconnect with<br>
|
When the Status 4 LED is solid on you can get your new DHCP lease and reconnect with<br>
|
||||||
<a href='http://localnode.local.mesh:8080/'>http://localnode.local.mesh:8080/</a></h3>
|
<a href='http://localnode.local.mesh:8080/'>http://localnode.local.mesh:8080/</a></h3>
|
||||||
</center></body></html>
|
</center></body></html>
|
||||||
";
|
";
|
||||||
|
|
||||||
system "/sbin/reboot" unless $debug;
|
system "/sbin/reboot" unless $debug;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
# CMLARA: Prepwork for using sysupgrade --- it has some issues with the page not returning that need to be worked on
|
|
||||||
# install fw -- use sysupgrade
|
|
||||||
|
|
||||||
#if($fw_install and -f "$tmpdir/firmware" and not $overwrite_firmware )
|
|
||||||
#{
|
|
||||||
# my $junk;
|
|
||||||
# http_header();
|
|
||||||
# html_header("FIRMWARE UPDATE IN PROGRESS", 1);
|
|
||||||
# print "<body><center>\n";
|
|
||||||
# print "<h2>The firmware is being updated.</h2><br><br>\n";
|
|
||||||
# print "<h1>DO NOT REMOVE POWER UNTIL UPDATE IS FINISHED</h1><br><br>\n";
|
|
||||||
# print "<h3>Wait for the Power LED to start blinking, then stop blinking.<br>\n";
|
|
||||||
# print "When the DMZ LED turns off you can reconnect your browser to the mesh node.</h3>\n";
|
|
||||||
# print "</center><br>\n";
|
|
||||||
# print "Writing firmware<br><br>\n";
|
|
||||||
# unless($debug)
|
|
||||||
# {
|
|
||||||
# open(FILE, "/sbin/sysupgrade -q $tmpdir/firmware 2>&1 |") or die;
|
|
||||||
# while(read FILE, $junk, 7) { print "|" }
|
|
||||||
# print "<br><br>REBOOTING<br><br>\n";
|
|
||||||
# print "<a href='http://localnode:8080/cgi-bin/status'>Click here</a> when the blinking stops and the DMZ LED turns off</body></html>\n";
|
|
||||||
# system "/sbin/reboot";
|
|
||||||
# }
|
|
||||||
# exit;
|
|
||||||
#}
|
|
||||||
|
|
||||||
|
|
||||||
# install patch
|
# install patch
|
||||||
if($patch_install and -f "$tmpdir/firmware")
|
if($patch_install and -f "$tmpdir/firmware")
|
||||||
|
@ -498,6 +487,7 @@ foreach(@fw_images)
|
||||||
print "</select>\n";
|
print "</select>\n";
|
||||||
print "<input type=submit name=button_refresh_fw value=Refresh title='download the list of available firmware versions'>\n";
|
print "<input type=submit name=button_refresh_fw value=Refresh title='download the list of available firmware versions'>\n";
|
||||||
print "<td align=center><input type=submit name=button_dl_fw value=Download title='install the firmware'></td>\n";
|
print "<td align=center><input type=submit name=button_dl_fw value=Download title='install the firmware'></td>\n";
|
||||||
|
print "<td align=right><input type=checkbox name=checkbox_keep_settings>Keep Settings</td>\n";
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
print "</table></td></tr>\n";
|
print "</table></td></tr>\n";
|
||||||
|
|
Loading…
Reference in New Issue