tom | 5ca3437 | 2014-09-19 17:43:41 -0700 | [diff] [blame] | 1 | #!/bin/bash |
Pavlin Radoslavov | 9141379 | 2014-10-15 11:00:32 -0700 | [diff] [blame] | 2 | # ----------------------------------------------------------------------------- |
tom | 5ca3437 | 2014-09-19 17:43:41 -0700 | [diff] [blame] | 3 | # Remotely configures & starts ONOS for the first time. |
Pavlin Radoslavov | 9141379 | 2014-10-15 11:00:32 -0700 | [diff] [blame] | 4 | # ----------------------------------------------------------------------------- |
tom | 5ca3437 | 2014-09-19 17:43:41 -0700 | [diff] [blame] | 5 | |
Ayaka Koshibe | f17f34a | 2015-09-24 19:31:48 -0700 | [diff] [blame] | 6 | function _usage () { |
| 7 | cat << _EOF_ |
| 8 | usage: |
| 9 | $(basename $0) [node] |
| 10 | |
| 11 | options: |
| 12 | - [node] : The node to configure |
| 13 | |
| 14 | summary: |
| 15 | Remotely configures and starts ONOS for the first time. |
| 16 | |
Marc De Leenheer | f8e0283 | 2017-01-17 15:33:11 -0800 | [diff] [blame] | 17 | The procedure for configuring a node includes determining base features, |
Ayaka Koshibe | f17f34a | 2015-09-24 19:31:48 -0700 | [diff] [blame] | 18 | applications to load at startup, and clustering and logical network view |
| 19 | configurations, among others. |
| 20 | |
Marc De Leenheer | f8e0283 | 2017-01-17 15:33:11 -0800 | [diff] [blame] | 21 | If [node] isn't specified, the default target becomes \$OCI. |
Ayaka Koshibe | f17f34a | 2015-09-24 19:31:48 -0700 | [diff] [blame] | 22 | |
| 23 | _EOF_ |
| 24 | } |
| 25 | |
| 26 | [ "$1" = "-h" ] && _usage && exit 0 |
| 27 | |
tom | 5ca3437 | 2014-09-19 17:43:41 -0700 | [diff] [blame] | 28 | [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 |
| 29 | . $ONOS_ROOT/tools/build/envDefaults |
| 30 | |
Thomas Vachuska | 12bf445 | 2015-06-26 09:15:38 -0700 | [diff] [blame] | 31 | node=${1:-$OCI} |
| 32 | remote=$ONOS_USER@$node |
DongRyeol Cha | 5c0a9f0 | 2018-05-17 14:32:55 +0900 | [diff] [blame] | 33 | remote_scp=$ONOS_USER@[$node] |
tom | 5ca3437 | 2014-09-19 17:43:41 -0700 | [diff] [blame] | 34 | |
Thomas Vachuska | 785f581 | 2015-03-19 01:11:00 -0700 | [diff] [blame] | 35 | # ONOS boot features |
Thomas Vachuska | f7adc6e | 2015-05-20 18:49:57 -0700 | [diff] [blame] | 36 | export ONOS_BOOT_FEATURES="${ONOS_BOOT_FEATURES:-webconsole,onos-api,onos-core,onos-incubator,onos-cli,onos-rest,onos-gui}" |
Thomas Vachuska | 734b749 | 2015-03-11 20:42:07 -0700 | [diff] [blame] | 37 | |
Thomas Vachuska | 785f581 | 2015-03-19 01:11:00 -0700 | [diff] [blame] | 38 | # ONOS builtin apps and providers ignited by default |
Thomas Vachuska | db7467a | 2015-04-17 11:06:53 -0700 | [diff] [blame] | 39 | export ONOS_APPS="${ONOS_APPS:-drivers,openflow}" |
Thomas Vachuska | 734b749 | 2015-03-11 20:42:07 -0700 | [diff] [blame] | 40 | |
Bob Lantz | 7c751b5 | 2016-04-15 15:42:28 -0700 | [diff] [blame] | 41 | ssh -tt $remote " |
Jonathan Hart | 54b4a37 | 2015-03-27 15:34:32 -0700 | [diff] [blame] | 42 | echo \"onos.ip = \$(sudo ifconfig | grep $ONOS_NIC | cut -d: -f2 | cut -d\\ -f1)\" \ |
tom | defed6f | 2014-09-29 11:37:02 -0700 | [diff] [blame] | 43 | >> $ONOS_INSTALL_DIR/$KARAF_DIST/etc/system.properties |
Yuta HIGUCHI | 18fdb25 | 2014-11-28 23:48:30 -0800 | [diff] [blame] | 44 | |
| 45 | # Drop copycat related log level for the console |
Jordan Halterman | 00e92da | 2018-05-22 23:05:52 -0700 | [diff] [blame] | 46 | echo "log4j.logger.io.atomix=INFO" \ |
| 47 | >> $ONOS_INSTALL_DIR/$KARAF_DIST/etc/org.ops4j.pax.logging.cfg |
| 48 | echo "log4j.logger.io.atomix.cluster.messaging=ERROR" \ |
Yuta HIGUCHI | 18fdb25 | 2014-11-28 23:48:30 -0800 | [diff] [blame] | 49 | >> $ONOS_INSTALL_DIR/$KARAF_DIST/etc/org.ops4j.pax.logging.cfg |
| 50 | |
Thomas Vachuska | 785f581 | 2015-03-19 01:11:00 -0700 | [diff] [blame] | 51 | # Patch the Apache Karaf distribution file to load ONOS boot features |
| 52 | perl -pi.old -e \"s|^(featuresBoot=.*,management)(,webconsole,.*)|\1,$ONOS_BOOT_FEATURES|\" \ |
Thomas Vachuska | 734b749 | 2015-03-11 20:42:07 -0700 | [diff] [blame] | 53 | $ONOS_INSTALL_DIR/$KARAF_DIST/etc/org.apache.karaf.features.cfg |
Thomas Vachuska | 785f581 | 2015-03-19 01:11:00 -0700 | [diff] [blame] | 54 | |
| 55 | # Customize which builtin apps should be ignited |
| 56 | for app in $(echo $ONOS_APPS | tr ',' ' '); do |
Marc De Leenheer | f8e0283 | 2017-01-17 15:33:11 -0800 | [diff] [blame] | 57 | if [ -d \"$ONOS_INSTALL_DIR/apps/org.onosproject.\$app/\" ]; then |
| 58 | touch $ONOS_INSTALL_DIR/apps/org.onosproject.\$app/active |
| 59 | elif [ -d \"$ONOS_INSTALL_DIR/apps/\$app\" ]; then |
| 60 | touch $ONOS_INSTALL_DIR/apps/\$app/active |
| 61 | else |
| 62 | echo \"[WARN] Don\'t know how to activate \$app\" |
| 63 | fi |
Thomas Vachuska | 785f581 | 2015-03-19 01:11:00 -0700 | [diff] [blame] | 64 | done |
tom | defed6f | 2014-09-29 11:37:02 -0700 | [diff] [blame] | 65 | " |
Yuta HIGUCHI | 60731cb | 2014-11-11 01:34:46 -0800 | [diff] [blame] | 66 | |
Madan Jampani | ec1df02 | 2015-10-13 21:23:03 -0700 | [diff] [blame] | 67 | # Generate a default cluster.json from the ON* environment variables |
| 68 | CDEF_FILE=/tmp/${remote}.cluster.json |
Jordan Halterman | 00e92da | 2018-05-22 23:05:52 -0700 | [diff] [blame] | 69 | onos-gen-config $CDEF_FILE |
DongRyeol Cha | 5c0a9f0 | 2018-05-17 14:32:55 +0900 | [diff] [blame] | 70 | scp -q $CDEF_FILE $remote_scp:$ONOS_INSTALL_DIR/config/cluster.json |
Yuta HIGUCHI | 60731cb | 2014-11-11 01:34:46 -0800 | [diff] [blame] | 71 | |
Thomas Vachuska | e636022 | 2015-07-21 10:10:36 -0700 | [diff] [blame] | 72 | # Copy tools/package/config/ to remote |
DongRyeol Cha | 5c0a9f0 | 2018-05-17 14:32:55 +0900 | [diff] [blame] | 73 | scp -qr ${ONOS_ROOT}/tools/package/config/ $remote_scp:$ONOS_INSTALL_DIR/ |
Thomas Vachuska | e636022 | 2015-07-21 10:10:36 -0700 | [diff] [blame] | 74 | |
| 75 | # Copy the desired initial network configuration to remote if needed |
Thomas Vachuska | 8d03367 | 2015-07-21 16:15:04 -0700 | [diff] [blame] | 76 | [ -n "$ONOS_CFG" -a -f "$ONOS_CFG" -a "${1:-$OCI}" = "$OC1" ] && \ |
DongRyeol Cha | 5c0a9f0 | 2018-05-17 14:32:55 +0900 | [diff] [blame] | 77 | scp $ONOS_CFG $remote_scp:$ONOS_INSTALL_DIR/config/network-cfg.json || true |