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