summaryrefslogtreecommitdiffstats
path: root/init.d/coldplug
blob: a39f39fb8c9a86c1ac82fa73d7a994b341e823a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/sbin/runscript

trigger_uevents() {
	local i
	for i in /sys/bus/*/devices/*/uevent\
		/sys/class/*/*/uevent\
		/sys/block/*/uevent\
		/sys/block/*/*/uevent ; do
		case "$i" in
			*/device/uevent)
				continue
				;;
			*/class/mem/*|*/class/tty/*)
				echo add > "$i"
				;;
			*/block/md*|*/block/dm-*)
				last="$last $i"
				;;
			*/*)
				default="$default $i"
				;;
		esac
	done
	for i in $default $last ; do
		echo add > "$i"
	done	
}

# coldplug devices
start() {
	unset NOCOLDPLUG 
	# check for boot option "nocoldplug"
	for i in `cat /proc/cmdline`; do
		[ "$i" = "nocoldplug" ] && NOCOLDPLUG=true
	done
	
	if [ "$NOCOLDPLUG" ]; then
		ebegin "Skipping coldplugging"
		eend 0
		return
	fi
	
#		for rc in /etc/hotplug/*.rc ; do
#			name=`basename $rc .rc`
#			ebegin "Coldplugging $name devices"
#			$rc start 2>/tmp/coldplug.err
#			eend 0
#		done
	ebegin "Coldplugging devices"
#	while [ -d /dev/.udev/queue ] ; do
#		sleep 1
#		echo -n "."
#	done
#	trigger_uevents
#	sleep 1
#	while [ -d /dev/.udev/queue ] ; do
#		sleep 1
#		echo -n "."
#	done
	find /sys -name modalias | while read a ; do
		modprobe `cat $a` 2>/dev/null || echo $a >> /tmp/failed
	done
	eend 0
}