blob: 35232bdb7703e3ee39a0d038b033367b809ef414 [file] [log] [blame]
tom5ca34372014-09-19 17:43:41 -07001#!/bin/bash
Pavlin Radoslavov91413792014-10-15 11:00:32 -07002# -----------------------------------------------------------------------------
tom5ca34372014-09-19 17:43:41 -07003# Remotely configures & starts ONOS for the first time.
Pavlin Radoslavov91413792014-10-15 11:00:32 -07004# -----------------------------------------------------------------------------
tom5ca34372014-09-19 17:43:41 -07005
6[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
7. $ONOS_ROOT/tools/build/envDefaults
8
9remote=$ONOS_USER@${1:-$OCI}
10
tomdefed6f2014-09-29 11:37:02 -070011# Generate a cluster.json from the ON* environment variables
Yuta HIGUCHIe4920dc2014-11-24 16:26:17 -080012CDEF_FILE=/tmp/${remote}.cluster.json
tomdefed6f2014-09-29 11:37:02 -070013echo "{ \"nodes\":[" > $CDEF_FILE
14for node in $(env | sort | egrep "OC[2-9]+" | cut -d= -f2); do
15 echo " { \"id\": \"$node\", \"ip\": \"$node\", \"tcpPort\": 9876 }," >> $CDEF_FILE
16done
17echo " { \"id\": \"$OC1\", \"ip\": \"$OC1\", \"tcpPort\": 9876 }" >> $CDEF_FILE
18echo "]}" >> $CDEF_FILE
Yuta HIGUCHIe4920dc2014-11-24 16:26:17 -080019scp -q $CDEF_FILE $remote:$ONOS_INSTALL_DIR/config/cluster.json
tomdefed6f2014-09-29 11:37:02 -070020
Pavlin Radoslavov20bc6ae2014-12-03 05:35:04 +000021ssh $remote "
tom0768a022014-09-24 16:16:16 -070022 sudo perl -pi.bak -e \"s/ <interface>.*</ <interface>${ONOS_NIC:-192.168.56.*}</g\" \
23 $ONOS_INSTALL_DIR/$KARAF_DIST/etc/hazelcast.xml
Yuta HIGUCHI673aaeb2014-11-22 03:31:18 -080024 sudo perl -pi -e \"s/ <name>onos</ <name>${ONOS_CELL:-onos}</g\" \
25 $ONOS_INSTALL_DIR/$KARAF_DIST/etc/hazelcast.xml
tomdefed6f2014-09-29 11:37:02 -070026
27 echo \"onos.ip = \$(ifconfig | grep $ONOS_NIC | cut -d: -f2 | cut -d\\ -f1)\" \
28 >> $ONOS_INSTALL_DIR/$KARAF_DIST/etc/system.properties
Yuta HIGUCHI18fdb252014-11-28 23:48:30 -080029
30 # Drop copycat related log level for the console
31 echo "log4j.logger.net.kuujo.copycat= INFO" \
32 >> $ONOS_INSTALL_DIR/$KARAF_DIST/etc/org.ops4j.pax.logging.cfg
33
Yuta HIGUCHI190ed192015-01-28 12:32:53 -080034 # Suppress Hazelcast multicast joiner warning
35 echo "log4j.logger.com.hazelcast.cluster.impl.MulticastService= ERROR" \
36 >> $ONOS_INSTALL_DIR/$KARAF_DIST/etc/org.ops4j.pax.logging.cfg
tomdefed6f2014-09-29 11:37:02 -070037"
Yuta HIGUCHI60731cb2014-11-11 01:34:46 -080038
39# Generate a default tablets.json from the ON* environment variables
Yuta HIGUCHIe4920dc2014-11-24 16:26:17 -080040TDEF_FILE=/tmp/${remote}.tablets.json
41nodes=( $(env | sort | egrep "OC[0-9]+" | cut -d= -f2) )
Yuta HIGUCHI60731cb2014-11-11 01:34:46 -080042echo "{ \"default\":[" > $TDEF_FILE
Yuta HIGUCHIe4920dc2014-11-24 16:26:17 -080043while [ ${#nodes[@]} -gt 0 ]; do
44 node=${nodes[0]}
45 nodes=( ${nodes[@]:1} )
46 if [ "${#nodes[@]}" -ne "0" ]; then
47 echo " { \"id\": \"$node\", \"ip\": \"$node\", \"tcpPort\": 9876 }," >> $TDEF_FILE
48 else
49 echo " { \"id\": \"$node\", \"ip\": \"$node\", \"tcpPort\": 9876 }" >> $TDEF_FILE
50 fi
Yuta HIGUCHI60731cb2014-11-11 01:34:46 -080051done
Yuta HIGUCHI60731cb2014-11-11 01:34:46 -080052echo "]}" >> $TDEF_FILE
Yuta HIGUCHIe4920dc2014-11-24 16:26:17 -080053scp -q $TDEF_FILE $remote:$ONOS_INSTALL_DIR/config/tablets.json
Yuta HIGUCHI60731cb2014-11-11 01:34:46 -080054
55
56# copy tools/package/config/ to remote
57scp -qr ${ONOS_ROOT}/tools/package/config/ $remote:$ONOS_INSTALL_DIR/
58