diff options
author | Adrian Dudau <adrian.dudau@enea.com> | 2013-12-12 13:36:50 +0100 |
---|---|---|
committer | Adrian Dudau <adrian.dudau@enea.com> | 2013-12-12 15:25:03 +0100 |
commit | 41ac47d732eed8392d60d0f6773e5a279d49b999 (patch) | |
tree | cf19d099db9cfdb8d73aa21c31e7aa1cc86ff860 /plugins/org.yocto.remote.utils/resources | |
download | eclipse-poky-juno-master.tar.gz |
Migrated from the internal git server on the dora-enea branch
Signed-off-by: Adrian Dudau <adrian.dudau@enea.com>
Diffstat (limited to 'plugins/org.yocto.remote.utils/resources')
-rwxr-xr-x | plugins/org.yocto.remote.utils/resources/ust_tar.sh | 19 | ||||
-rwxr-xr-x | plugins/org.yocto.remote.utils/resources/yocto_tool.sh | 125 | ||||
-rwxr-xr-x | plugins/org.yocto.remote.utils/resources/yocto_ust.sh | 35 |
3 files changed, 179 insertions, 0 deletions
diff --git a/plugins/org.yocto.remote.utils/resources/ust_tar.sh b/plugins/org.yocto.remote.utils/resources/ust_tar.sh new file mode 100755 index 0000000..20a8039 --- /dev/null +++ b/plugins/org.yocto.remote.utils/resources/ust_tar.sh | |||
@@ -0,0 +1,19 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | #set PATH to include sbin dirs | ||
4 | export PATH="$PATH:/usr/local/sbin:/usr/sbin:/sbin" | ||
5 | |||
6 | if [ ! -d "$@" ] || [ -z "$@" ]; then | ||
7 | exit 1 | ||
8 | fi | ||
9 | |||
10 | DATESTRING="$(date +%Y%m%d%H%M%S%N)" | ||
11 | BASENAME=`basename $@` | ||
12 | DATAFILE=/tmp/${BASENAME}-${DATESTRING}.tar | ||
13 | cd $@ | ||
14 | cd .. | ||
15 | |||
16 | tar -cf ${DATAFILE} ${BASENAME} &> /dev/null || exit $? | ||
17 | |||
18 | echo -e "ustfile:$DATAFILE\n" | ||
19 | |||
diff --git a/plugins/org.yocto.remote.utils/resources/yocto_tool.sh b/plugins/org.yocto.remote.utils/resources/yocto_tool.sh new file mode 100755 index 0000000..099e481 --- /dev/null +++ b/plugins/org.yocto.remote.utils/resources/yocto_tool.sh | |||
@@ -0,0 +1,125 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | help () | ||
4 | { | ||
5 | echo "Usage $0 command [options] application [application argument]" | ||
6 | echo "command:" | ||
7 | echo " start - start an application" | ||
8 | echo " stop - stop an application" | ||
9 | echo " restart - restart an application" | ||
10 | echo "" | ||
11 | echo "options: -d | -l <log file>" | ||
12 | echo " -d - start an application as a singleton daemon" | ||
13 | echo " -l <log file name> - redirect the standard output/error in the the file" | ||
14 | echo " note: Option -d and -l are exclusive to each other" | ||
15 | exit 1 | ||
16 | } | ||
17 | |||
18 | killproc() { # kill the named process(es) | ||
19 | pid=`/bin/pidof $1` | ||
20 | [ "x$pid" != "x" ] && kill $pid | ||
21 | } | ||
22 | |||
23 | start () | ||
24 | { | ||
25 | pid=`/bin/pidof $APP` | ||
26 | [ "x$pid" != "x" ] && return 0 | ||
27 | |||
28 | if [ "x$DAEMON" != "x" ]; then | ||
29 | if [ "x$APPARG" != "x" ]; then | ||
30 | start-stop-daemon -S -b --oknodo -x $APP -- $APPARG | ||
31 | else | ||
32 | start-stop-daemon -S -b --oknodo -x $APP | ||
33 | fi | ||
34 | |||
35 | #wait for sometime for the backend app to bring up & daemonzie | ||
36 | ret=$? | ||
37 | if [ $ret -eq 0 ]; then | ||
38 | sleep 1 | ||
39 | fi | ||
40 | return $ret | ||
41 | elif [ "x$LOGFILE" != "x" ]; then | ||
42 | $APP $APPARG $>${LOGFILE} | ||
43 | else | ||
44 | $APP $APPARG | ||
45 | fi | ||
46 | } | ||
47 | |||
48 | stop () | ||
49 | { | ||
50 | if [ "x$DAEMON" != "x" ]; then | ||
51 | start-stop-daemon -K -x $APP | ||
52 | else | ||
53 | count=0 | ||
54 | while [ -n "`/bin/pidof $APP`" -a $count -lt 10 ] ; do | ||
55 | killproc $APP >& /dev/null | ||
56 | sleep 1 | ||
57 | RETVAL=$? | ||
58 | if [ $RETVAL != 0 -o -n "`/bin/pidof $APP`" ] ; then | ||
59 | sleep 3 | ||
60 | fi | ||
61 | count=`expr $count + 1` | ||
62 | done | ||
63 | fi | ||
64 | } | ||
65 | |||
66 | restart () | ||
67 | { | ||
68 | stop | ||
69 | sleep 1 | ||
70 | start | ||
71 | } | ||
72 | |||
73 | #set PATH to include sbin dirs | ||
74 | export PATH="$PATH:/usr/local/sbin:/usr/sbin:/sbin" | ||
75 | |||
76 | #get command | ||
77 | case $1 in | ||
78 | start) CMD=$1; shift 1 | ||
79 | ;; | ||
80 | stop) CMD=$1; shift 1 | ||
81 | ;; | ||
82 | *) help | ||
83 | ;; | ||
84 | esac | ||
85 | |||
86 | #get options | ||
87 | while [ $# -gt 0 ]; do | ||
88 | case $1 in | ||
89 | -d) DAEMON=true; shift 1 | ||
90 | ;; | ||
91 | -l) LOGFILE=$2; shift 2 | ||
92 | ;; | ||
93 | *) break | ||
94 | ;; | ||
95 | esac | ||
96 | done | ||
97 | |||
98 | #get application | ||
99 | APP=$1 | ||
100 | shift 1 | ||
101 | |||
102 | #get app argument | ||
103 | APPARG="$@" | ||
104 | |||
105 | #validate options | ||
106 | if [ "x$DAEMON" != "x" -a "x$LOGFILE" != "x" ]; then | ||
107 | help | ||
108 | fi | ||
109 | if [ "x$DAEMON" != "x" ]; then | ||
110 | APP=`which $APP` | ||
111 | fi | ||
112 | if [ "x$APP" == "x" ]; then | ||
113 | help | ||
114 | fi | ||
115 | |||
116 | #run script | ||
117 | case $CMD in | ||
118 | start) start | ||
119 | ;; | ||
120 | stop) stop | ||
121 | ;; | ||
122 | restart) | ||
123 | restart | ||
124 | ;; | ||
125 | esac | ||
diff --git a/plugins/org.yocto.remote.utils/resources/yocto_ust.sh b/plugins/org.yocto.remote.utils/resources/yocto_ust.sh new file mode 100755 index 0000000..a1637db --- /dev/null +++ b/plugins/org.yocto.remote.utils/resources/yocto_ust.sh | |||
@@ -0,0 +1,35 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | #set PATH to include sbin dirs | ||
4 | export PATH="$PATH:/usr/local/sbin:/usr/sbin:/sbin" | ||
5 | |||
6 | DATESTRING="$(date +%Y%m%d%H%M%S%N)" | ||
7 | TEMPFILE="/tmp/yocto-ust-tmp-$DATESTRING" | ||
8 | |||
9 | rm -f ${TEMPFILE} | ||
10 | usttrace $@ &> ${TEMPFILE} | ||
11 | ret=$? | ||
12 | |||
13 | if [ $ret -ne 0 ]; then | ||
14 | cat $TEMPFILE | ||
15 | rm -f $TEMPFILE | ||
16 | exit $ret | ||
17 | fi | ||
18 | |||
19 | #search for output dir | ||
20 | USTDIR=`cat ${TEMPFILE} | awk '/^Trace was output in:/ { print $5}'` | ||
21 | rm -f ${TEMPFILE} | ||
22 | |||
23 | if [ -z "$USTDIR" ]; then | ||
24 | exit 1 | ||
25 | fi | ||
26 | |||
27 | BASENAME=`basename $USTDIR` | ||
28 | DATAFILE=/tmp/${BASENAME}.tar | ||
29 | cd $USTDIR | ||
30 | cd .. | ||
31 | |||
32 | tar -cf ${DATAFILE} ${BASENAME} &> /dev/null || exit $? | ||
33 | |||
34 | echo -e "ustfile:$DATAFILE\n" | ||
35 | |||