udev_retry 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/sh
  2. ########################################################################
  3. # Begin udev_retry
  4. #
  5. # Description : Udev cold-plugging script (retry)
  6. #
  7. # Authors : Alexander E. Patrakov
  8. # DJ Lucas - dj@linuxfromscratch.org
  9. # Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
  10. # Bryan Kadzban -
  11. #
  12. # Version : LFS 7.0
  13. #
  14. ########################################################################
  15. ### BEGIN INIT INFO
  16. # Provides: udev_retry
  17. # Required-Start: udev
  18. # Should-Start: $local_fs
  19. # Required-Stop:
  20. # Should-Stop:
  21. # Default-Start: S
  22. # Default-Stop:
  23. # Short-Description: Replays failed uevents and creates additonal devices.
  24. # Description: Replays any failed uevents that were skipped due to
  25. # slow hardware initialization, and creates those needed
  26. # device nodes
  27. # X-LFS-Provided-By: LFS
  28. ### END INIT INFO
  29. . /lib/lsb/init-functions
  30. case "${1}" in
  31. start)
  32. log_info_msg "Retrying failed uevents, if any..."
  33. # As of udev-186, the --run option is no longer valid
  34. #rundir=$(/sbin/udevadm info --run)
  35. rundir=/run/udev
  36. # From Debian: "copy the rules generated before / was mounted
  37. # read-write":
  38. for file in ${rundir}/tmp-rules--*; do
  39. dest=${file##*tmp-rules--}
  40. [ "$dest" = '*' ] && break
  41. cat $file >> /etc/udev/rules.d/$dest
  42. rm -f $file
  43. done
  44. # Re-trigger the uevents that may have failed,
  45. # in hope they will succeed now
  46. /bin/sed -e 's/#.*$//' /etc/sysconfig/udev_retry | /bin/grep -v '^$' | \
  47. while read line ; do
  48. for subsystem in $line ; do
  49. /sbin/udevadm trigger --subsystem-match=$subsystem --action=add
  50. done
  51. done
  52. # Now wait for udevd to process the uevents we triggered
  53. /sbin/udevadm settle
  54. evaluate_retval
  55. ;;
  56. *)
  57. echo "Usage ${0} {start}"
  58. exit 1
  59. ;;
  60. esac
  61. exit 0
  62. # End udev_retry