blob: b72bb8c666bc266f7db3792f24d97f426610f846 [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
12CDEF_FILE=/tmp/cluster.json
13echo "{ \"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
19
tom0768a022014-09-24 16:16:16 -070020ssh $remote "
21 sudo perl -pi.bak -e \"s/ <interface>.*</ <interface>${ONOS_NIC:-192.168.56.*}</g\" \
22 $ONOS_INSTALL_DIR/$KARAF_DIST/etc/hazelcast.xml
tomdefed6f2014-09-29 11:37:02 -070023
24 echo \"onos.ip = \$(ifconfig | grep $ONOS_NIC | cut -d: -f2 | cut -d\\ -f1)\" \
25 >> $ONOS_INSTALL_DIR/$KARAF_DIST/etc/system.properties
26"
Pavlin Radoslavov91413792014-10-15 11:00:32 -070027scp -q $CDEF_FILE $remote:$ONOS_INSTALL_DIR/config/
Yuta HIGUCHI60731cb2014-11-11 01:34:46 -080028
29# Generate a default tablets.json from the ON* environment variables
30TDEF_FILE=/tmp/tablets.json
31echo "{ \"default\":[" > $TDEF_FILE
32for node in $(env | sort | egrep "OC[2-9]+" | cut -d= -f2); do
33 echo " { \"id\": \"$node\", \"ip\": \"$node\", \"tcpPort\": 9876 }," >> $TDEF_FILE
34done
35echo " { \"id\": \"$OC1\", \"ip\": \"$OC1\", \"tcpPort\": 9876 }" >> $TDEF_FILE
36echo "]}" >> $TDEF_FILE
37scp -q $TDEF_FILE $remote:$ONOS_INSTALL_DIR/config/
38
39
40# copy tools/package/config/ to remote
41scp -qr ${ONOS_ROOT}/tools/package/config/ $remote:$ONOS_INSTALL_DIR/
42