1 | #!/bin/sh
|
---|
2 | ########################################################################
|
---|
3 | # Begin udev
|
---|
4 | #
|
---|
5 | # Description : Udev cold-plugging script
|
---|
6 | #
|
---|
7 | # Authors : Zack Winkles, Alexander E. Patrakov
|
---|
8 | # Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
|
---|
9 | #
|
---|
10 | # Version : LFS 7.0
|
---|
11 | #
|
---|
12 | ########################################################################
|
---|
13 |
|
---|
14 | ### BEGIN INIT INFO
|
---|
15 | # Provides: udev
|
---|
16 | # Required-Start:
|
---|
17 | # Should-Start: modules
|
---|
18 | # Required-Stop:
|
---|
19 | # Should-Stop:
|
---|
20 | # Default-Start: S
|
---|
21 | # Default-Stop:
|
---|
22 | # Short-Description: Populates /dev with device nodes.
|
---|
23 | # Description: Mounts a tempfs on /dev and starts the udevd daemon.
|
---|
24 | # Device nodes are created as defined by udev.
|
---|
25 | # X-LFS-Provided-By: LFS
|
---|
26 | ### END INIT INFO
|
---|
27 |
|
---|
28 | . /lib/boot/functions
|
---|
29 |
|
---|
30 | case "${1}" in
|
---|
31 | start)
|
---|
32 | boot_mesg "Populating /dev with device nodes..."
|
---|
33 | if ! grep -q '[[:space:]]sysfs' /proc/mounts; then
|
---|
34 | echo_failure
|
---|
35 | boot_mesg -n "FAILURE:\n\nUnable to create" ${FAILURE}
|
---|
36 | boot_mesg -n " devices without a SysFS filesystem"
|
---|
37 | boot_mesg -n "\n\nAfter you press Enter, this system"
|
---|
38 | boot_mesg -n " will be halted and powered off."
|
---|
39 | boot_mesg -n "\n\nPress Enter to continue..." ${INFO}
|
---|
40 | boot_mesg "" ${NORMAL}
|
---|
41 | wait_for_user
|
---|
42 | /etc/rc.d/init.d/halt stop
|
---|
43 | fi
|
---|
44 |
|
---|
45 | # Mount a temporary file system over /dev, so that any devices
|
---|
46 | # made or removed during this boot don't affect the next one.
|
---|
47 | # The reason we don't write to mtab is because we don't ever
|
---|
48 | # want /dev to be unavailable (such as by `umount -a').
|
---|
49 | if ! mountpoint /dev > /dev/null; then
|
---|
50 | mount -n -t tmpfs tmpfs /dev -o mode=755
|
---|
51 | fi
|
---|
52 | if [ ${?} != 0 ]; then
|
---|
53 | echo_failure
|
---|
54 | boot_mesg -n "FAILURE:\n\nCannot mount a tmpfs" ${FAILURE}
|
---|
55 | boot_mesg -n " onto /dev, this system will be halted."
|
---|
56 | boot_mesg -n "\n\nAfter you press Enter, this system"
|
---|
57 | boot_mesg -n " will be halted and powered off."
|
---|
58 | boot_mesg -n "\n\nPress Enter to continue..." ${INFO}
|
---|
59 | boot_mesg "" ${NORMAL}
|
---|
60 | wait_for_user
|
---|
61 | /etc/rc.d/init.d/halt stop
|
---|
62 | fi
|
---|
63 |
|
---|
64 | ln -s /run/shm /dev/shm
|
---|
65 |
|
---|
66 | # Udev handles uevents itself, so we don't need to have
|
---|
67 | # the kernel call out to any binary in response to them
|
---|
68 | echo > /proc/sys/kernel/hotplug
|
---|
69 |
|
---|
70 | # Copy the only static device node that Udev >= 155 doesn't
|
---|
71 | # handle to /dev
|
---|
72 | cp -a /lib/udev/devices/null /dev
|
---|
73 |
|
---|
74 | # Start the udev daemon to continually watch for, and act on,
|
---|
75 | # uevents
|
---|
76 | /sbin/udevd --daemon
|
---|
77 |
|
---|
78 | # Now traverse /sys in order to "coldplug" devices that have
|
---|
79 | # already been discovered
|
---|
80 | /sbin/udevadm trigger --action=add --type=subsystems
|
---|
81 | /sbin/udevadm trigger --action=add --type=devices
|
---|
82 |
|
---|
83 | # Now wait for udevd to process the uevents we triggered
|
---|
84 | /sbin/udevadm settle
|
---|
85 | evaluate_retval
|
---|
86 | ;;
|
---|
87 |
|
---|
88 | *)
|
---|
89 | echo "Usage ${0} {start}"
|
---|
90 | exit 1
|
---|
91 | ;;
|
---|
92 | esac
|
---|
93 |
|
---|
94 | # End udev
|
---|