summaryrefslogtreecommitdiff
path: root/storage/ndb/test/run-test/make-config.sh
blob: a5ea2e58ae6c5cdd85e5a682371a42261011b8f1 (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 (){
	case $type in
	mgm)
		echo "$proc_no.ndb_mgmd" >> $dir_file
		echo "[ndb_mgmd]"        >> $config_file
		echo "Id: $node_id"      >> $config_file
		echo "HostName: $2"      >> $config_file
		node_id=`expr $node_id + 1`
		;;
	api)
		echo "$proc_no.ndb_api" >> $dir_file
                echo "[api]"            >> $config_file
                echo "Id: $node_id"     >> $config_file
                echo "HostName: $2"     >> $config_file
		node_id=`expr $node_id + 1`
		;;
	ndb)
		echo "$proc_no.ndbd" >> $dir_file
                echo "[ndbd]"        >> $config_file
                echo "Id: $node_id"  >> $config_file
                echo "HostName: $2"  >> $config_file
		node_id=`expr $node_id + 1`
		;;
	mysqld)
		echo "$proc_no.mysqld" >> $dir_file
                echo "[mysqld]"      >> $config_file
                echo "Id: $node_id"    >> $config_file
                echo "HostName: $2"    >> $config_file
		node_id=`expr $node_id + 1`
		;;
	mysql)
		echo "$proc_no.mysql" >> $dir_file
		;;
	esac
	proc_no=`expr $proc_no + 1`
}


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