home *** CD-ROM | disk | FTP | other *** search
/ ftp.jcu.edu.au / 2014.06.ftp.jcu.edu.au.tar / ftp.jcu.edu.au / v6.3.2b / SWBD63 / fabos-6.3.2b-10.ppc.rpm / fabos-6.3.2b.10.cpio.gz / fabos-6.3.2b.10.cpio / fabos / libexec / ifmode_to_ethmode.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  2010-11-10  |  1KB  |  60 lines

  1. #!/bin/bash
  2. # Passed a file name containing the old mii-tool based script to set
  3. # ethernet link modes, this script will make the equivalent exec of ethmode.
  4.  
  5. # populate $2,$3,$4 with auto/forced, desired link mode(s), interface
  6. set -- `/bin/cat $1`
  7. auto_forced=1
  8. mode=0
  9.  
  10. # -F means force a single mode
  11. match=`/usr/bin/expr match $2 ".*-F.*"`
  12. if [ "$match" -ne 0 ]
  13. then
  14.     auto_forced=0
  15. fi
  16.  
  17. # 10HD => bit 0x01
  18. match=`/usr/bin/expr match $3 ".*10baseT-HD.*"`
  19. if [ "$match" -ne 0 ]
  20. then
  21.     let "mode += 1"
  22. fi
  23.  
  24. # 10FD => bit 0x02
  25. match=`/usr/bin/expr match $3 ".*10baseT-FD.*"`
  26. if [ "$match" -ne 0 ]
  27. then
  28.     let "mode += 2"
  29. fi
  30.  
  31. # 100HD => bit 0x04
  32. match=`/usr/bin/expr match $3 ".*100baseTx-HD.*"`
  33. if [ "$match" -ne 0 ]
  34. then
  35.     let "mode += 4"
  36. fi
  37.  
  38. # 100FD => bit 0x08
  39. match=`/usr/bin/expr match $3 ".*100baseTx-FD.*"`
  40. if [ "$match" -ne 0 ]
  41. then
  42.     let "mode += 8"
  43. fi
  44.  
  45. # 1000HD => bit 0x10
  46. match=`/usr/bin/expr match $3 ".*1000baseT-HD.*"`
  47. if [ "$match" -ne 0 ]
  48. then
  49.     let "mode += 16"
  50. fi
  51.  
  52. # 1000FD => bit 0x20
  53. match=`/usr/bin/expr match $3 ".*1000baseT-FD.*"`
  54. if [ "$match" -ne 0 ]
  55. then
  56.     let "mode += 32"
  57. fi
  58.  
  59. /fabos/libexec/ethmode $4 $auto_forced $mode
  60.