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 | |
| 9 | remote=$ONOS_USER@${1:-$OCI} |
| 10 | |
Thomas Vachuska | 734b749 | 2015-03-11 20:42:07 -0700 | [diff] [blame] | 11 | # Customize features |
| 12 | export ONOS_FEATURES="${ONOS_FEATURES:-webconsole,onos-api,onos-core,onos-cli,onos-rest,onos-gui,onos-openflow}" |
| 13 | |
| 14 | |
tom | defed6f | 2014-09-29 11:37:02 -0700 | [diff] [blame] | 15 | # Generate a cluster.json from the ON* environment variables |
Yuta HIGUCHI | e4920dc | 2014-11-24 16:26:17 -0800 | [diff] [blame] | 16 | CDEF_FILE=/tmp/${remote}.cluster.json |
Madan Jampani | a14047d | 2015-02-25 12:23:02 -0800 | [diff] [blame] | 17 | echo "{ \"ipPrefix\": \"$ONOS_NIC\"," > $CDEF_FILE |
| 18 | echo " \"nodes\":[" >> $CDEF_FILE |
tom | defed6f | 2014-09-29 11:37:02 -0700 | [diff] [blame] | 19 | for node in $(env | sort | egrep "OC[2-9]+" | cut -d= -f2); do |
| 20 | echo " { \"id\": \"$node\", \"ip\": \"$node\", \"tcpPort\": 9876 }," >> $CDEF_FILE |
| 21 | done |
| 22 | echo " { \"id\": \"$OC1\", \"ip\": \"$OC1\", \"tcpPort\": 9876 }" >> $CDEF_FILE |
| 23 | echo "]}" >> $CDEF_FILE |
Yuta HIGUCHI | e4920dc | 2014-11-24 16:26:17 -0800 | [diff] [blame] | 24 | scp -q $CDEF_FILE $remote:$ONOS_INSTALL_DIR/config/cluster.json |
tom | defed6f | 2014-09-29 11:37:02 -0700 | [diff] [blame] | 25 | |
Pavlin Radoslavov | 20bc6ae | 2014-12-03 05:35:04 +0000 | [diff] [blame] | 26 | ssh $remote " |
tom | 0768a02 | 2014-09-24 16:16:16 -0700 | [diff] [blame] | 27 | sudo perl -pi.bak -e \"s/ <interface>.*</ <interface>${ONOS_NIC:-192.168.56.*}</g\" \ |
| 28 | $ONOS_INSTALL_DIR/$KARAF_DIST/etc/hazelcast.xml |
Yuta HIGUCHI | 673aaeb | 2014-11-22 03:31:18 -0800 | [diff] [blame] | 29 | sudo perl -pi -e \"s/ <name>onos</ <name>${ONOS_CELL:-onos}</g\" \ |
| 30 | $ONOS_INSTALL_DIR/$KARAF_DIST/etc/hazelcast.xml |
tom | defed6f | 2014-09-29 11:37:02 -0700 | [diff] [blame] | 31 | |
| 32 | echo \"onos.ip = \$(ifconfig | grep $ONOS_NIC | cut -d: -f2 | cut -d\\ -f1)\" \ |
| 33 | >> $ONOS_INSTALL_DIR/$KARAF_DIST/etc/system.properties |
Yuta HIGUCHI | 18fdb25 | 2014-11-28 23:48:30 -0800 | [diff] [blame] | 34 | |
| 35 | # Drop copycat related log level for the console |
| 36 | echo "log4j.logger.net.kuujo.copycat= INFO" \ |
| 37 | >> $ONOS_INSTALL_DIR/$KARAF_DIST/etc/org.ops4j.pax.logging.cfg |
| 38 | |
Yuta HIGUCHI | 190ed19 | 2015-01-28 12:32:53 -0800 | [diff] [blame] | 39 | # Suppress Hazelcast multicast joiner warning |
| 40 | echo "log4j.logger.com.hazelcast.cluster.impl.MulticastService= ERROR" \ |
| 41 | >> $ONOS_INSTALL_DIR/$KARAF_DIST/etc/org.ops4j.pax.logging.cfg |
Thomas Vachuska | 734b749 | 2015-03-11 20:42:07 -0700 | [diff] [blame] | 42 | |
| 43 | # Patch the Apache Karaf distribution file to load ONOS features |
| 44 | perl -pi.old -e \"s|^(featuresBoot=.*,management)(,webconsole,.*)|\1,$ONOS_FEATURES|\" \ |
| 45 | $ONOS_INSTALL_DIR/$KARAF_DIST/etc/org.apache.karaf.features.cfg |
tom | defed6f | 2014-09-29 11:37:02 -0700 | [diff] [blame] | 46 | " |
Yuta HIGUCHI | 60731cb | 2014-11-11 01:34:46 -0800 | [diff] [blame] | 47 | |
| 48 | # Generate a default tablets.json from the ON* environment variables |
Yuta HIGUCHI | e4920dc | 2014-11-24 16:26:17 -0800 | [diff] [blame] | 49 | TDEF_FILE=/tmp/${remote}.tablets.json |
Madan Jampani | 0cb0067 | 2015-02-27 00:27:22 -0800 | [diff] [blame] | 50 | onos-gen-partitions $TDEF_FILE |
Yuta HIGUCHI | e4920dc | 2014-11-24 16:26:17 -0800 | [diff] [blame] | 51 | scp -q $TDEF_FILE $remote:$ONOS_INSTALL_DIR/config/tablets.json |
Yuta HIGUCHI | 60731cb | 2014-11-11 01:34:46 -0800 | [diff] [blame] | 52 | |
Yuta HIGUCHI | 60731cb | 2014-11-11 01:34:46 -0800 | [diff] [blame] | 53 | # copy tools/package/config/ to remote |
| 54 | scp -qr ${ONOS_ROOT}/tools/package/config/ $remote:$ONOS_INSTALL_DIR/ |
| 55 | |