udev: add version 154
[openembedded.git] / recipes / udev / udev-154 / init
blobf4dc5de2f502d73a8399de6c10fe7d3b9b87a8c1
1 #!/bin/sh -e
3 ### BEGIN INIT INFO
4 # Provides: udev
5 # Required-Start: mountvirtfs
6 # Required-Stop:
7 # Default-Start: S
8 # Default-Stop:
9 # Short-Description: Start udevd, populate /dev and load drivers.
10 ### END INIT INFO
12 export TZ=/etc/localtime
14 [ -d /sys/class ] || exit 1
15 [ -r /proc/mounts ] || exit 1
16 [ -x /sbin/udevd ] || exit 1
17 [ -f /etc/default/udev ] && . /etc/default/udev
18 [ -f /etc/udev/udev.conf ] && . /etc/udev/udev.conf
20 kill_udevd() {
21 if [ -x /sbin/pidof ]; then
22 pid=`/sbin/pidof -x udevd`
23 [ -n "$pid" ] && kill $pid
27 export ACTION=add
28 # propagate /dev from /sys
29 echo "Starting udev"
31 # mount the tmpfs on /dev, if not already done
32 LANG=C awk "\$2 == \"/dev\" && \$4 == \"tmpfs\" { exit 1 }" /proc/mounts && {
33 mount -n -o mode=0755 -t tmpfs none "/dev"
34 mkdir -m 0755 /dev/pts
35 mkdir -m 1777 /dev/shm
38 if [ "$DEVCACHE" != "" ]; then
39 # Invalidate udev cache if the kernel or its bootargs/cmdline have changed
40 [ -x /bin/uname ] && /bin/uname -mrspv > /tmp/uname || touch /tmp/uname
41 [ -r /proc/cmdline ] && cat /proc/cmdline > /tmp/cmdline || touch /tmp/cmdline
42 [ -r /proc/atags ] && cat /proc/atags > /tmp/atags || touch /tmp/atags
43 if [ -e $DEVCACHE ] && \
44 cmp -s /tmp/uname /etc/udev/saved.uname && \
45 cmp -s /tmp/cmdline /etc/udev/saved.cmdline && \
46 cmp -s /tmp/atags /etc/udev/saved.atags; then
47 (cd /; tar xf $DEVCACHE > /dev/null 2>&1)
48 not_first_boot=1
52 if [ ! -e "/lib/modules/$(uname -r)"/modules.dep ] ; then
53 mkdir -p /lib/modules/$(uname -r)
54 depmod -ae
57 # make_extra_nodes
58 kill_udevd > "/dev/null" 2>&1
60 # trigger the sorted events
61 echo -e '\000\000\000\000' > /proc/sys/kernel/hotplug
62 /sbin/udevd -d
64 /sbin/udevadm control --env STARTUP=1
65 if [ "$not_first_boot" != "" ];then
66 /sbin/udevadm trigger --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
67 (/sbin/udevadm settle --timeout=3; /sbin/udevadm control --env STARTUP=)&
68 if [ "$DEVCACHE" != "" ]; then
69 rm -f /tmp/uname
70 rm -f /tmp/cmdline
71 rm -f /tmp/atags
73 else
74 /sbin/udevadm trigger
75 /sbin/udevadm settle
78 exit 0