View | Details | Raw Unified | Return to bug 6397
Collapse All | Expand All

(-)rc.sysinit (-32 / +2 lines)
Lines 285-323 if [ -x "$STARTEVMS" ] && ! grep -iwqs n Link Here
285
fi
285
fi
286
286
287
# Add raid devices
287
# Add raid devices
288
if [ -z "$EVMS_ACTIVE" ] && [ -f /proc/mdstat -a -s /etc/raidtab ] && ! grep -iwqs noraidtab /proc/cmdline; then
288
if [ -z "$EVMS_ACTIVE" ] && [ -f /proc/mdstat ]; then
289
	echo -n "Starting up RAID devices: "
290
291
	rc=0
292
	for i in `grep -s "^raiddev" /etc/raidtab | awk '{print $2}'`; do
293
		RAIDDEV="${i##*/}"
294
		RAIDSTAT=`grep -s "^$RAIDDEV : active" /proc/mdstat`
295
		if [ -z "$RAIDSTAT" ]; then
296
			# Try raidstart first...if that fails then
297
			# fall back to raidadd, raidrun.  If that
298
			# also fails, then we drop to a shell
299
			RESULT=1
300
			ExecIfExecutable /sbin/raidstart "$i"
301
			RESULT=$?
302
			if [ $RESULT -gt 0 ]; then
303
				ExecIfExecutable /sbin/raid0run "$i"
304
				RESULT=$?
305
			fi
306
			if [ $RESULT -gt 0 ]; then
307
				ExecIfExecutable /sbin/raidadd "$i"
308
				ExecIfExecutable /sbin/raidrun "$i"
309
				RESULT=$?
310
			fi
311
			if [ $RESULT -gt 0 ]; then
312
				rc=1
313
			fi
314
		fi
315
		echo -n "$RAIDDEV "
316
	done
317
	echo
318
319
	# A non-zero return means there were problems.
289
	# A non-zero return means there were problems.
320
	if [ $rc -gt 0 ]; then
290
	if ! /etc/rc.d/scripts/raidstart; then
321
		echo
291
		echo
322
		echo
292
		echo
323
		echo "*** An error occurred during the RAID startup"
293
		echo "*** An error occurred during the RAID startup"
(-) (+97 lines)
Added Link Here
1
#!/bin/sh
2
3
exec_if_executable()
4
{
5
	local f
6
	f="$1"
7
	shift
8
	[ -x "$f" ] && "$f" "$@"
9
}
10
11
mdadm_found()
12
{
13
	[ -s /etc/mdadm.conf ] || return 1
14
	local f
15
	for f in /sbin/mdadm /usr/sbin/mdadm /sbin/mdassemble /usr/sbin/mdassemble; do
16
		[ -x "$f" ] && return 0
17
	done
18
	return 1
19
}
20
21
raidtools_found()
22
{
23
	[ -s /etc/raidtab ] || return 1
24
	local f
25
	for f in /sbin/raidstart /sbin/raid0run /sbin/raidadd; do
26
		[ -x "$f" ] && return 0
27
	done
28
	return 1
29
}
30
31
start_raid_using_mdadm()
32
{
33
	[ -s /etc/mdadm.conf ] || return 1
34
	local f
35
	for f in /sbin/mdadm /usr/sbin/mdadm; do
36
		[ -x "$f" ] || continue
37
		echo -n "(using mdadm) "
38
		"$f" --assemble --scan
39
		return $?
40
	done
41
	for f in /sbin/mdassemble /usr/sbin/mdassemble; do
42
		[ -x "$f" ] || continue
43
		echo -n "(using mdassemble) "
44
		"$f"
45
		return $?
46
	done
47
	return 1
48
}
49
50
start_raid_using_raidtools()
51
{
52
	[ -s /etc/raidtab ] || return 1
53
	local rc=0 i dev stat res
54
	echo -n "(using raidtools) "
55
	for i in `grep -s "^raiddev" /etc/raidtab | awk '{print $2}'`; do
56
		dev="${i##*/}"
57
		stat=`grep -s "^$dev : active" /proc/mdstat`
58
		if [ -z "$stat" ]; then
59
			# Try raidstart first...if that fails then
60
			# fall back to raidadd, raidrun.  If that
61
			# also fails, then we drop to a shell
62
			res=1
63
			exec_if_executable /sbin/raidstart "$i"
64
			res=$?
65
			if [ $res -gt 0 ]; then
66
				exec_if_executable /sbin/raid0run "$i"
67
				res=$?
68
			fi
69
			if [ $res -gt 0 ]; then
70
				exec_if_executable /sbin/raidadd "$i"
71
				exec_if_executable /sbin/raidrun "$i"
72
				res=$?
73
			fi
74
			if [ $res -gt 0 ]; then
75
				rc=1
76
			fi
77
		fi
78
		echo -n "$dev "
79
	done
80
	return $rc
81
}
82
83
[ -f /proc/mdstat ] && ! grep -iwqs noraidtab /proc/cmdline || exit 0
84
85
rc=0
86
if mdadm_found; then
87
	echo -n "Starting up RAID devices: "
88
	start_raid_using_mdadm
89
	rc=$?
90
	echo
91
elif raidtools_found; then
92
	echo -n "Starting up RAID devices: "
93
	start_raid_using_raidtools
94
	rc=$?
95
	echo
96
fi
97
exit $rc

Return to bug 6397