init 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/bin/sh -e
  2. ### BEGIN INIT INFO
  3. # Provides: udev
  4. # Required-Start: mountvirtfs
  5. # Required-Stop:
  6. # Default-Start: S
  7. # Default-Stop:
  8. # Short-Description: Start udevd, populate /dev and load drivers.
  9. ### END INIT INFO
  10. export TZ=/etc/localtime
  11. [ -d /sys/class ] || exit 1
  12. [ -r /proc/mounts ] || exit 1
  13. [ -x /sbin/udevd ] || exit 1
  14. [ -f /etc/default/udev ] && . /etc/default/udev
  15. [ -f /etc/udev/udev.conf ] && . /etc/udev/udev.conf
  16. kill_udevd() {
  17. if [ -x /sbin/pidof ]; then
  18. pid=`/sbin/pidof -x udevd`
  19. [ -n "$pid" ] && kill $pid
  20. fi
  21. }
  22. export ACTION=add
  23. # propagate /dev from /sys
  24. echo "Starting udev"
  25. # mount the tmpfs on /dev, if not already done
  26. LANG=C awk "\$2 == \"/dev\" && \$3 == \"tmpfs\" { exit 1 }" /proc/mounts && {
  27. mount -n -o mode=0755 -t tmpfs none "/dev"
  28. mkdir -m 0755 /dev/pts
  29. mkdir -m 1777 /dev/shm
  30. }
  31. if [ "$DEVCACHE" != "" ]; then
  32. # Invalidate udev cache if the kernel or its bootargs/cmdline have changed
  33. [ -x /bin/uname ] && /bin/uname -mrspv > /tmp/uname || touch /tmp/uname
  34. [ -r /proc/cmdline ] && cat /proc/cmdline > /tmp/cmdline || touch /tmp/cmdline
  35. [ -r /proc/atags ] && cat /proc/atags > /tmp/atags || touch /tmp/atags
  36. if [ -e $DEVCACHE ] && \
  37. cmp -s /tmp/uname /etc/udev/saved.uname && \
  38. cmp -s /tmp/cmdline /etc/udev/saved.cmdline && \
  39. cmp -s /tmp/atags /etc/udev/saved.atags; then
  40. (cd /; tar xf $DEVCACHE > /dev/null 2>&1)
  41. not_first_boot=1
  42. fi
  43. fi
  44. if [ ! -e "/lib/modules/$(uname -r)"/modules.dep ] ; then
  45. mkdir -p /lib/modules/$(uname -r)
  46. depmod -ae
  47. fi
  48. # make_extra_nodes
  49. kill_udevd > "/dev/null" 2>&1
  50. # trigger the sorted events
  51. echo -e '\000\000\000\000' > /proc/sys/kernel/hotplug
  52. /sbin/udevd -d
  53. /sbin/udevadm control --env STARTUP=1
  54. if [ "$not_first_boot" != "" ];then
  55. /sbin/udevadm trigger --action=add --subsystem-nomatch=tty --subsystem-nomatch=mem --subsystem-nomatch=vc --subsystem-nomatch=vtconsole --subsystem-nomatch=misc --subsystem-nomatch=dcon --subsystem-nomatch=pci_bus --subsystem-nomatch=graphics --subsystem-nomatch=backlight --subsystem-nomatch=video4linux --subsystem-nomatch=platform
  56. (/sbin/udevadm settle --timeout=8; /sbin/udevadm control --env STARTUP=)&
  57. else
  58. /sbin/udevadm trigger
  59. /sbin/udevadm settle
  60. fi
  61. exit 0