Ray Milkey | 97dfd1e | 2016-06-20 17:04:19 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # ----------------------------------------------------------------------------- |
| 3 | # Finds an app in the system. |
| 4 | # ----------------------------------------------------------------------------- |
| 5 | |
| 6 | [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 |
| 7 | . $ONOS_ROOT/tools/build/envDefaults |
| 8 | |
| 9 | aux=/tmp/stc-$$.log |
| 10 | trap "rm -f $aux 2>/dev/null" EXIT |
| 11 | |
| 12 | echo onos-find-app: $* |
| 13 | |
| 14 | target=${1:-$OCI} |
| 15 | app=$2 |
| 16 | id=$3 |
| 17 | set -x |
| 18 | |
| 19 | onos $target "onos:apps" | tee $aux |
| 20 | appString=`cat $aux | grep "name=$app,"` |
| 21 | |
| 22 | if [ $? -ne 0 ] |
| 23 | then |
| 24 | exit 1; |
| 25 | fi |
| 26 | |
| 27 | state='inactive' |
| 28 | if [ appString != "" ] |
| 29 | then |
| 30 | if [[ ${appString:0:1} == '*' ]] |
| 31 | then |
| 32 | state='active' |
| 33 | fi |
| 34 | for token in '$appString' |
| 35 | do |
| 36 | if [[ $token =~ "id=" ]] |
| 37 | then |
| 38 | echo "@stc ${id}Id=${token}" |
| 39 | fi |
| 40 | done |
| 41 | echo "@stc ${id}State=${state}" |
| 42 | exit 0 |
| 43 | fi |
| 44 | |
| 45 | |
| 46 | cat $aux |
| 47 | exit 1 |
| 48 | |