mirror of https://github.com/aredn/aredn.git
83 lines
1.9 KiB
Perl
Executable File
83 lines
1.9 KiB
Perl
Executable File
#!/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(get_interface("wifi")), 0);
|
|
$dtdmac = mac2ip(get_mac(get_interface("lan")), 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";
|
|
}
|
|
}
|
|
|
|
# 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";
|
|
}
|
|
}
|
|
|
|
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");
|