blob: 8057adf2bb4ffef0c881fe6858635fea72ea1502 [file] [log] [blame]
Thomas Vachuska8189a742015-05-29 10:02:52 -07001#!/bin/bash
2# -----------------------------------------------------------------------------
3# Checks whether all and only the ONOS apps configured in ONOS_APPS are active.
4# -----------------------------------------------------------------------------
5
Thomas Vachuska4cfcc562015-06-03 09:51:02 -07006[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
7. $ONOS_ROOT/tools/build/envDefaults
8
Jon Hallfb6009d2017-02-15 16:01:17 -08009aux=/tmp/stc/stc-$$.log
Thomas Vachuska8189a742015-05-29 10:02:52 -070010trap "rm -f $aux $aux.1 $aux.2 2>/dev/null" EXIT
11
Ray Milkey1ad9a632017-03-20 14:20:40 -070012echo $app | grep '.'
13
14if [ $? != 0 ]; then
15 appnameextra=
16else
17 appname=org.onosproject.
18fi
19
Thomas Vachuskad2f2dfe2016-02-18 13:55:53 -080020for attempt in {1..30}; do
Thomas Vachuska5af2e4f2016-12-16 12:07:33 -080021 onos ${1:-$OCI} "onos:apps -s -a" > $aux
Thomas Vachuska1c152872015-08-26 18:41:10 -070022 cat $aux
Thomas Vachuska8189a742015-05-29 10:02:52 -070023
Thomas Vachuska1c152872015-08-26 18:41:10 -070024 # Normalize the installed apps
Thomas Vachuska5af2e4f2016-12-16 12:07:33 -080025 cut -c7- $aux | cut -d\ -f1 | sort > $aux.1
Thomas Vachuska8189a742015-05-29 10:02:52 -070026
Thomas Vachuska1c152872015-08-26 18:41:10 -070027 # Normalize the expected apps
28 apps=${2:-$ONOS_APPS}
Sean Condonbf7ff4f2019-03-17 16:18:42 +000029 apps=${apps:-gui,drivers,openflow}
Ray Milkey1ad9a632017-03-20 14:20:40 -070030 (for app in ${apps//,/ }; do echo ${appnameextra}${app}; done) | sort > $aux.2
Thomas Vachuska8189a742015-05-29 10:02:52 -070031
Thomas Vachuska1c152872015-08-26 18:41:10 -070032 # Check for differences
33 case ${3:-equals} in
34 equals) diff $aux.1 $aux.2;;
Thomas Vachuska4b146a72015-11-18 12:04:50 -080035 includes) [ $(egrep -c -f $aux.2 $aux.1) -ge $(wc -l $aux.2 | sed "s|$aux.2||g") ];;
Thomas Vachuska1c152872015-08-26 18:41:10 -070036 excludes) ! egrep -f $aux.2 $aux.1;;
37 esac
38
39 [ $? -eq 0 ] && exit 0 || sleep 1
40done
41
42exit 1;