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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#Prep some variables
|
|
|
|
$node = nvram_get("node");
|
|
|
|
$tactical = nvram_get("tactical");
|
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
|
|
|
|
|
|
|
|
|
|
|
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";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-23 18:25:18 -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 ( $cfg{$variable} )
|
|
|
|
{
|
|
|
|
print TMPCONFFILE "$variable = $cfg{$variable}\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-12 22:25:41 -07:00
|
|
|
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");
|