Advertisement
s243a

testInterface() - /usr/sbin/net-setup.sh - puppylinux

Oct 9th, 2016
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.34 KB | None | 0 0
  1. # lines 992 to 1063 of /usr/sbin/net-setup.sh
  2. # http://www.pearltrees.com/s243a/testinterface-setup-puppylinux/id16441463
  3. testInterface()
  4. {
  5.   INTERFACE="$1"
  6.  
  7.   (
  8.     UNPLUGGED="false"
  9.     ifconfig "$INTERFACE" | grep ' UP ' >> $DEBUG_OUTPUT 2>&1
  10.     if [ ! $? -eq 0 ];then #=0 if found
  11.         #cleanUpInterface "$INTERFACE" >> $DEBUG_OUTPUT 2>&1
  12.         # Dougal: add check for error -- maybe it fails to be raised?
  13.         if ! ERROR=$(ifconfig "$INTERFACE" up 2>&1) ; then
  14.           giveErrorDialog "$L_MESSAGE_Failed_Raise_Interface_p1 $INTERFACE.
  15. $L_MESSAGE_Failed_Raise_Interface_p2 ifconfig $INTERFACE up
  16. $L_MESSAGE_Failed_Raise_Interface_p3
  17. $ERROR
  18. "
  19.         fi
  20.     fi
  21.     #BK1.0.7 improved link-beat detection...
  22.     echo "X"
  23.   #091108 old ifplugstatus now -0.18, latest is just 'ifplugstatus'...
  24.   # 25feb10: shinobar: old and new ifplugstatus
  25.   IFPLUGOLD=ifplugstatus
  26.   IFPLUGNEW=ifplugstatus
  27.   [ -x /sbin/ifplugstatus-0.18 ] && IFPLUGOLD=ifplugstatus-0.18
  28.   [ -x /sbin/ifplugstatus-0.25 ] && IFPLUGNEW=ifplugstatus-0.25
  29.     if ! $IFPLUGOLD "$INTERFACE" | grep -F -q 'link beat detected' ;then
  30.       sleep 2
  31.       echo "X"
  32.       if ! $IFPLUGNEW "$INTERFACE" | grep -F -q 'link beat detected' ;then
  33.         sleep 2
  34.         echo "X"
  35.         if ! $IFPLUGOLD "$INTERFACE" | grep -F -q 'link beat detected' ;then
  36.           sleep 2
  37.           echo "X"
  38.           if ! $IFPLUGNEW "$INTERFACE" | grep -F -q 'link beat detected' ;then
  39.             # add ethtool test, just in case it helps at times...
  40.             sleep 1
  41.             echo "X"
  42.             if ! ethtool "$INTERFACE" | grep -Fq 'Link detected: yes' ; then
  43.               UNPLUGGED="true"
  44.             fi
  45.           fi
  46.         fi
  47.       fi
  48.     fi
  49.     echo "${UNPLUGGED}" > /tmp/net-setup_UNPLUGGED.txt
  50.   ) | Xdialog --title "$L_TITLE_Network_Wizard" --progress "$L_PROGRESS_Testing_Interface ${INTERFACE}" 0 0 5
  51.  
  52.   UNPLUGGED=$(cat /tmp/net-setup_UNPLUGGED.txt)
  53.  
  54.   if [ "$UNPLUGGED" != "false" ];then #BK1.0.7
  55.     #no cable plugged in, no network connection possible...
  56.     ifconfig "$INTERFACE" down
  57.     BGCOLOR="#ffc0c0"
  58.     if [ "${IS_WIRELESS}" ] ; then
  59.       TOPMSG="$(eval echo $L_TOPMSG_Report_On_Test)
  60. $L_TOPMSG_Unplugged_Wireless"
  61.     else
  62.       TOPMSG="$(eval echo $L_TOPMSG_Report_On_Test)
  63. $L_TOPMSG_Unplugged_Wired"
  64.     RETTEST=1
  65.     fi
  66.   else
  67.     BGCOLOR="#e0ffe0"
  68.     TOPMSG="$(eval echo $L_TOPMSG_Report_On_Test)
  69. $L_TOPMSG_Network_Alive"
  70.         RETTEST=0
  71.   fi
  72.  
  73.   return $RETTEST
  74. } # end of testInterface
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement