home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / boot / i386 / rescue / lib / udev / trigger_firmware_loading.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  2006-11-29  |  971b  |  40 lines

  1. #! /bin/bash
  2.  
  3. . /etc/sysconfig/hardware/scripts/functions
  4.  
  5. NOMAC_HACK_APPLIED=no
  6. trap 'echo NOMAC_HACK_APPLIED=$NOMAC_HACK_APPLIED
  7.       echo ADDRESS=$MAC_ADDRESS' EXIT
  8.  
  9. case "$1" in
  10.     eth*|ath*|wlan*|ra*) : ;;
  11.     *) exit 0 ;;
  12. esac
  13.  
  14. MAC_ADDRESS=
  15. if ls /sys/class/net/$1 2>/dev/null 1>&2; then
  16.     MAC_ADDRESS=`cat /sys/class/net/$INTERFACE/address`
  17. fi
  18. if [ -z "$MAC_ADDRESS" ] ; then
  19.     exit 0
  20. fi
  21. if [ "${MAC_ADDRESS%00:00:00}" != "$MAC_ADDRESS" ] ; then
  22.     # Workaround for some drivers which don't request their
  23.     # firmware before beeing set up and don't have a mac address
  24.     # before firmware was loaded.
  25.     ip link set up dev $INTERFACE
  26.     ip link set down dev $INTERFACE
  27.     # Do we have to wait some time?
  28.     for i in 0 1 2 3 4 5 6 7 8 9; do
  29.         MAC_ADDRESS=`cat /sys/class/net/$INTERFACE/address`
  30.         info_mesg "waiting for a usefull mac address: $MAC_ADDRESS"
  31.         if [ "${MAC_ADDRESS%00:00:00}" != "$MAC_ADDRESS" ] ; then
  32.             NOMAC_HACK_APPLIED=yes
  33.             break
  34.         fi
  35.         sleep 1
  36.     done
  37. fi
  38.  
  39. exit 0
  40.