blob: a38191d4b3eff1b222b69b116c631fd303577093 [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
Ayaka Koshibef17f34a2015-09-24 19:31:48 -07006function _usage () {
7cat << _EOF_
8usage:
9 $(basename $0) [node]
10
11options:
12- [node] : The node to configure
13
14summary:
15 Remotely configures and starts ONOS for the first time.
16
17 The procedure for configruing a node include determining base features,
18 applications to load at startup, and clustering and logical network view
19 configurations, among others.
20
21 If [node] isn't specified, the defualt target becomes \$OCI.
22
23_EOF_
24}
25
26[ "$1" = "-h" ] && _usage && exit 0
27
tom5ca34372014-09-19 17:43:41 -070028[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
29. $ONOS_ROOT/tools/build/envDefaults
30
Thomas Vachuska12bf4452015-06-26 09:15:38 -070031node=${1:-$OCI}
32remote=$ONOS_USER@$node
tom5ca34372014-09-19 17:43:41 -070033
Thomas Vachuska785f5812015-03-19 01:11:00 -070034# ONOS boot features
Thomas Vachuskaf7adc6e2015-05-20 18:49:57 -070035export 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 -070036
Thomas Vachuska785f5812015-03-19 01:11:00 -070037# ONOS builtin apps and providers ignited by default
Thomas Vachuskadb7467a2015-04-17 11:06:53 -070038export ONOS_APPS="${ONOS_APPS:-drivers,openflow}"
Thomas Vachuska734b7492015-03-11 20:42:07 -070039
Bob Lantz7c751b52016-04-15 15:42:28 -070040ssh -tt $remote "
Jonathan Hart54b4a372015-03-27 15:34:32 -070041 echo \"onos.ip = \$(sudo ifconfig | grep $ONOS_NIC | cut -d: -f2 | cut -d\\ -f1)\" \
tomdefed6f2014-09-29 11:37:02 -070042 >> $ONOS_INSTALL_DIR/$KARAF_DIST/etc/system.properties
Yuta HIGUCHI18fdb252014-11-28 23:48:30 -080043
44 # Drop copycat related log level for the console
45 echo "log4j.logger.net.kuujo.copycat= INFO" \
46 >> $ONOS_INSTALL_DIR/$KARAF_DIST/etc/org.ops4j.pax.logging.cfg
47
Thomas Vachuska785f5812015-03-19 01:11:00 -070048 # Patch the Apache Karaf distribution file to load ONOS boot features
49 perl -pi.old -e \"s|^(featuresBoot=.*,management)(,webconsole,.*)|\1,$ONOS_BOOT_FEATURES|\" \
Thomas Vachuska734b7492015-03-11 20:42:07 -070050 $ONOS_INSTALL_DIR/$KARAF_DIST/etc/org.apache.karaf.features.cfg
Thomas Vachuska785f5812015-03-19 01:11:00 -070051
52 # Customize which builtin apps should be ignited
53 for app in $(echo $ONOS_APPS | tr ',' ' '); do
54 touch $ONOS_INSTALL_DIR/apps/org.onosproject.\$app/active
55 done
tomdefed6f2014-09-29 11:37:02 -070056"
Yuta HIGUCHI60731cb2014-11-11 01:34:46 -080057
Madan Jampaniec1df022015-10-13 21:23:03 -070058# Generate a default cluster.json from the ON* environment variables
59CDEF_FILE=/tmp/${remote}.cluster.json
60onos-gen-partitions $CDEF_FILE
61scp -q $CDEF_FILE $remote:$ONOS_INSTALL_DIR/config/cluster.json
Yuta HIGUCHI60731cb2014-11-11 01:34:46 -080062
Thomas Vachuskae6360222015-07-21 10:10:36 -070063# Copy tools/package/config/ to remote
Yuta HIGUCHI60731cb2014-11-11 01:34:46 -080064scp -qr ${ONOS_ROOT}/tools/package/config/ $remote:$ONOS_INSTALL_DIR/
Thomas Vachuskae6360222015-07-21 10:10:36 -070065
66# Copy the desired initial network configuration to remote if needed
Thomas Vachuska8d033672015-07-21 16:15:04 -070067[ -n "$ONOS_CFG" -a -f "$ONOS_CFG" -a "${1:-$OCI}" = "$OC1" ] && \
Thomas Vachuskae6360222015-07-21 10:10:36 -070068 scp $ONOS_CFG $remote:$ONOS_INSTALL_DIR/config/network-cfg.json