Thomas Vachuska | 8189a74 | 2015-05-29 10:02:52 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # ----------------------------------------------------------------------------- |
| 3 | # Checks whether all and only the ONOS apps configured in ONOS_APPS are active. |
| 4 | # ----------------------------------------------------------------------------- |
| 5 | |
Thomas Vachuska | 4cfcc56 | 2015-06-03 09:51:02 -0700 | [diff] [blame] | 6 | [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 |
| 7 | . $ONOS_ROOT/tools/build/envDefaults |
| 8 | |
Jon Hall | fb6009d | 2017-02-15 16:01:17 -0800 | [diff] [blame] | 9 | aux=/tmp/stc/stc-$$.log |
Thomas Vachuska | 8189a74 | 2015-05-29 10:02:52 -0700 | [diff] [blame] | 10 | trap "rm -f $aux $aux.1 $aux.2 2>/dev/null" EXIT |
| 11 | |
Ray Milkey | 1ad9a63 | 2017-03-20 14:20:40 -0700 | [diff] [blame^] | 12 | echo $app | grep '.' |
| 13 | |
| 14 | if [ $? != 0 ]; then |
| 15 | appnameextra= |
| 16 | else |
| 17 | appname=org.onosproject. |
| 18 | fi |
| 19 | |
Thomas Vachuska | d2f2dfe | 2016-02-18 13:55:53 -0800 | [diff] [blame] | 20 | for attempt in {1..30}; do |
Thomas Vachuska | 5af2e4f | 2016-12-16 12:07:33 -0800 | [diff] [blame] | 21 | onos ${1:-$OCI} "onos:apps -s -a" > $aux |
Thomas Vachuska | 1c15287 | 2015-08-26 18:41:10 -0700 | [diff] [blame] | 22 | cat $aux |
Thomas Vachuska | 8189a74 | 2015-05-29 10:02:52 -0700 | [diff] [blame] | 23 | |
Thomas Vachuska | 1c15287 | 2015-08-26 18:41:10 -0700 | [diff] [blame] | 24 | # Normalize the installed apps |
Thomas Vachuska | 5af2e4f | 2016-12-16 12:07:33 -0800 | [diff] [blame] | 25 | cut -c7- $aux | cut -d\ -f1 | sort > $aux.1 |
Thomas Vachuska | 8189a74 | 2015-05-29 10:02:52 -0700 | [diff] [blame] | 26 | |
Thomas Vachuska | 1c15287 | 2015-08-26 18:41:10 -0700 | [diff] [blame] | 27 | # Normalize the expected apps |
| 28 | apps=${2:-$ONOS_APPS} |
| 29 | apps=${apps:-drivers,openflow} |
Ray Milkey | 1ad9a63 | 2017-03-20 14:20:40 -0700 | [diff] [blame^] | 30 | (for app in ${apps//,/ }; do echo ${appnameextra}${app}; done) | sort > $aux.2 |
Thomas Vachuska | 8189a74 | 2015-05-29 10:02:52 -0700 | [diff] [blame] | 31 | |
Thomas Vachuska | 1c15287 | 2015-08-26 18:41:10 -0700 | [diff] [blame] | 32 | # Check for differences |
| 33 | case ${3:-equals} in |
| 34 | equals) diff $aux.1 $aux.2;; |
Thomas Vachuska | 4b146a7 | 2015-11-18 12:04:50 -0800 | [diff] [blame] | 35 | includes) [ $(egrep -c -f $aux.2 $aux.1) -ge $(wc -l $aux.2 | sed "s|$aux.2||g") ];; |
Thomas Vachuska | 1c15287 | 2015-08-26 18:41:10 -0700 | [diff] [blame] | 36 | excludes) ! egrep -f $aux.2 $aux.1;; |
| 37 | esac |
| 38 | |
| 39 | [ $? -eq 0 ] && exit 0 || sleep 1 |
| 40 | done |
| 41 | |
| 42 | exit 1; |