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

  1. #!/bin/sh -e
  2.  
  3. FIRMWARE_DIRS="/lib/firmware /usr/local/lib/firmware"
  4.  
  5. err() {
  6.     echo "$@" >&2
  7.     if [ -x /bin/logger ]; then
  8.     /bin/logger -t "${0##*/}[$$]" "$@"
  9.     fi
  10. }
  11.  
  12. if [ ! -e /sys$DEVPATH/loading ]; then
  13.     err "udev firmware loader misses sysfs directory"
  14.     exit 1
  15. fi
  16.  
  17. for DIR in $FIRMWARE_DIRS; do
  18.     [ -e "$DIR/$FIRMWARE" ] || continue
  19.     echo 1 > /sys$DEVPATH/loading
  20.     cat "$DIR/$FIRMWARE" > /sys$DEVPATH/data
  21.     echo 0 > /sys$DEVPATH/loading
  22.     exit 0
  23. done
  24.  
  25. echo -1 > /sys$DEVPATH/loading
  26. err "Cannot find  firmware file '$FIRMWARE'"
  27. exit 1
  28.