From 41ac47d732eed8392d60d0f6773e5a279d49b999 Mon Sep 17 00:00:00 2001 From: Adrian Dudau Date: Thu, 12 Dec 2013 13:36:50 +0100 Subject: initial commit of Enea Linux 3.1 Migrated from the internal git server on the dora-enea branch Signed-off-by: Adrian Dudau --- .../org.yocto.remote.utils/resources/ust_tar.sh | 19 ++++ .../org.yocto.remote.utils/resources/yocto_tool.sh | 125 +++++++++++++++++++++ .../org.yocto.remote.utils/resources/yocto_ust.sh | 35 ++++++ 3 files changed, 179 insertions(+) create mode 100755 plugins/org.yocto.remote.utils/resources/ust_tar.sh create mode 100755 plugins/org.yocto.remote.utils/resources/yocto_tool.sh create mode 100755 plugins/org.yocto.remote.utils/resources/yocto_ust.sh (limited to 'plugins/org.yocto.remote.utils/resources') 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 @@ +#!/bin/sh + +#set PATH to include sbin dirs +export PATH="$PATH:/usr/local/sbin:/usr/sbin:/sbin" + +if [ ! -d "$@" ] || [ -z "$@" ]; then + exit 1 +fi + +DATESTRING="$(date +%Y%m%d%H%M%S%N)" +BASENAME=`basename $@` +DATAFILE=/tmp/${BASENAME}-${DATESTRING}.tar +cd $@ +cd .. + +tar -cf ${DATAFILE} ${BASENAME} &> /dev/null || exit $? + +echo -e "ustfile:$DATAFILE\n" + 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 @@ +#!/bin/sh + +help () +{ + echo "Usage $0 command [options] application [application argument]" + echo "command:" + echo " start - start an application" + echo " stop - stop an application" + echo " restart - restart an application" + echo "" + echo "options: -d | -l " + echo " -d - start an application as a singleton daemon" + echo " -l - redirect the standard output/error in the the file" + echo " note: Option -d and -l are exclusive to each other" + exit 1 +} + +killproc() { # kill the named process(es) + pid=`/bin/pidof $1` + [ "x$pid" != "x" ] && kill $pid +} + +start () +{ + pid=`/bin/pidof $APP` + [ "x$pid" != "x" ] && return 0 + + if [ "x$DAEMON" != "x" ]; then + if [ "x$APPARG" != "x" ]; then + start-stop-daemon -S -b --oknodo -x $APP -- $APPARG + else + start-stop-daemon -S -b --oknodo -x $APP + fi + + #wait for sometime for the backend app to bring up & daemonzie + ret=$? + if [ $ret -eq 0 ]; then + sleep 1 + fi + return $ret + elif [ "x$LOGFILE" != "x" ]; then + $APP $APPARG $>${LOGFILE} + else + $APP $APPARG + fi +} + +stop () +{ + if [ "x$DAEMON" != "x" ]; then + start-stop-daemon -K -x $APP + else + count=0 + while [ -n "`/bin/pidof $APP`" -a $count -lt 10 ] ; do + killproc $APP >& /dev/null + sleep 1 + RETVAL=$? + if [ $RETVAL != 0 -o -n "`/bin/pidof $APP`" ] ; then + sleep 3 + fi + count=`expr $count + 1` + done + fi +} + +restart () +{ + stop + sleep 1 + start +} + +#set PATH to include sbin dirs +export PATH="$PATH:/usr/local/sbin:/usr/sbin:/sbin" + +#get command +case $1 in +start) CMD=$1; shift 1 + ;; +stop) CMD=$1; shift 1 + ;; +*) help + ;; +esac + +#get options +while [ $# -gt 0 ]; do + case $1 in + -d) DAEMON=true; shift 1 + ;; + -l) LOGFILE=$2; shift 2 + ;; + *) break + ;; + esac +done + +#get application +APP=$1 +shift 1 + +#get app argument +APPARG="$@" + +#validate options +if [ "x$DAEMON" != "x" -a "x$LOGFILE" != "x" ]; then + help +fi +if [ "x$DAEMON" != "x" ]; then + APP=`which $APP` +fi +if [ "x$APP" == "x" ]; then + help +fi + +#run script +case $CMD in +start) start + ;; +stop) stop + ;; +restart) + restart + ;; +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 @@ +#!/bin/sh + +#set PATH to include sbin dirs +export PATH="$PATH:/usr/local/sbin:/usr/sbin:/sbin" + +DATESTRING="$(date +%Y%m%d%H%M%S%N)" +TEMPFILE="/tmp/yocto-ust-tmp-$DATESTRING" + +rm -f ${TEMPFILE} +usttrace $@ &> ${TEMPFILE} +ret=$? + +if [ $ret -ne 0 ]; then + cat $TEMPFILE + rm -f $TEMPFILE + exit $ret +fi + +#search for output dir +USTDIR=`cat ${TEMPFILE} | awk '/^Trace was output in:/ { print $5}'` +rm -f ${TEMPFILE} + +if [ -z "$USTDIR" ]; then + exit 1 +fi + +BASENAME=`basename $USTDIR` +DATAFILE=/tmp/${BASENAME}.tar +cd $USTDIR +cd .. + +tar -cf ${DATAFILE} ${BASENAME} &> /dev/null || exit $? + +echo -e "ustfile:$DATAFILE\n" + -- cgit v1.2.3-54-g00ecf