Thomas Vachuska | 5f54c6f | 2016-05-04 19:19:51 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # ----------------------------------------------------------------------------- |
| 3 | # Runs ONOS from distributable onos.tar.gz |
| 4 | # ----------------------------------------------------------------------------- |
| 5 | |
| 6 | ONOS_TAR= |
| 7 | |
| 8 | cd /tmp |
| 9 | |
| 10 | # Kill any running instances |
| 11 | [ -f /tmp/onos.pid ] && kill -9 $(cat /tmp/onos.pid) &>/dev/null |
| 12 | |
| 13 | set -e |
| 14 | |
| 15 | # Blitz previously unrolled onos- directory |
Thomas Vachuska | fc3f314 | 2016-05-04 20:10:10 -0700 | [diff] [blame] | 16 | rm -fr onos-*/ |
Thomas Vachuska | 5f54c6f | 2016-05-04 19:19:51 -0700 | [diff] [blame] | 17 | |
| 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 |
| 22 | cd onos-* |
| 23 | export ONOS_HOME=$PWD |
| 24 | |
| 25 | # FIXME: for now we're running using the karaf client; later use raw SSH |
| 26 | unset ONOS_USE_SSH |
| 27 | |
| 28 | # Start ONOS as a server, but include any specified options |
| 29 | ./bin/onos-service server "$@" &>onos.log & |
| 30 | echo "$!" > /tmp/onos.pid |
| 31 | |
| 32 | # Hang-on a bit and then start tailing the ONOS log output |
Charles Chan | f9335af | 2016-05-05 21:05:47 -0700 | [diff] [blame^] | 33 | RETRY_COUNT=5 |
| 34 | echo "Waiting for karaf.log" |
| 35 | until [ $RETRY_COUNT -le 0 ]; do |
| 36 | KARAF_LOG=$(find $ONOS_HOME -type f -name karaf.log) |
| 37 | if [ $KARAF_LOG ]; then |
| 38 | tail -f $KARAF_LOG |
| 39 | return |
| 40 | fi |
| 41 | RETRY_COUNT=$[$RETRY_COUNT-1] |
| 42 | sleep 1 |
| 43 | done |
| 44 | echo "Fail to open karaf.log" |