2014-11-12 22:25:41 -07:00
|
|
|
#!/usr/bin/perl -w -I/www/cgi-bin
|
|
|
|
|
|
|
|
use perlfunc;
|
|
|
|
|
|
|
|
$needsrun=nvram_get("nodeupgraded");
|
|
|
|
|
|
|
|
if ( ! $needsrun ){
|
|
|
|
print "Node not upgraded, exiting\n";
|
|
|
|
exit 0;
|
|
|
|
}
|
|
|
|
|
2016-06-29 20:43:43 -06:00
|
|
|
$config=nvram_get('config');
|
|
|
|
if ($config ne "mesh")
|
|
|
|
{
|
|
|
|
print "This node was previously configured in non-mesh mode and is no longer implemented. Returning to \"firstboot\".\n";
|
|
|
|
system ("firstboot -y && reboot");
|
|
|
|
exit 1;
|
|
|
|
}
|
2014-11-12 22:25:41 -07:00
|
|
|
|
|
|
|
#Prep some variables
|
|
|
|
$node = nvram_get("node");
|
2015-03-25 00:41:51 -06:00
|
|
|
$mac2 = mac2ip(get_mac(get_interface("wifi")), 0);
|
|
|
|
$dtdmac = mac2ip(get_mac(get_interface("lan")), 0);
|
2014-11-12 22:25:41 -07:00
|
|
|
|
2016-06-29 20:43:43 -06:00
|
|
|
$cfg = ();
|
|
|
|
$defaultcfg = ();
|
2014-11-12 22:25:41 -07:00
|
|
|
|
2016-06-29 20:43:43 -06:00
|
|
|
open(TMPCONFFILE, ">/tmp/.mesh_setup") or die;
|
2014-11-12 22:25:41 -07:00
|
|
|
|
2016-06-29 20:43:43 -06:00
|
|
|
foreach $line (`cat /etc/config.mesh/_setup`)
|
|
|
|
{
|
|
|
|
next if $line =~ /^\s*#/;
|
|
|
|
next if $line =~ /^\s*$/;
|
|
|
|
$line =~ /^(\w+)\s*=\s*(.*)$/;
|
2014-11-12 22:25:41 -07:00
|
|
|
|
2016-06-29 20:43:43 -06:00
|
|
|
$cfg{$1} = $2;
|
|
|
|
}
|
2014-11-12 22:25:41 -07:00
|
|
|
|
2016-06-29 20:43:43 -06:00
|
|
|
foreach $line (`cat /etc/config.mesh/_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;
|
|
|
|
}
|
2014-11-12 22:25:41 -07:00
|
|
|
|
2016-06-29 20:43:43 -06:00
|
|
|
foreach $variable( sort keys %defaultcfg )
|
|
|
|
{
|
|
|
|
if ( defined $cfg{$variable} )
|
2014-11-12 22:25:41 -07:00
|
|
|
{
|
2016-06-29 20:43:43 -06:00
|
|
|
print TMPCONFFILE "$variable = $cfg{$variable}\n";
|
2014-11-12 22:25:41 -07:00
|
|
|
}
|
2016-06-29 20:43:43 -06:00
|
|
|
else
|
2014-11-12 22:25:41 -07:00
|
|
|
{
|
2016-06-29 20:43:43 -06:00
|
|
|
print TMPCONFFILE "$variable = $defaultcfg{$variable}\n";
|
2014-11-12 22:25:41 -07:00
|
|
|
}
|
2016-06-29 20:43:43 -06:00
|
|
|
}
|
2014-11-12 22:25:41 -07:00
|
|
|
|
2016-06-29 20:43:43 -06:00
|
|
|
# Specific settings for variables that are not in the default config but are added by the system
|
|
|
|
foreach $variable( 'dmz_dhcp_end', 'dmz_dhcp_limit', 'dmz_dhcp_start', 'dmz_lan_ip', 'dmz_lan_mask', 'wifi_rxant', 'wifi_txant' )
|
|
|
|
{
|
|
|
|
if ( defined $cfg{$variable} )
|
2015-03-23 18:25:18 -06:00
|
|
|
{
|
2016-06-29 20:43:43 -06:00
|
|
|
print TMPCONFFILE "$variable = $cfg{$variable}\n";
|
2015-03-23 18:25:18 -06:00
|
|
|
}
|
2014-11-12 22:25:41 -07:00
|
|
|
}
|
|
|
|
|
2016-06-29 20:43:43 -06:00
|
|
|
close (TMPCONFFILE);
|
|
|
|
|
|
|
|
system ("mv /tmp/.mesh_setup /etc/config.mesh/_setup");
|
|
|
|
print "Updated mode: mesh\n";
|
2014-11-12 22:25:41 -07:00
|
|
|
|
|
|
|
#Commit the new combined config
|
2016-06-29 20:43:43 -06:00
|
|
|
system ("/usr/local/bin/node-setup -a mesh");
|
2014-11-12 22:25:41 -07:00
|
|
|
nvram_set("nodeupgraded","0");
|
|
|
|
print "Rebooting node";
|
|
|
|
system ("reboot");
|