blob: 1321ce4e9f0ee42085a93a7f660a802c185e714d (
plain)
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
#!/bin/sh
baseport=""
basedir=""
proc_no=1
node_id=1
d_file=/tmp/d.$$
dir_file=/tmp/dirs.$$
config_file=/tmp/config.$$
cluster_file=/tmp/cluster.$$
add_procs(){
type=$1; shift
while [ $# -ne 0 ]
do
add_proc $type $1
shift
done
}
add_proc (){
dir=""
conf=""
case $type in
mgm)
dir="ndb_mgmd"
conf="[ndb_mgmd]\nId: $node_id\nHostName: $2\n"
node_id=`expr $node_id + 1`
;;
api)
dir="ndb_api"
conf="[api]\nId: $node_id\nHostName: $2\n"
node_id=`expr $node_id + 1`
;;
ndb)
dir="ndbd"
conf="[ndbd]\nId: $node_id\nHostName: $2\n"
node_id=`expr $node_id + 1`
;;
mysqld)
dir="mysqld"
conf="[mysqld]\nId: $node_id\nHostName: $2\n"
node_id=`expr $node_id + 1`
;;
mysql)
dir="mysql"
;;
esac
dir="$proc_no.$dir"
proc_no=`expr $proc_no + 1`
echo -e $dir >> $dir_file
if [ "$conf" ]
then
echo -e $conf >> $config_file
fi
}
cnf=/dev/null
cat $1 | while read line
do
case $line in
baseport:*) baseport=`echo $line | sed 's/baseport[ ]*:[ ]*//g'`;;
basedir:*) basedir=`echo $line | sed 's/basedir[ ]*:[ ]*//g'`;;
mgm:*) add_procs mgm `echo $line | sed 's/mgm[ ]*:[ ]*//g'`;;
api:*) add_procs api `echo $line | sed 's/api[ ]*:[ ]*//g'`;;
ndb:*) add_procs ndb `echo $line | sed 's/ndb[ ]*:[ ]*//g'`;;
mysqld:*) add_procs mysqld `echo $line | sed 's/mysqld[ ]*:[ ]*//g'`;;
mysql:*) add_procs mysql `echo $line | sed 's/mysql[ ]*:[ ]*//g'`;;
"-- cluster config")
if [ "$cnf" = "/dev/null" ]
then
cnf=$cluster_file
else
cnf=/dev/null
fi
line="";;
*) echo $line >> $cnf; line="";;
esac
if [ "$line" ]
then
echo $line >> $d_file
fi
done
cat $dir_file | xargs mkdir -p
if [ -f $cluster_file ]
then
cat $cluster_file $config_file >> /tmp/config2.$$
mv /tmp/config2.$$ $config_file
fi
for i in `find . -type d -name '*.ndb_mgmd'`
do
cp $config_file $i/config.ini
done
mv $d_file d.txt
rm -f $config_file $dir_file $cluster_file
|