]> git.sur5r.net Git - bacula/rescue/blob - rescue/linux/usb/src/scripts/findraidevice/findraid_new
Add new usb rescue key code
[bacula/rescue] / rescue / linux / usb / src / scripts / findraidevice / findraid_new
1 #!/bin/sh
2
3 if [ -f recreate_raid_arrays ];then
4 rm recreate_raid_arrays
5 fi
6
7 if [ -f findraidtemp ];then
8 rm findraidtemp
9 fi
10 devices=""
11
12 cat /proc/mdstat |grep active|grep -v inactive>>/dev/null
13         if [ $? = 0 ];then
14         cat /proc/mdstat |grep active|grep -v inactive>>findraidtemp
15         cat findraidtemp |while read line ;do
16         words=`echo $line |wc -w`
17                 for i in `seq 1 $words`;do
18                 a=1
19                 result=`echo $line|cut -d" " -f$i`
20                 res=`echo $result|cut -c1`
21                 resu=`echo $result|cut -c 1-4`
22                 resfin=`echo $result|tail -c2`          
23                         if [ "$res" = "m" ];then
24                         device=$result
25                         
26                         fi
27                                 if [ "$resu" = "raid" ];then
28                                 level=`echo $result|tail -c2`   
29                                 
30                                 fi
31                                         if [ "$resfin" = "]" ];then
32                                          dev=`echo $result |cut -d"[" -f1`
33                                         dev=`echo "/dev/"$dev" "`
34                                         devices=$devices$dev
35                                         
36                                                 
37                                                 
38                                         fi
39                  done
40          numdev=`echo $devices|wc -w`
41          onedev=`echo $devices|cut -d" " -f1`
42          uuid=`blkid |grep $onedev|cut -d'"' -f2`
43          echo "mdadm --create /dev/"$device" --level="$level" --raid-devices="$numdev " " $devices "--uuid="$uuid >>recreate_raid_arrays
44          devices=""
45          done
46 chmod +x recreate_raid_arrays
47
48         fi
49  if [ -f findraidtemp ];then
50 rm findraidtemp
51 fi