blob: 7ada015a13bc7f427147da68d2e974e2b98496e9 [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
Marc De Leenheerf8e02832017-01-17 15:33:11 -080017 The procedure for configuring a node includes determining base features,
Ayaka Koshibef17f34a2015-09-24 19:31:48 -070018 applications to load at startup, and clustering and logical network view
19 configurations, among others.
20
Marc De Leenheerf8e02832017-01-17 15:33:11 -080021 If [node] isn't specified, the default target becomes \$OCI.
Ayaka Koshibef17f34a2015-09-24 19:31:48 -070022
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
DongRyeol Cha5c0a9f02018-05-17 14:32:55 +090033remote_scp=$ONOS_USER@[$node]
tom5ca34372014-09-19 17:43:41 -070034
Thomas Vachuska785f5812015-03-19 01:11:00 -070035# ONOS boot features
Thomas Vachuskaf7adc6e2015-05-20 18:49:57 -070036export 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 -070037
Thomas Vachuska785f5812015-03-19 01:11:00 -070038# ONOS builtin apps and providers ignited by default
Sean Condonbf7ff4f2019-03-17 16:18:42 +000039export ONOS_APPS="${ONOS_APPS:-gui,drivers,openflow}"
Thomas Vachuska734b7492015-03-11 20:42:07 -070040
Bob Lantz7c751b52016-04-15 15:42:28 -070041ssh -tt $remote "
Thomas Vachuska5d80e452019-03-21 14:10:13 -070042 # Drop atomix related log level for the console
Jordan Haltermana0c5dc12018-11-12 11:04:46 -080043 echo "log4j2.logger.atomix.name = io.atomix.protocols.raft" >> $ONOS_INSTALL_DIR/$KARAF_DIST/etc/org.ops4j.pax.logging.cfg
44 echo "log4j2.logger.atomix.level = INFO" >> $ONOS_INSTALL_DIR/$KARAF_DIST/etc/org.ops4j.pax.logging.cfg
Yuta HIGUCHI18fdb252014-11-28 23:48:30 -080045
Thomas Vachuska785f5812015-03-19 01:11:00 -070046 # Patch the Apache Karaf distribution file to load ONOS boot features
47 perl -pi.old -e \"s|^(featuresBoot=.*,management)(,webconsole,.*)|\1,$ONOS_BOOT_FEATURES|\" \
Thomas Vachuska734b7492015-03-11 20:42:07 -070048 $ONOS_INSTALL_DIR/$KARAF_DIST/etc/org.apache.karaf.features.cfg
Thomas Vachuska785f5812015-03-19 01:11:00 -070049
50 # Customize which builtin apps should be ignited
51 for app in $(echo $ONOS_APPS | tr ',' ' '); do
Marc De Leenheerf8e02832017-01-17 15:33:11 -080052 if [ -d \"$ONOS_INSTALL_DIR/apps/org.onosproject.\$app/\" ]; then
53 touch $ONOS_INSTALL_DIR/apps/org.onosproject.\$app/active
54 elif [ -d \"$ONOS_INSTALL_DIR/apps/\$app\" ]; then
55 touch $ONOS_INSTALL_DIR/apps/\$app/active
56 else
57 echo \"[WARN] Don\'t know how to activate \$app\"
58 fi
Thomas Vachuska785f5812015-03-19 01:11:00 -070059 done
tomdefed6f2014-09-29 11:37:02 -070060"
Yuta HIGUCHI60731cb2014-11-11 01:34:46 -080061
Madan Jampaniec1df022015-10-13 21:23:03 -070062# Generate a default cluster.json from the ON* environment variables
63CDEF_FILE=/tmp/${remote}.cluster.json
Jordan Haltermand326de12018-07-31 11:57:21 -070064onos-gen-config $node $CDEF_FILE
DongRyeol Cha5c0a9f02018-05-17 14:32:55 +090065scp -q $CDEF_FILE $remote_scp:$ONOS_INSTALL_DIR/config/cluster.json
Yuta HIGUCHI60731cb2014-11-11 01:34:46 -080066
Thomas Vachuskae6360222015-07-21 10:10:36 -070067# Copy tools/package/config/ to remote
DongRyeol Cha5c0a9f02018-05-17 14:32:55 +090068scp -qr ${ONOS_ROOT}/tools/package/config/ $remote_scp:$ONOS_INSTALL_DIR/
Thomas Vachuskae6360222015-07-21 10:10:36 -070069
70# Copy the desired initial network configuration to remote if needed
Thomas Vachuska8d033672015-07-21 16:15:04 -070071[ -n "$ONOS_CFG" -a -f "$ONOS_CFG" -a "${1:-$OCI}" = "$OC1" ] && \
DongRyeol Cha5c0a9f02018-05-17 14:32:55 +090072 scp $ONOS_CFG $remote_scp:$ONOS_INSTALL_DIR/config/network-cfg.json || true