[Lunar-commits] <lunar> Replace the use of net-tools with iproute

Stefan Wold ratler at lunar-linux.org
Fri Jan 4 14:15:25 CET 2013


commit 54774e2b6d32388a880920637790da400e7d1306
Author: Stefan Wold <ratler at lunar-linux.org>
Date: Fri, 04 Jan 2013 05:15:25 -0800
URL: https://github.com/lunar-linux/lunar/commit/54774e2b6d32388a880920637790da400e7d1306

Replace the use of net-tools with iproute
---
  libs/connect.lunar | +2/-2     
  libs/uniqid.lunar  | +5/-14    
  2 files changed, 7 insertions(+), 16 deletions(-)

--- a/libs/connect.lunar
+++ b/libs/connect.lunar
@@ -37,14 +37,14 @@ connect()  {
   local TIMEOUT
   debug_msg "connect ($@)"
 
-  if ! ifconfig | grep -q "^eth[0-9]\|^wlan[0-9]\|^ppp[0-9]\|^ath[0-9]\|^tun[0-9]\|^ra[0-9]\|^usb[0-9]"
+  if ! ip link | egrep -q '^[0-9]*: (eth|wlan|ppp|ath|tun|ra|usb)[0-9]+.*state UP'
   then
     pon
 
     # Timeout in deciseconds to wait for Interface to come up.
     TIMEOUT=30
 
-    until ifconfig | grep -q "^eth[0-9]\|^wlan[0-9]\|^ppp[0-9]\|^ath[0-9]\|^tun[0-9]\|^ra[0-9]\|^usb[0-9]" || [ $TIMEOUT == 0  ]
+    until ip link | egrep -q '^[0-9]*: (eth|wlan|ppp|ath|tun|ra|usb)[0-9]+.*state UP' || [ $TIMEOUT == 0  ]
     do
       sleep  10
       (( TIMEOUT-- ))
--- a/libs/uniqid.lunar
+++ b/libs/uniqid.lunar
@@ -6,6 +6,8 @@
 #                                                          #
 # Copyright Fw systems LLC Under eitherGPL v2 or BSD Lic.  #
 #                                                          #
+# Parts Copyrighted  Stefan Wold 2013 under GPLv2          #
+#                                                          #
 ############################################################
 
 
@@ -28,21 +30,10 @@ create_uniq_id() {
     return
   fi
 
-  OS=$(uname -s)
-
-  if [  "$OS"  == "OpenBSD" ]; then
-    HASH="sha1"
-    IFACE=`netstat -r | grep default | awk '{print $7}'`
-  elif [  "$OS"  == "Linux" ]; then
-    HASH="md5sum"
-    IFACE=`netstat -r | grep default | awk '{print $8}'`
-  else
-    exit 1
-  fi
+  IFACE=$(ip route | grep ^default | awk '{print $5}')
+  UNIQID=$(ip addr show $IFACE | grep 'link/ether' | awk '{print $2}' |\
+      tr 'A-Z' 'a-z' | md5sum | awk '{print $1}')
 
-  UNIQID=`ifconfig $IFACE |\
-      awk '/addr.*[:]* [0-9a-fA-F][0-9a-fA-F]:[0-9a-fA-F][0-9a-fA-F]/ {print $NF}' |\
-      tr 'A-Z' 'a-z' | $HASH | awk '{print $1}'`
   export UNIQID
 
   verbose_msg "id(\"$IFACE\")=\"$UNIQID\""




More information about the Lunar-commits mailing list