diff options
Diffstat (limited to 'oma-dm')
-rwxr-xr-x | oma-dm | 73 |
1 files changed, 73 insertions, 0 deletions
@@ -0,0 +1,73 @@ +#!/bin/sh + +DESC="OMA DM agent daemon" +NAME=oma-dm-agent +DAEMON=/usr/bin/$NAME +SCRIPTNAME=/etc/init.d/oma-dm + +[ -x "$DAEMON" ] || exit 0 + +do_start() { + PID=`pidof $NAME` + [ -z "$PID" ] || return 1 + $DAEMON + RETVAL=$? + return "$RETVAL" +} + +do_stop() { + PID=`pidof $NAME` + if [ -n "$PID" ]; then + kill $PID + fi + return 0 +} + +prt_res() { + RETVAL=$1 + + case "$RETVAL" in + 0|1) + echo "... done." + RETVAL=0 + ;; + *) + echo "... failed!" + RETVAL=1 + ;; + esac + + return $RETVAL +} + +case "$1" in + start) + echo "Starting $DESC" "$NAME" + if [ -f /opt/data/fota/oma-dm/.oma-dm-agent-enabled ]; then + do_start + prt_res $? + else + echo "don't exist oma-dm-agent enabled file" + prt_res $? + fi + ;; + stop) + echo "Stopping $DESC" "$NAME" + do_stop + prt_res $? + ;; + restart) + echo "Stopping $DESC" "$NAME" + do_stop + prt_res $? + sleep 2 + echo "Starting $DESC" "$NAME" + do_start + prt_res $? + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|restart}" >&2 + exit 3 + ;; +esac + |