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 | |
| 6 | [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 |
| 7 | . $ONOS_ROOT/tools/build/envDefaults |
| 8 | |
Thomas Vachuska | 12bf445 | 2015-06-26 09:15:38 -0700 | [diff] [blame] | 9 | node=${1:-$OCI} |
| 10 | remote=$ONOS_USER@$node |
tom | 5ca3437 | 2014-09-19 17:43:41 -0700 | [diff] [blame] | 11 | |
Thomas Vachuska | 785f581 | 2015-03-19 01:11:00 -0700 | [diff] [blame] | 12 | # ONOS boot features |
Thomas Vachuska | f7adc6e | 2015-05-20 18:49:57 -0700 | [diff] [blame] | 13 | 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] | 14 | |
Thomas Vachuska | 785f581 | 2015-03-19 01:11:00 -0700 | [diff] [blame] | 15 | # ONOS builtin apps and providers ignited by default |
Thomas Vachuska | db7467a | 2015-04-17 11:06:53 -0700 | [diff] [blame] | 16 | export ONOS_APPS="${ONOS_APPS:-drivers,openflow}" |
Thomas Vachuska | 734b749 | 2015-03-11 20:42:07 -0700 | [diff] [blame] | 17 | |
tom | defed6f | 2014-09-29 11:37:02 -0700 | [diff] [blame] | 18 | # Generate a cluster.json from the ON* environment variables |
Yuta HIGUCHI | e4920dc | 2014-11-24 16:26:17 -0800 | [diff] [blame] | 19 | CDEF_FILE=/tmp/${remote}.cluster.json |
Madan Jampani | a14047d | 2015-02-25 12:23:02 -0800 | [diff] [blame] | 20 | echo "{ \"ipPrefix\": \"$ONOS_NIC\"," > $CDEF_FILE |
| 21 | echo " \"nodes\":[" >> $CDEF_FILE |
tom | defed6f | 2014-09-29 11:37:02 -0700 | [diff] [blame] | 22 | for node in $(env | sort | egrep "OC[2-9]+" | cut -d= -f2); do |
| 23 | echo " { \"id\": \"$node\", \"ip\": \"$node\", \"tcpPort\": 9876 }," >> $CDEF_FILE |
| 24 | done |
| 25 | echo " { \"id\": \"$OC1\", \"ip\": \"$OC1\", \"tcpPort\": 9876 }" >> $CDEF_FILE |
| 26 | echo "]}" >> $CDEF_FILE |
Yuta HIGUCHI | e4920dc | 2014-11-24 16:26:17 -0800 | [diff] [blame] | 27 | scp -q $CDEF_FILE $remote:$ONOS_INSTALL_DIR/config/cluster.json |
tom | defed6f | 2014-09-29 11:37:02 -0700 | [diff] [blame] | 28 | |
Pavlin Radoslavov | 20bc6ae | 2014-12-03 05:35:04 +0000 | [diff] [blame] | 29 | ssh $remote " |
Jonathan Hart | 54b4a37 | 2015-03-27 15:34:32 -0700 | [diff] [blame] | 30 | 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] | 31 | >> $ONOS_INSTALL_DIR/$KARAF_DIST/etc/system.properties |
Yuta HIGUCHI | 18fdb25 | 2014-11-28 23:48:30 -0800 | [diff] [blame] | 32 | |
| 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 Vachuska | 785f581 | 2015-03-19 01:11:00 -0700 | [diff] [blame] | 37 | # 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 Vachuska | 734b749 | 2015-03-11 20:42:07 -0700 | [diff] [blame] | 39 | $ONOS_INSTALL_DIR/$KARAF_DIST/etc/org.apache.karaf.features.cfg |
Thomas Vachuska | 785f581 | 2015-03-19 01:11:00 -0700 | [diff] [blame] | 40 | |
| 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 |
tom | defed6f | 2014-09-29 11:37:02 -0700 | [diff] [blame] | 45 | " |
Yuta HIGUCHI | 60731cb | 2014-11-11 01:34:46 -0800 | [diff] [blame] | 46 | |
| 47 | # Generate a default tablets.json from the ON* environment variables |
Yuta HIGUCHI | e4920dc | 2014-11-24 16:26:17 -0800 | [diff] [blame] | 48 | TDEF_FILE=/tmp/${remote}.tablets.json |
Madan Jampani | 0cb0067 | 2015-02-27 00:27:22 -0800 | [diff] [blame] | 49 | onos-gen-partitions $TDEF_FILE |
Yuta HIGUCHI | e4920dc | 2014-11-24 16:26:17 -0800 | [diff] [blame] | 50 | scp -q $TDEF_FILE $remote:$ONOS_INSTALL_DIR/config/tablets.json |
Yuta HIGUCHI | 60731cb | 2014-11-11 01:34:46 -0800 | [diff] [blame] | 51 | |
Thomas Vachuska | e636022 | 2015-07-21 10:10:36 -0700 | [diff] [blame] | 52 | # Copy tools/package/config/ to remote |
Yuta HIGUCHI | 60731cb | 2014-11-11 01:34:46 -0800 | [diff] [blame] | 53 | scp -qr ${ONOS_ROOT}/tools/package/config/ $remote:$ONOS_INSTALL_DIR/ |
Thomas Vachuska | e636022 | 2015-07-21 10:10:36 -0700 | [diff] [blame] | 54 | |
| 55 | # Copy the desired initial network configuration to remote if needed |
Thomas Vachuska | 8d03367 | 2015-07-21 16:15:04 -0700 | [diff] [blame] | 56 | [ -n "$ONOS_CFG" -a -f "$ONOS_CFG" -a "${1:-$OCI}" = "$OC1" ] && \ |
Thomas Vachuska | e636022 | 2015-07-21 10:10:36 -0700 | [diff] [blame] | 57 | scp $ONOS_CFG $remote:$ONOS_INSTALL_DIR/config/network-cfg.json |