blob: 082f506c266fc719f39092c54378dddf8083c4e5 [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
Thomas Vachuska734b7492015-03-11 20:42:07 -070011# Customize features
12export ONOS_FEATURES="${ONOS_FEATURES:-webconsole,onos-api,onos-core,onos-cli,onos-rest,onos-gui,onos-openflow}"
13
14
tomdefed6f2014-09-29 11:37:02 -070015# Generate a cluster.json from the ON* environment variables
Yuta HIGUCHIe4920dc2014-11-24 16:26:17 -080016CDEF_FILE=/tmp/${remote}.cluster.json
Madan Jampania14047d2015-02-25 12:23:02 -080017echo "{ \"ipPrefix\": \"$ONOS_NIC\"," > $CDEF_FILE
18echo " \"nodes\":[" >> $CDEF_FILE
tomdefed6f2014-09-29 11:37:02 -070019for node in $(env | sort | egrep "OC[2-9]+" | cut -d= -f2); do
20 echo " { \"id\": \"$node\", \"ip\": \"$node\", \"tcpPort\": 9876 }," >> $CDEF_FILE
21done
22echo " { \"id\": \"$OC1\", \"ip\": \"$OC1\", \"tcpPort\": 9876 }" >> $CDEF_FILE
23echo "]}" >> $CDEF_FILE
Yuta HIGUCHIe4920dc2014-11-24 16:26:17 -080024scp -q $CDEF_FILE $remote:$ONOS_INSTALL_DIR/config/cluster.json
tomdefed6f2014-09-29 11:37:02 -070025
Pavlin Radoslavov20bc6ae2014-12-03 05:35:04 +000026ssh $remote "
tom0768a022014-09-24 16:16:16 -070027 sudo perl -pi.bak -e \"s/ <interface>.*</ <interface>${ONOS_NIC:-192.168.56.*}</g\" \
28 $ONOS_INSTALL_DIR/$KARAF_DIST/etc/hazelcast.xml
Yuta HIGUCHI673aaeb2014-11-22 03:31:18 -080029 sudo perl -pi -e \"s/ <name>onos</ <name>${ONOS_CELL:-onos}</g\" \
30 $ONOS_INSTALL_DIR/$KARAF_DIST/etc/hazelcast.xml
tomdefed6f2014-09-29 11:37:02 -070031
32 echo \"onos.ip = \$(ifconfig | grep $ONOS_NIC | cut -d: -f2 | cut -d\\ -f1)\" \
33 >> $ONOS_INSTALL_DIR/$KARAF_DIST/etc/system.properties
Yuta HIGUCHI18fdb252014-11-28 23:48:30 -080034
35 # Drop copycat related log level for the console
36 echo "log4j.logger.net.kuujo.copycat= INFO" \
37 >> $ONOS_INSTALL_DIR/$KARAF_DIST/etc/org.ops4j.pax.logging.cfg
38
Yuta HIGUCHI190ed192015-01-28 12:32:53 -080039 # Suppress Hazelcast multicast joiner warning
40 echo "log4j.logger.com.hazelcast.cluster.impl.MulticastService= ERROR" \
41 >> $ONOS_INSTALL_DIR/$KARAF_DIST/etc/org.ops4j.pax.logging.cfg
Thomas Vachuska734b7492015-03-11 20:42:07 -070042
43 # Patch the Apache Karaf distribution file to load ONOS features
44 perl -pi.old -e \"s|^(featuresBoot=.*,management)(,webconsole,.*)|\1,$ONOS_FEATURES|\" \
45 $ONOS_INSTALL_DIR/$KARAF_DIST/etc/org.apache.karaf.features.cfg
tomdefed6f2014-09-29 11:37:02 -070046"
Yuta HIGUCHI60731cb2014-11-11 01:34:46 -080047
48# Generate a default tablets.json from the ON* environment variables
Yuta HIGUCHIe4920dc2014-11-24 16:26:17 -080049TDEF_FILE=/tmp/${remote}.tablets.json
Madan Jampani0cb00672015-02-27 00:27:22 -080050onos-gen-partitions $TDEF_FILE
Yuta HIGUCHIe4920dc2014-11-24 16:26:17 -080051scp -q $TDEF_FILE $remote:$ONOS_INSTALL_DIR/config/tablets.json
Yuta HIGUCHI60731cb2014-11-11 01:34:46 -080052
Yuta HIGUCHI60731cb2014-11-11 01:34:46 -080053# copy tools/package/config/ to remote
54scp -qr ${ONOS_ROOT}/tools/package/config/ $remote:$ONOS_INSTALL_DIR/
55