Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Advertising

Someone
Monday, April 9th, 2007 at 3:47:11pm MDT 

  1. #!/bin/sh
  2. #
  3. # Firmware-specific hotplug policy agent.
  4. #
  5. # Kernel firmware hotplug params include:
  6. #
  7. # ACTION=%s [add or remove]
  8. # DEVPATH=%s [in 2.5 kernels, /sys/$DEVPATH]
  9. # FIRMWARE=%s
  10. #
  11. # HISTORY:
  12. #
  13. # 24-Jul-2003 Initial version of “new” hotplug agent.
  14. #
  15. # $Id: firmware.agent,v 1.3 2004/03/14 15:52:56 ukai Exp $
  16. #
  17.  
  18. cd /etc/hotplug
  19. . ./hotplug.functions
  20.  
  21. load() {
  22. echo 1 > $SYSFS/$DEVPATH/loading
  23. cat “$1″ > $SYSFS/$DEVPATH/data
  24. echo 0 > $SYSFS/$DEVPATH/loading
  25. exit
  26. }
  27.  
  28. # DEBUG=yes export DEBUG
  29.  
  30. # directories with the firmware files
  31. FIRMWARE_DIRS=”/lib/hotplug/firmware /usr/local/lib/hotplug/firmware /usr/lib/hotplug/firmware”
  32.  
  33. # mountpoint of sysfs
  34. SYSFS=$(sed -n ’s/^.* \([^ ]*\) sysfs .*$/\1/p’ /proc/mounts | sed -e ‘2,$d’)
  35.  
  36. # use /proc for 2.4 kernels
  37. if [ “$SYSFS” = “” ]; then
  38. SYSFS=/proc
  39. fi
  40.  
  41. VERSION=$(uname -r)
  42.  
  43. #
  44. # What to do with this firmware hotplug event?
  45. #
  46. case “$ACTION” in
  47.  
  48. add)
  49. counter=5
  50. while [ ! -e $SYSFS/$DEVPATH/loading -a $counter -gt 0 ]; do
  51. sleep 1
  52. counter=$(($counter - 1))
  53. done
  54.  
  55. if [ $counter -eq 0 ]; then
  56. mesg “$SYSFS/$DEVPATH/ does not exist”
  57. exit 1
  58. fi
  59.  
  60. for DIR in $FIRMWARE_DIRS; do
  61. if [ -e “$DIR/$FIRMWARE-$VERSION” ]; then
  62. load “$DIR/$FIRMWARE-$VERSION”
  63. elif [ -e “$DIR/$FIRMWARE” ]; then
  64. load “$DIR/$FIRMWARE”
  65. fi
  66. done
  67.  
  68. # the firmware was not found
  69. echo -1 > $SYSFS/$DEVPATH/loading
  70.  
  71. ;;
  72.  
  73. remove)
  74. ;;
  75.  
  76. *)
  77. mesg “Firmware ‘$ACTION’ event not supported”
  78. exit 1
  79. ;;
  80.  
  81. esac

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

worth-right