summaryrefslogtreecommitdiff
path: root/oma-dm
diff options
context:
space:
mode:
Diffstat (limited to 'oma-dm')
-rwxr-xr-xoma-dm73
1 files changed, 73 insertions, 0 deletions
diff --git a/oma-dm b/oma-dm
new file mode 100755
index 0000000..da98b8f
--- /dev/null
+++ b/oma-dm
@@ -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
+