blob: 732aa8f68bb39722fed08b7758b672da424bcfa7 [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
Thomas Vachuska12bf4452015-06-26 09:15:38 -07009node=${1:-$OCI}
10remote=$ONOS_USER@$node
tom5ca34372014-09-19 17:43:41 -070011
Thomas Vachuska785f5812015-03-19 01:11:00 -070012# ONOS boot features
Thomas Vachuskaf7adc6e2015-05-20 18:49:57 -070013export ONOS_BOOT_FEATURES="${ONOS_BOOT_FEATURES:-webconsole,onos-api,onos-core,onos-incubator,onos-cli,onos-rest,onos-gui}"
Thomas Vachuska734b7492015-03-11 20:42:07 -070014
Thomas Vachuska785f5812015-03-19 01:11:00 -070015# ONOS builtin apps and providers ignited by default
Thomas Vachuskadb7467a2015-04-17 11:06:53 -070016export ONOS_APPS="${ONOS_APPS:-drivers,openflow}"
Thomas Vachuska734b7492015-03-11 20:42:07 -070017
tomdefed6f2014-09-29 11:37:02 -070018# Generate a cluster.json from the ON* environment variables
Yuta HIGUCHIe4920dc2014-11-24 16:26:17 -080019CDEF_FILE=/tmp/${remote}.cluster.json
Madan Jampania14047d2015-02-25 12:23:02 -080020echo "{ \"ipPrefix\": \"$ONOS_NIC\"," > $CDEF_FILE
21echo " \"nodes\":[" >> $CDEF_FILE
tomdefed6f2014-09-29 11:37:02 -070022for node in $(env | sort | egrep "OC[2-9]+" | cut -d= -f2); do
23 echo " { \"id\": \"$node\", \"ip\": \"$node\", \"tcpPort\": 9876 }," >> $CDEF_FILE
24done
25echo " { \"id\": \"$OC1\", \"ip\": \"$OC1\", \"tcpPort\": 9876 }" >> $CDEF_FILE
26echo "]}" >> $CDEF_FILE
Yuta HIGUCHIe4920dc2014-11-24 16:26:17 -080027scp -q $CDEF_FILE $remote:$ONOS_INSTALL_DIR/config/cluster.json
tomdefed6f2014-09-29 11:37:02 -070028
Pavlin Radoslavov20bc6ae2014-12-03 05:35:04 +000029ssh $remote "
Jonathan Hart54b4a372015-03-27 15:34:32 -070030 echo \"onos.ip = \$(sudo ifconfig | grep $ONOS_NIC | cut -d: -f2 | cut -d\\ -f1)\" \
tomdefed6f2014-09-29 11:37:02 -070031 >> $ONOS_INSTALL_DIR/$KARAF_DIST/etc/system.properties
Yuta HIGUCHI18fdb252014-11-28 23:48:30 -080032
33 # Drop copycat related log level for the console
34 echo "log4j.logger.net.kuujo.copycat= INFO" \
35 >> $ONOS_INSTALL_DIR/$KARAF_DIST/etc/org.ops4j.pax.logging.cfg
36
Thomas Vachuska785f5812015-03-19 01:11:00 -070037 # Patch the Apache Karaf distribution file to load ONOS boot features
38 perl -pi.old -e \"s|^(featuresBoot=.*,management)(,webconsole,.*)|\1,$ONOS_BOOT_FEATURES|\" \
Thomas Vachuska734b7492015-03-11 20:42:07 -070039 $ONOS_INSTALL_DIR/$KARAF_DIST/etc/org.apache.karaf.features.cfg
Thomas Vachuska785f5812015-03-19 01:11:00 -070040
41 # Customize which builtin apps should be ignited
42 for app in $(echo $ONOS_APPS | tr ',' ' '); do
43 touch $ONOS_INSTALL_DIR/apps/org.onosproject.\$app/active
44 done
tomdefed6f2014-09-29 11:37:02 -070045"
Yuta HIGUCHI60731cb2014-11-11 01:34:46 -080046
47# Generate a default tablets.json from the ON* environment variables
Yuta HIGUCHIe4920dc2014-11-24 16:26:17 -080048TDEF_FILE=/tmp/${remote}.tablets.json
Madan Jampani0cb00672015-02-27 00:27:22 -080049onos-gen-partitions $TDEF_FILE
Yuta HIGUCHIe4920dc2014-11-24 16:26:17 -080050scp -q $TDEF_FILE $remote:$ONOS_INSTALL_DIR/config/tablets.json
Yuta HIGUCHI60731cb2014-11-11 01:34:46 -080051
Yuta HIGUCHI60731cb2014-11-11 01:34:46 -080052# copy tools/package/config/ to remote
53scp -qr ${ONOS_ROOT}/tools/package/config/ $remote:$ONOS_INSTALL_DIR/