From ac93a0346f8436da5a6cf16fe1aab1c9f0620cd2 Mon Sep 17 00:00:00 2001 From: Conrad Lara - KG6JEI Date: Tue, 24 Mar 2015 23:41:51 -0700 Subject: [PATCH] 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. --- files/usr/local/bin/bbhn-postupgrade | 4 ++-- files/usr/local/bin/node-setup | 4 ++-- files/usr/local/bin/nvram-setup | 5 ++++- files/usr/local/bin/olsrd-config | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/files/usr/local/bin/bbhn-postupgrade b/files/usr/local/bin/bbhn-postupgrade index 59a1cf90..6137bc3a 100755 --- a/files/usr/local/bin/bbhn-postupgrade +++ b/files/usr/local/bin/bbhn-postupgrade @@ -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") diff --git a/files/usr/local/bin/node-setup b/files/usr/local/bin/node-setup index 559065ec..ad6b9455 100755 --- a/files/usr/local/bin/node-setup +++ b/files/usr/local/bin/node-setup @@ -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) { diff --git a/files/usr/local/bin/nvram-setup b/files/usr/local/bin/nvram-setup index 08eecdd9..88fe6617 100755 --- a/files/usr/local/bin/nvram-setup +++ b/files/usr/local/bin/nvram-setup @@ -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() { diff --git a/files/usr/local/bin/olsrd-config b/files/usr/local/bin/olsrd-config index b642fc82..3395cb85 100755 --- a/files/usr/local/bin/olsrd-config +++ b/files/usr/local/bin/olsrd-config @@ -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"); }