[Lunar-commits] <lunar-tools> Don't use ifconfig in lnet and don't show empty list.

Peter de Ridder peter at lunar-linux.org
Thu Apr 25 21:39:22 CEST 2013


commit 962f3ddf6e7a11a6979745fb73b429a5b02e661f
Author: Peter de Ridder <peter at lunar-linux.org>
Date: Tue, 23 Apr 2013 11:44:34 -0700
URL: https://github.com/lunar-linux/lunar-tools/commit/962f3ddf6e7a11a6979745fb73b429a5b02e661f

Don't use ifconfig in lnet and don't show empty list.
---
  prog/lnet | +14/-3    
  1 file changed, 14 insertions(+), 3 deletions(-)

--- a/prog/lnet
+++ b/prog/lnet
@@ -126,6 +126,7 @@ main ()
   while true; do
     COUNTER=0
     unset LIST
+    unset MANAGE
     for DEVICE in `get_dev_list`; do
       if [ -L $CONFIG_DIR/$DEVICE ]; then
 	      continue
@@ -139,6 +140,9 @@ main ()
 	fi
 	(( COUNTER++ ))
     done
+    if (( COUNTER > 0 )) ; then
+        MANAGE="M\nManage network devices\n"
+    fi
     COMMAND=`$DIALOG  --title "Network configuration" \
                       --ok-label "Select"            \
 		      --cancel-label "Exit"          \
@@ -150,7 +154,7 @@ main ()
                       "D"  "Setup DNS configuration" \
 		      "N"  "Setup host and domain name" \
 		      "G"  "Setup global Gateway" \
-		      "M"  "Manage network devices"`
+		      $(echo -en $MANAGE)`
 
     if [ $? != 0 ] ; then
       return
@@ -281,6 +285,8 @@ function ethernet_menu() {
 }
 
 function ethernet_manage_menu() {
+    NO_INTERFACES="There are no interfaces to be listed. You may want to configure a device first."
+
   while true; do
     unset LIST INTERFACES
     COUNTER=0
@@ -295,6 +301,11 @@ function ethernet_manage_menu() {
 	(( COUNTER++ ))
     done
 
+    if (( COUNTER == 0 )) ; then
+        msgbox "Manage Devices" "$NO_INTERFACES" 7
+        return
+    fi
+
     PROMPT="Select an interface to manage"
     DEVICE=`$DIALOG  --title "Manage Devices"       \
 		     --ok-label "Select"            \
@@ -370,8 +381,8 @@ function ethernet_manage_device() {
         ;;
     esac
 
-    if [[ "$(ifconfig | grep $1 | wc -l)" -ge "1" ]]; then
-        T=1; else T=0
+    if ip link show $1 | grep -q 'state DOWN'; then
+        T=0; else T=1
     fi
 
     if [[ ( "$COMMAND" == "S" && "$TOGGLE" == "Start" && "$T" != "1" ) || 




More information about the Lunar-commits mailing list