-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvolcreate_new.sh
executable file
·83 lines (59 loc) · 1.46 KB
/
volcreate_new.sh
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
#!/bin/bash
if [ $# -ne 5 ]; then
echo "usage: ./volcreate_new volname nbricks scount rcount brickdir"
exit 1
fi
volname=$1
nbricks=$2
scount=$3
rcount=$4
brickdir=$5
cmd_prefix="gluster volume"
brick_list=" "
echo -e "VOLNAME:\t$volname\nBRICK_CNT:\t$nbricks\nSTRPIPE_CNT:\t$scount\n\
REPLICA_CNT:\t$rcount\nBRICK_DIR:\t$brickdir"
if [ $nbricks -eq 0 ]; then
echo "brick count can't be zero"
exit 1;
fi
#check if brick dir exists
if [ ! -d $brickdir ]; then
echo "brick directory doesn't exists"
exit 1
fi
if [ ! -f "servers" ]; then
echo "server file does not exists"
exit 1
fi
#read server list#
i=0
while read line
do
a[i]=$line
(( i++ ))
done < servers
j=0
while [ $j -lt $nbricks ]
do
val=`expr $j % $i`
host=${a[$val]}
brick_list="$brick_list $host:/$brickdir/$volname$j "
(( j++ ))
done
echo -e "BRICK_LIST:$brick_list\n"
if [ "$scount" -eq "0" ] && [ "$rcount" -eq "0" ]; then
#this volume is distribute
$cmd_prefix create $volname $brick_list
exit 0
fi
#find out what type of volume to be created
if [ "$rcount" -eq 0 ]; then
#volume is either plain stripe or dist-stripe
$cmd_prefix create $volname stripe $scount $brick_list
elif [ "$scount" -eq 0 ] ; then
#this is plain replica or distributed-replicate
$cmd_prefix create $volname replica $rcount $brick_list
else
#this is stripe-replicate or distributed-stripe-replicate
$cmd_prefix create $volname stripe $scount replica $rcount $brick_list
fi