systemd-udevd 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #!/bin/sh
  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. . /etc/init.d/functions
  11. export TZ=/etc/localtime
  12. [ -d /sys/class ] || exit 1
  13. [ -r /proc/mounts ] || exit 1
  14. [ -x /lib/systemd/systemd-udevd ] || exit 1
  15. [ -f /etc/default/udev-cache ] && . /etc/default/udev-cache
  16. [ -f /etc/udev/udev.conf ] && . /etc/udev/udev.conf
  17. readfile () {
  18. filename=$1
  19. READDATA=""
  20. if [ -r $filename ]; then
  21. while read line; do
  22. READDATA="$READDATA$line"
  23. done < $filename
  24. fi
  25. }
  26. case "$1" in
  27. start)
  28. export ACTION=add
  29. # propagate /dev from /sys
  30. echo "Starting udev"
  31. # mount the devtmpfs on /dev, if not already done
  32. LANG=C awk '$2 == "/dev" && ($3 == "devtmpfs") { exit 1 }' /proc/mounts && {
  33. mount -n -o mode=0755 -t devtmpfs none "/dev"
  34. }
  35. [ -e /dev/pts ] || mkdir -m 0755 /dev/pts
  36. [ -e /dev/shm ] || mkdir -m 1777 /dev/shm
  37. mount -a -t tmpfs 2>/dev/null
  38. # cache handling
  39. if [ "$DEVCACHE" != "" ]; then
  40. readfile /proc/version
  41. VERSION="$READDATA"
  42. readfile /proc/cmdline
  43. CMDLINE="$READDATA"
  44. readfile /proc/devices
  45. DEVICES="$READDATA"
  46. readfile /proc/atags
  47. ATAGS="$READDATA"
  48. if [ -e $DEVCACHE ]; then
  49. readfile /etc/udev/cache.data
  50. if [ "$READDATA" = "$VERSION$CMDLINE$DEVICES$ATAGS" ]; then
  51. (cd /; tar xf $DEVCACHE > /dev/null 2>&1)
  52. not_first_boot=1
  53. [ "$VERBOSE" != "no" ] && echo "udev: using cache file $DEVCACHE"
  54. [ -e /dev/shm/udev.cache ] && rm -f /dev/shm/udev.cache
  55. else
  56. echo "$VERSION$CMDLINE$DEVICES$ATAGS" > /dev/shm/udev.cache
  57. fi
  58. else
  59. echo "$VERSION$CMDLINE$DEVICES$ATAGS" > /dev/shm/udev.cache
  60. fi
  61. fi
  62. # make_extra_nodes
  63. killproc systemd-udevd > "/dev/null" 2>&1
  64. # trigger the sorted events
  65. echo -e '\000\000\000\000' > /proc/sys/kernel/hotplug
  66. /lib/systemd/systemd-udevd -d
  67. udevadm control --env=STARTUP=1
  68. if [ "$not_first_boot" != "" ];then
  69. 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
  70. (udevadm settle --timeout=3; udevadm control --env=STARTUP=)&
  71. else
  72. udevadm trigger --action=add
  73. udevadm settle
  74. fi
  75. ;;
  76. stop)
  77. echo "Stopping udevd"
  78. start-stop-daemon --stop --name systemd-udevd --quiet
  79. ;;
  80. restart)
  81. $0 stop
  82. sleep 1
  83. $0 start
  84. ;;
  85. status)
  86. status systemd-udevd
  87. ;;
  88. *)
  89. echo "Usage: $0 {start|stop|status|restart}"
  90. exit 1
  91. esac
  92. exit 0