Author: tchemineau
Date: 2010-09-23 15:26:51 +0200 (Thu, 23 Sep 2010)
New Revision: 137

Modified:
   openldap-mmr/trunk/functions
Log:
add #282 - use ip command instead of ifconfig

Modified: openldap-mmr/trunk/functions
===================================================================
--- openldap-mmr/trunk/functions        2010-09-23 12:29:48 UTC (rev 136)
+++ openldap-mmr/trunk/functions        2010-09-23 13:26:51 UTC (rev 137)
@@ -333,16 +333,19 @@
 #
 get_local_ipAddresses ()
 {
-  net_interfaces="`/sbin/ifconfig -s | grep -Eiv "^Iface" | grep -Eiv "^lo" \
-    | cut -d' ' -f 1 | perl -p0e 's/\n/ /g'`"
-  ip_address_list=""
+  net_interfaces="`ip link show | grep -v '^ ' | cut -d ':' -f 2 | grep -v 
'lo' \
+     | sed -e 's/ //g'`"
+  net_addresses=""
+
   for net_interface in ${net_interfaces}; do
-    ip_address=`/sbin/ifconfig ${net_interface} | grep -Ei "inet (adr|addr):" \
-      | awk '{print $2}' | sed -e 's/adr://g;s/addr://g'`
-    ip_address_list="${ip_address_list}${net_interface}:${ip_address};"
+    net_address="`ip addr show dev ${net_interface} | grep '^ \+inet ' \
+        | sed -e 's/ \+/ /g;s/^ //' | cut -d ' ' -f 2 | cut -d '/' -f 1`"
+    if [ -n "${net_address}" ]; then
+      net_addresses="${net_addresses}${net_interface}:${net_address};"
+    fi
   done
-  ip_address_list=`echo "${ip_address_list}" | perl -p0e 's/;$//g;'`
-  echo "${ip_address_list}"
+
+  echo "${net_addresses}" | sed -e 's/;$//g'
 }
 
 #

_______________________________________________
ltb-changes mailing list
[email protected]
http://lists.ltb-project.org/listinfo/ltb-changes

Reply via email to