blob: 5da0ea6b258fa692a96d97d74ef0e30295693a78 [file] [log] [blame]
Thomas Vachuska5f54c6f2016-05-04 19:19:51 -07001#!/bin/bash
2# -----------------------------------------------------------------------------
3# Runs ONOS from distributable onos.tar.gz
4# -----------------------------------------------------------------------------
5
6ONOS_TAR=
7
8cd /tmp
9
10# Kill any running instances
11[ -f /tmp/onos.pid ] && kill -9 $(cat /tmp/onos.pid) &>/dev/null
12
13set -e
14
15# Blitz previously unrolled onos- directory
Thomas Vachuskafc3f3142016-05-04 20:10:10 -070016rm -fr onos-*/
Thomas Vachuska5f54c6f2016-05-04 19:19:51 -070017
18# Unroll new image from the specified tar file
19[ -f $ONOS_TAR ] && tar zxf $ONOS_TAR
20
21# Change into the ONOS home directory
Thomas Vachuskadcdf24d2016-06-13 12:10:25 -070022cd onos-*/
Thomas Vachuska5f54c6f2016-05-04 19:19:51 -070023export ONOS_HOME=$PWD
24
25# FIXME: for now we're running using the karaf client; later use raw SSH
26unset ONOS_USE_SSH
27
Madan Jampani590160a2016-06-14 16:49:44 -070028# Create config/cluster.json (cluster metadata)
29ONOS_IP=${ONOS_IP:-127.0.0.1}
30IP="${1:-$ONOS_IP}"
31echo "Creating local cluster configs for IP $IP..."
32[ -d $ONOS_HOME/config ] || mkdir -p $ONOS_HOME/config
33cat > $ONOS_HOME/config/cluster.json <<EOF
34{
35 "name": "default",
36 "nodes": [ {"id": "$IP", "ip": "$IP", "port": 9876 } ],
37 "partitions": [ { "id": 1, "members": [ "$IP" ] } ]
38}
39EOF
40
Thomas Vachuska5f54c6f2016-05-04 19:19:51 -070041# Start ONOS as a server, but include any specified options
42./bin/onos-service server "$@" &>onos.log &
43echo "$!" > /tmp/onos.pid
44
45# Hang-on a bit and then start tailing the ONOS log output
Charles Chanf9335af2016-05-05 21:05:47 -070046RETRY_COUNT=5
47echo "Waiting for karaf.log"
48until [ $RETRY_COUNT -le 0 ]; do
49 KARAF_LOG=$(find $ONOS_HOME -type f -name karaf.log)
50 if [ $KARAF_LOG ]; then
51 tail -f $KARAF_LOG
52 return
53 fi
54 RETRY_COUNT=$[$RETRY_COUNT-1]
55 sleep 1
56done
Madan Jampani590160a2016-06-14 16:49:44 -070057echo "Fail to open karaf.log"
58