blob: 0099e820739577ee9715c12a1b3129818ff41669 [file] [log] [blame]
Masayoshi Kobayashif358ff52013-03-22 00:31:59 +00001#! /bin/bash
2USERNAME=ubuntu
3if [ $# == 3 ]; then
4 NR_NODES=$1
5 basename=$2
6 hosts_file=$3
7else
8 echo "$0 nr_hodes basename hostfile"
9 exit
10fi
11
12for n in `seq 1 $NR_NODES`; do
13 rm -rf ${basename}${n}
14 mkdir ${basename}${n}
15 echo "${basename}${n}" > ${basename}${n}/hostname
16 echo $n > ${basename}${n}/myid
17done
18
19## ZK config ##
20cp template/zoo.cfg common/
21for n in `seq 1 $NR_NODES`; do
22 echo "server.${n}=${basename}${n}:2888:3888"
23done >> common/zoo.cfg
24
25## Cassandra config ##
26cat template/cassandra.yaml |\
27 sed "s/__SEED__/${basename}1/g" > common/cassandra.yaml
28
29## /etc/hosts ##
30cat template/hosts $hosts_file > common/hosts
31
Masayoshi Kobayashi85b3f9b2013-04-01 21:03:50 +000032
Masayoshi Kobayashif358ff52013-03-22 00:31:59 +000033## .ssh/known_hosts ##
34ssh-keyscan -H -t rsa github.com > common/known_hosts
35ssh-keyscan -H -t rsa onosnat >> common/known_hosts
36for n in `seq 1 $NR_NODES`; do
37 ssh-keyscan -H -t rsa ${basename}${n}
38done >> common/known_hosts
39
Masayoshi Kobayashi85b3f9b2013-04-01 21:03:50 +000040echo "GROUP: $basename" > bin/cluster.txt
41cat $hosts_file | awk '{print $2}' >> bin/cluster.txt
Masayoshi Kobayashif358ff52013-03-22 00:31:59 +000042
43
44## Creating shell script to login each node ##
45for n in `seq 1 $NR_NODES`; do
46 cat << EOF > bin/${basename}${n}
47#!/bin/sh
48ssh $USERNAME@${basename}${n}
49EOF
50 chmod 755 bin/${basename}${n}
51done
52
53echo "======================================"
54echo "Do not forget to do the following"
55echo "paste $hosts_file to /etc/hosts"
56echo "paste cluster.txt to your CLUSTER file"
57echo "======================================"