This is the first release of cgi.
[archserver.git] / admin / raid / create_raid.sh
blob5c8467c0458d20875f2d8fa2e6bb22175bca26a1
1 #!/bin/sh
2 #echo -e "Content-type: text/html; charset=utf-8\n\n";
3 #source ./proccgi.sh
5 echo "<html>"
7 all_disks="$F_devs_1 $F_devs_2 $F_devs_3 $F_devs_4 $F_devs_5 $F_devs_6 $F_devs_7 $F_devs_8 $F_devs_9 $F_devs_10 $F_devs_11 $F_devs_12"
9 echo -e "all: $all_disks<br>"
10 echo -e "hotspare: $F_hot_spare<br>"
11 echo -e "Raid Method: $F_raid_method<br>"
13 if [ "$F_raid_method" = "no" ]; then
14 echo "Error: No Raid Type Selected."; exit
15 elif [ "$all_disks" = "" ]; then
16 echo "Error: No Disks Selected."; exit
19 disk_nu=$(echo $all_disks | wc -w)
20 echo -e "Disks: $all_disks<br>"
21 echo "disk number: $disk_nu<br>"
24 ##### Do Some check with the parameters ! ##########
25 ####################################################
27 m=$F_raid_method
28 if [ "$m" = "raid0" -a $disk_nu -lt 2 ] || [ "$m" = "raid1" -a $disk_nu -lt 2 ]; then
29 echo "Error: $m need 2 disk at lease"; exit
30 elif [ "$m" = "raid5" -a $disk_nu -lt 3 ]; then
31 echo "Error: $m need 3 disk at least"; exit
32 elif [ "$m" = "raid6" -a $disk_nu -lt 4 ] || [ "$m" = "raid10" -a $disk_nu -lt 4 ]; then
33 echo "Error: $m need 4 disk at least"; exit
36 for h in `echo -e $F_hot_spare`
38 if echo -e $all_disks | grep -q $h; then
39 echo -e $F_hot_spare" exist in disks!"; exit
41 done
43 #FIXME There should also be some check with disk status.
47 ########### Create Raid ############################
48 ####################################################
50 echo -e "<br>Command:<br><font color=red>
51 sudo /sbin/mdadm -C /dev/md0 -l`echo $m|sed 's/raid//'`
52 $all_disks `[ "$F_hot_spare" = "no" ] || echo "-x $F_hot_spare"`
54 echo "</html>"