blob: b97a8180a53b80fd05d0c4ff248d36d8be6569b3 [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
32## .ssh/known_hosts ##
33ssh-keyscan -H -t rsa github.com > common/known_hosts
34ssh-keyscan -H -t rsa onosnat >> common/known_hosts
35for n in `seq 1 $NR_NODES`; do
36 ssh-keyscan -H -t rsa ${basename}${n}
37done >> common/known_hosts
38
39echo "GROUP: $basename" > cluster.txt
40cat $hosts_file | awk '{print $2}' >> cluster.txt
41
42
43## Creating shell script to login each node ##
44for n in `seq 1 $NR_NODES`; do
45 cat << EOF > bin/${basename}${n}
46#!/bin/sh
47ssh $USERNAME@${basename}${n}
48EOF
49 chmod 755 bin/${basename}${n}
50done
51
52echo "======================================"
53echo "Do not forget to do the following"
54echo "paste $hosts_file to /etc/hosts"
55echo "paste cluster.txt to your CLUSTER file"
56echo "======================================"