2004-04-14 10:53:21 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2010-12-28 19:57:23 +01:00
|
|
|
# Copyright (C) 2004, 2005 MySQL AB
|
2014-02-17 18:19:04 +05:30
|
|
|
# Use is subject to license terms
|
2010-12-28 19:57:23 +01:00
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Library General Public
|
|
|
|
# License as published by the Free Software Foundation; version 2
|
|
|
|
# of the License.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# Library General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Library General Public
|
|
|
|
# License along with this library; if not, write to the Free
|
2013-03-19 15:53:48 +01:00
|
|
|
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
|
|
# MA 02110-1301, USA
|
2010-12-28 19:57:23 +01:00
|
|
|
|
2005-05-06 15:37:51 +02:00
|
|
|
baseport=""
|
|
|
|
basedir=""
|
|
|
|
proc_no=1
|
|
|
|
node_id=1
|
2004-04-14 10:53:21 +02:00
|
|
|
|
2005-05-07 13:23:38 +02:00
|
|
|
d_file=/tmp/d.$$
|
2005-05-06 15:37:51 +02:00
|
|
|
dir_file=/tmp/dirs.$$
|
|
|
|
config_file=/tmp/config.$$
|
2005-05-06 16:14:30 +02:00
|
|
|
cluster_file=/tmp/cluster.$$
|
2004-04-14 10:53:21 +02:00
|
|
|
|
2005-05-06 15:37:51 +02:00
|
|
|
add_procs(){
|
2004-04-14 10:53:21 +02:00
|
|
|
type=$1; shift
|
2005-05-06 15:37:51 +02:00
|
|
|
while [ $# -ne 0 ]
|
|
|
|
do
|
|
|
|
add_proc $type $1
|
|
|
|
shift
|
|
|
|
done
|
2004-04-14 10:53:21 +02:00
|
|
|
}
|
|
|
|
|
2005-05-06 15:37:51 +02:00
|
|
|
add_proc (){
|
|
|
|
case $type in
|
|
|
|
mgm)
|
2005-06-10 10:22:32 +02:00
|
|
|
echo "$proc_no.ndb_mgmd" >> $dir_file
|
|
|
|
echo "[ndb_mgmd]" >> $config_file
|
|
|
|
echo "Id: $node_id" >> $config_file
|
|
|
|
echo "HostName: $2" >> $config_file
|
2005-05-06 15:37:51 +02:00
|
|
|
node_id=`expr $node_id + 1`
|
|
|
|
;;
|
|
|
|
api)
|
2005-06-10 10:22:32 +02:00
|
|
|
echo "$proc_no.ndb_api" >> $dir_file
|
|
|
|
echo "[api]" >> $config_file
|
|
|
|
echo "Id: $node_id" >> $config_file
|
|
|
|
echo "HostName: $2" >> $config_file
|
2005-05-06 15:37:51 +02:00
|
|
|
node_id=`expr $node_id + 1`
|
|
|
|
;;
|
|
|
|
ndb)
|
2005-06-10 10:22:32 +02:00
|
|
|
echo "$proc_no.ndbd" >> $dir_file
|
|
|
|
echo "[ndbd]" >> $config_file
|
|
|
|
echo "Id: $node_id" >> $config_file
|
|
|
|
echo "HostName: $2" >> $config_file
|
2005-05-06 15:37:51 +02:00
|
|
|
node_id=`expr $node_id + 1`
|
|
|
|
;;
|
|
|
|
mysqld)
|
2005-06-10 10:22:32 +02:00
|
|
|
echo "$proc_no.mysqld" >> $dir_file
|
2005-11-22 18:05:10 +01:00
|
|
|
echo "[mysqld]" >> $config_file
|
2005-06-10 10:22:32 +02:00
|
|
|
echo "Id: $node_id" >> $config_file
|
|
|
|
echo "HostName: $2" >> $config_file
|
2005-05-06 15:37:51 +02:00
|
|
|
node_id=`expr $node_id + 1`
|
|
|
|
;;
|
|
|
|
mysql)
|
2005-06-10 10:22:32 +02:00
|
|
|
echo "$proc_no.mysql" >> $dir_file
|
2005-05-06 15:37:51 +02:00
|
|
|
;;
|
2004-04-14 10:53:21 +02:00
|
|
|
esac
|
2005-05-06 15:37:51 +02:00
|
|
|
proc_no=`expr $proc_no + 1`
|
2004-04-14 10:53:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-05-06 16:14:30 +02:00
|
|
|
cnf=/dev/null
|
2005-05-06 15:37:51 +02:00
|
|
|
cat $1 | while read line
|
2004-04-14 10:53:21 +02:00
|
|
|
do
|
2005-05-06 15:37:51 +02:00
|
|
|
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'`;;
|
2005-05-06 16:14:30 +02:00
|
|
|
"-- cluster config")
|
|
|
|
if [ "$cnf" = "/dev/null" ]
|
|
|
|
then
|
|
|
|
cnf=$cluster_file
|
|
|
|
else
|
|
|
|
cnf=/dev/null
|
|
|
|
fi
|
2005-05-07 13:23:38 +02:00
|
|
|
line="";;
|
|
|
|
*) echo $line >> $cnf; line="";;
|
2005-05-06 15:37:51 +02:00
|
|
|
esac
|
2005-05-07 13:23:38 +02:00
|
|
|
if [ "$line" ]
|
|
|
|
then
|
|
|
|
echo $line >> $d_file
|
|
|
|
fi
|
2004-04-14 10:53:21 +02:00
|
|
|
done
|
|
|
|
|
2005-05-06 16:14:30 +02:00
|
|
|
cat $dir_file | xargs mkdir -p
|
2004-04-14 10:53:21 +02:00
|
|
|
|
2005-05-06 16:14:30 +02:00
|
|
|
if [ -f $cluster_file ]
|
|
|
|
then
|
|
|
|
cat $cluster_file $config_file >> /tmp/config2.$$
|
2005-05-06 15:37:51 +02:00
|
|
|
mv /tmp/config2.$$ $config_file
|
2004-04-14 10:53:21 +02:00
|
|
|
fi
|
|
|
|
|
2005-05-06 15:37:51 +02:00
|
|
|
for i in `find . -type d -name '*.ndb_mgmd'`
|
2005-05-06 16:14:30 +02:00
|
|
|
do
|
2005-05-06 15:37:51 +02:00
|
|
|
cp $config_file $i/config.ini
|
2004-04-14 10:53:21 +02:00
|
|
|
done
|
|
|
|
|
2005-05-07 13:23:38 +02:00
|
|
|
mv $d_file d.txt
|
2005-05-06 16:14:30 +02:00
|
|
|
rm -f $config_file $dir_file $cluster_file
|