blob: 5e0794f828c5ec6afc866c15127c29fee18259e0 [file] [log] [blame]
Masayoshi Kobayashif358ff52013-03-22 00:31:59 +00001#! /bin/bash
2USERNAME=ubuntu
Masayoshi Kobayashi4de8d122013-04-08 19:19:47 +00003if [ x$ONOS_CLUSTER_BASENAME == "x" -o x$ONOS_CLUSTER_NR_NODES == "x" ]; then
4 echo "set environment variable ONOS_CLUSTER_BASENAME and ONOS_CLUSTER_NR_NODES"
5 exit
6elif [ $# != 1 ]; then
7 echo "$0 hostfile"
Masayoshi Kobayashif358ff52013-03-22 00:31:59 +00008 exit
9fi
10
Masayoshi Kobayashi4de8d122013-04-08 19:19:47 +000011basename=$ONOS_CLUSTER_BASENAME
12NR_NODES=$ONOS_CLUSTER_NR_NODES
13hosts_file=$1
14
Masayoshi Kobayashif358ff52013-03-22 00:31:59 +000015for n in `seq 1 $NR_NODES`; do
16 rm -rf ${basename}${n}
17 mkdir ${basename}${n}
18 echo "${basename}${n}" > ${basename}${n}/hostname
19 echo $n > ${basename}${n}/myid
20done
21
22## ZK config ##
23cp template/zoo.cfg common/
24for n in `seq 1 $NR_NODES`; do
25 echo "server.${n}=${basename}${n}:2888:3888"
26done >> common/zoo.cfg
27
28## Cassandra config ##
29cat template/cassandra.yaml |\
30 sed "s/__SEED__/${basename}1/g" > common/cassandra.yaml
31
32## /etc/hosts ##
33cat template/hosts $hosts_file > common/hosts
34
Masayoshi Kobayashi85b3f9b2013-04-01 21:03:50 +000035
Masayoshi Kobayashif358ff52013-03-22 00:31:59 +000036## .ssh/known_hosts ##
37ssh-keyscan -H -t rsa github.com > common/known_hosts
38ssh-keyscan -H -t rsa onosnat >> common/known_hosts
39for n in `seq 1 $NR_NODES`; do
40 ssh-keyscan -H -t rsa ${basename}${n}
41done >> common/known_hosts
42
Masayoshi Kobayashi85b3f9b2013-04-01 21:03:50 +000043echo "GROUP: $basename" > bin/cluster.txt
44cat $hosts_file | awk '{print $2}' >> bin/cluster.txt
Masayoshi Kobayashif358ff52013-03-22 00:31:59 +000045
46
47## Creating shell script to login each node ##
48for n in `seq 1 $NR_NODES`; do
49 cat << EOF > bin/${basename}${n}
50#!/bin/sh
51ssh $USERNAME@${basename}${n}
52EOF
53 chmod 755 bin/${basename}${n}
54done
55
56echo "======================================"
57echo "Do not forget to do the following"
58echo "paste $hosts_file to /etc/hosts"
59echo "paste cluster.txt to your CLUSTER file"
60echo "======================================"