Masayoshi Kobayashi | f358ff5 | 2013-03-22 00:31:59 +0000 | [diff] [blame] | 1 | #! /bin/bash |
| 2 | USERNAME=ubuntu |
| 3 | CASSANDRA_DIR='/home/ubuntu/apache-cassandra-1.1.4' |
| 4 | ZK_DIR='/home/ubuntu/zookeeper-3.4.5' |
| 5 | ZK_LIB='/var/lib/zookeeper' |
| 6 | CASSANDRA_LIB='/var/lib/cassandra' |
| 7 | |
| 8 | SSH_COPY="authorized_keys id_rsa id_rsa.pub known_hosts onlab-gui.pem onlabkey.pem" |
| 9 | |
| 10 | if [ $# == 2 ]; then |
| 11 | NR_NODES=$1 |
| 12 | basename=$2 |
| 13 | else |
| 14 | echo "$0 nr_nodes basename" |
| 15 | exit |
| 16 | fi |
| 17 | |
| 18 | if [ ! -f ./cluster.txt ]; then |
| 19 | echo "Cannot find cluster.txt" |
| 20 | exit |
| 21 | fi |
| 22 | |
| 23 | export CLUSTER="./cluster.txt" |
| 24 | dsh -g $basename 'uname -a' |
| 25 | |
| 26 | echo "Stopping Services" |
| 27 | #dsh -g $basename 'cd ONOS; ./start-onos.sh stop' |
| 28 | #dsh -g $basename 'cd ONOS; ./stop-cassandra stop' |
| 29 | #dsh -g $basename '$ZK_DIR/bin/zkServer.sh stop' |
| 30 | |
| 31 | # authorized_keys cassandra.yaml hosts id_rsa id_rsa.pub known_hosts onlab-gui.pem onlabkey.pem onos.properties zoo.cfg |
| 32 | ## SSH Setting |
| 33 | dsh -g $basename 'mkdir -m 700 .ssh' |
| 34 | for n in $SSH_COPY; do |
| 35 | pcp -g $basename common/$n '.ssh' |
| 36 | if [ $n != "id_rsa.pub" ] ; then |
| 37 | dsh -g $basename "chmod 600 .ssh/$n" |
| 38 | fi |
| 39 | done |
| 40 | |
| 41 | dsh -g $basename "sudo rm -rf $CASSANDRA_LIB/commitlog/*" |
| 42 | dsh -g $basename "sudo rm -rf $CASSANDRA_LIB/saved_caches/*" |
| 43 | dsh -g $basename "sudo rm -rf $CASSANDRA_LIB/data/*" |
| 44 | dsh -g $basename "sudo chown -R $username:$username $CASSANDRA_LIB" |
| 45 | |
| 46 | dsh -g $basename "sudo rm -rf $ZK_LIB/version-2*" |
| 47 | dsh -g $basename "sudo rm -rf $ZK_LIB/myid" |
| 48 | |
| 49 | pcp -g $basename common/cassandra.yaml $CASSANDRA_DIR/conf |
| 50 | pcp -g $basename common/zoo.cfg $ZK_DIR/conf |
| 51 | pcp -g $basename common/hosts '~' |
| 52 | |
| 53 | for n in `seq 1 $NR_NODES`; do |
| 54 | pcp -w ${basename}${n} ${basename}${n}/hostname '~' |
| 55 | pcp -w ${basename}${n} ${basename}${n}/myid $ZK_DIR/conf |
| 56 | done |
| 57 | |
| 58 | dsh -g $basename 'sudo cp ~/hostname /etc' |
| 59 | dsh -g $basename 'sudo cp ~/hosts /etc' |
| 60 | dsh -g $basename "cd $ZK_LIB; sudo ln -s $ZK_DIR/conf/myid" |
| 61 | |
| 62 | dsh -g $basename 'sudo hostname `cat /etc/hostname`' |
| 63 | |
| 64 | for n in `seq 2 $NR_NODES`; do |
| 65 | pcp -w ${basename}${n} ${basename}${n}/onsdemo_edge.py 'ONOS/test-network/mininet' |
| 66 | pcp -w ${basename}${n} ${basename}${n}/tunnel_onos_edge.sh 'ONOS/test-network/mininet' |
| 67 | done |
| 68 | pcp -w ${basename}1 ${basename}1/tunnel_onos_core.sh 'ONOS/test-network/mininet' |
| 69 | pcp -w ${basename}1 ${basename}1/onsdemo_core.py 'ONOS/test-network/mininet' |