feature: migrate scripts to use get_interface

nvram-setup may be the only script we have to worry about as it may call configs for interfaces that do not exist in the current mode.

By default get_interface will return a static mapping when it can't find an active config entry meaning that eventually get_interface will need an update routine to pull out of local running config

The lack of this update routine should be acceptable for now as we have no GUI for users to change the mapping.
This commit is contained in:
Conrad Lara - KG6JEI 2015-03-24 23:41:51 -07:00
parent 9444716fbd
commit ac93a0346f
4 changed files with 9 additions and 6 deletions

View File

@ -13,8 +13,8 @@ if ( ! $needsrun ){
#Prep some variables
$node = nvram_get("node");
$tactical = nvram_get("tactical");
$mac2 = mac2ip(get_mac("wlan0"), 0);
$dtdmac = mac2ip(get_mac("eth0"), 0);
$mac2 = mac2ip(get_mac(get_interface("wifi")), 0);
$dtdmac = mac2ip(get_mac(get_interface("lan")), 0);
foreach $config ("ap","client","mesh","mesh_ap","router")

View File

@ -73,8 +73,8 @@ die "'$config' is not a valid configuration\n" unless -f "/etc/config.$config/_s
$node = nvram_get("node");
$tactical = nvram_get("tactical");
$mac2 = mac2ip(get_mac("wlan0"), 0);
$dtdmac = mac2ip(get_mac("eth0"), 0);
$mac2 = mac2ip(get_mac(get_interface("wifi")), 0);
$dtdmac = mac2ip(get_mac(get_interface("lan")), 0);
unless($auto)
{

View File

@ -105,7 +105,10 @@ chomp ($dtdmac = `uci -c /etc/local/uci/ -q get hsmmmesh.settings.dtdmac`);
if($dtdmac eq "")
{
# We should always have an eth0 interface on all nodes.
# Not porting get_interface into this file at this time
# as on a firstboot where nvram-setup runs the interfaces
# should not be changed yet.
open(FILE, "/sbin/ifconfig eth0 |") or fail("ERROR: eth0 mac not available");
while(<FILE>)
{

View File

@ -65,7 +65,7 @@ if(-f "/etc/config/dmz-mode")
if ($name = nvram_get("node"))
{
my ($dtdip,$dtdmask,$dtdbcast,$dtdnet);
($dtdip, $dtdmask, $dtdbcast, $dtdnet) = get_ip4_network("eth0.2");
($dtdip, $dtdmask, $dtdbcast, $dtdnet) = get_ip4_network(get_interface("dtdlink"));
push @hosts, qq("$dtdip" "dtdlink.$name.local.mesh");
}