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 | |
Masayoshi Kobayashi | 4de8d12 | 2013-04-08 19:19:47 +0000 | [diff] [blame] | 10 | if [ x$ONOS_CLUSTER_BASENAME == "x" -o x$ONOS_CLUSTER_NR_NODES == "x" ]; then |
| 11 | echo "set environment variable ONOS_CLUSTER_BASENAME and ONOS_CLUSTER_NR_NODES" |
Masayoshi Kobayashi | f358ff5 | 2013-03-22 00:31:59 +0000 | [diff] [blame] | 12 | exit |
| 13 | fi |
| 14 | |
Masayoshi Kobayashi | 4de8d12 | 2013-04-08 19:19:47 +0000 | [diff] [blame] | 15 | basename=$ONOS_CLUSTER_BASENAME |
| 16 | NR_NODES=$ONOS_CLUSTER_NR_NODES |
| 17 | |
Masayoshi Kobayashi | f358ff5 | 2013-03-22 00:31:59 +0000 | [diff] [blame] | 18 | dsh -g $basename 'uname -a' |
| 19 | |
| 20 | echo "Stopping Services" |
| 21 | #dsh -g $basename 'cd ONOS; ./start-onos.sh stop' |
| 22 | #dsh -g $basename 'cd ONOS; ./stop-cassandra stop' |
| 23 | #dsh -g $basename '$ZK_DIR/bin/zkServer.sh stop' |
| 24 | |
| 25 | # authorized_keys cassandra.yaml hosts id_rsa id_rsa.pub known_hosts onlab-gui.pem onlabkey.pem onos.properties zoo.cfg |
| 26 | ## SSH Setting |
| 27 | dsh -g $basename 'mkdir -m 700 .ssh' |
| 28 | for n in $SSH_COPY; do |
| 29 | pcp -g $basename common/$n '.ssh' |
| 30 | if [ $n != "id_rsa.pub" ] ; then |
| 31 | dsh -g $basename "chmod 600 .ssh/$n" |
| 32 | fi |
| 33 | done |
| 34 | |
| 35 | dsh -g $basename "sudo rm -rf $CASSANDRA_LIB/commitlog/*" |
| 36 | dsh -g $basename "sudo rm -rf $CASSANDRA_LIB/saved_caches/*" |
| 37 | dsh -g $basename "sudo rm -rf $CASSANDRA_LIB/data/*" |
| 38 | dsh -g $basename "sudo chown -R $username:$username $CASSANDRA_LIB" |
| 39 | |
| 40 | dsh -g $basename "sudo rm -rf $ZK_LIB/version-2*" |
| 41 | dsh -g $basename "sudo rm -rf $ZK_LIB/myid" |
| 42 | |
| 43 | pcp -g $basename common/cassandra.yaml $CASSANDRA_DIR/conf |
| 44 | pcp -g $basename common/zoo.cfg $ZK_DIR/conf |
| 45 | pcp -g $basename common/hosts '~' |
| 46 | |
| 47 | for n in `seq 1 $NR_NODES`; do |
| 48 | pcp -w ${basename}${n} ${basename}${n}/hostname '~' |
| 49 | pcp -w ${basename}${n} ${basename}${n}/myid $ZK_DIR/conf |
| 50 | done |
| 51 | |
| 52 | dsh -g $basename 'sudo cp ~/hostname /etc' |
| 53 | dsh -g $basename 'sudo cp ~/hosts /etc' |
| 54 | dsh -g $basename "cd $ZK_LIB; sudo ln -s $ZK_DIR/conf/myid" |
| 55 | |
| 56 | dsh -g $basename 'sudo hostname `cat /etc/hostname`' |
| 57 | |
Masayoshi Kobayashi | 4de8d12 | 2013-04-08 19:19:47 +0000 | [diff] [blame] | 58 | #for n in `seq 2 $NR_NODES`; do |
| 59 | # pcp -w ${basename}${n} ${basename}${n}/onsdemo_edge.py 'ONOS/test-network/mininet' |
| 60 | # pcp -w ${basename}${n} ${basename}${n}/tunnel_onos_edge.sh 'ONOS/test-network/mininet' |
| 61 | #done |
| 62 | #pcp -w ${basename}1 ${basename}1/tunnel_onos_core.sh 'ONOS/test-network/mininet' |
| 63 | #pcp -w ${basename}1 ${basename}1/onsdemo_core.py 'ONOS/test-network/mininet' |