File: raid2

package info (click to toggle)
raidtools2 0.90.990824-5
  • links: PTS
  • area: main
  • in suites: potato
  • size: 688 kB
  • ctags: 468
  • sloc: ansic: 2,631; makefile: 143; sh: 114
file content (82 lines) | stat: -rw-r--r-- 2,079 bytes parent folder | download
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/sh -e
#
# Start any devices that weren't autodetected
#
# While this script probably has some bugs, and the sed's probably can be
# done easier, comments/reports are more than welcome.
#
# Written by P.A. Knuutila <pa@debian.org> for Debian raidtools2

RAIDSTART=/sbin/raidstart
RAIDSTOP=/sbin/raidstop
RAID0RUN=/sbin/raid0run
CONFIG=/etc/raidtab

case "$1" in
start)

  test -f $RAIDSTART || exit 0
  test -f $RAID0RUN || exit 0
  test -f $CONFIG || exit 0

  echo -n "Starting raid devices:"

  DEVICES=`sed -ne 's/^[[:space:]]*raiddev[[:space:]]*\/dev\/\(md[01234]\).*/\1/p' $CONFIG`

  for i in $DEVICES; do

    if ! grep -q "^$i : active" /proc/mdstat; then # check if already active

# look for persistant superblock in config file; if not mentioned it is
# persistant (i.e. mkraid defaults to persistant-superblock 1)

      PERSISTANT=`sed -ne "/^[[:space:]]*raiddev[[:space:]]*\/dev\/$i/,/^[[:space:]]*raiddev/s/[[:space:]]persistent-superblock[[:space:]]*\([01]\).*/\1/p" $CONFIG`

      if [ ! $PERSISTANT ]; then PERSISTANT=1; fi

      if [ $PERSISTANT -eq 1 ]; then

        $RAIDSTART --configfile $CONFIG /dev/$i

      else # if not persistant, start it only if it's RAID0/linear

        LEVEL=`sed -ne "/^[[:space:]]*raiddev[[:space:]]*\/dev\/$i/,/^[[:space:]]*raiddev/s/[[:space:]]raid-level[[:space:]]*\(0\|linear\).*/\1/p" $CONFIG`

        if [ $LEVEL ]; then

          $RAID0RUN --configfile $CONFIG /dev/$i

        fi
      fi
    fi
  done
        
        echo "done."
        ;;
stop)   # raidstop isn't very good at stopping all devices, so we'll have to
        # sedding again. raidstopping at shutdown actually isn't mandatory.

  test -f $RAIDSTOP || exit 0
  test -f $CONFIG || exit 0

  echo -n "Stopping raid devices:"

  DEVICES=`sed -ne 's/^\(md[01234]\) : active.*/\1/p' /proc/mdstat`

  for i in $DEVICES; do

    $RAIDSTOP --configfile $CONFIG /dev/$i

  done
        echo "done."
        ;;
restart)
	/etc/init.d/raid2 stop
	/etc/init.d/raid2 start
	;;
        reload|force-reload)
echo "Not supported"
        ;;
esac

exit 0