[Lunar-commits] <lunar> Merge pull request #35 from Ratler/remove_ifconfig

Auke Kok sofar+github at foo-projects.org
Sat Jan 5 08:44:56 CET 2013


commit eeb701042f7bc67ee7783c7d1020cabc0fe1593d
Author: Auke Kok <sofar+github at foo-projects.org>
Date: Fri, 04 Jan 2013 23:44:56 -0800
URL: https://github.com/lunar-linux/lunar/commit/eeb701042f7bc67ee7783c7d1020cabc0fe1593d

Merge pull request #35 from Ratler/remove_ifconfig

Replace the use of net-tools with iproute
---
  libs/connect.lunar | +2/-2     
  libs/uniqid.lunar  | +5/-14    
  misc/sustained     | +1/-1     
  3 files changed

--- 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\""
--- a/misc/sustained
+++ b/misc/sustained
@@ -19,6 +19,7 @@ gmp
 grep
 gzip
 installwatch
+iproute2
 kmod
 less
 libcap
@@ -29,7 +30,6 @@ make
 mpfr
 nano
 ncurses
-net-tools
 patch
 procps
 readline




More information about the Lunar-commits mailing list