summaryrefslogtreecommitdiff
path: root/oma-ds
diff options
context:
space:
mode:
Diffstat (limited to 'oma-ds')
-rwxr-xr-xoma-ds73
1 files changed, 73 insertions, 0 deletions
diff --git a/oma-ds b/oma-ds
new file mode 100755
index 0000000..893ebdb
--- /dev/null
+++ b/oma-ds
@@ -0,0 +1,73 @@
+#!/bin/sh
+
+DESC="OMA DS agent daemon"
+NAME=oma-ds-agent
+DAEMON=/usr/bin/$NAME
+SCRIPTNAME=/etc/init.d/oma-ds
+
+[ -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/usr/data/oma-ds/.oma-ds-agent-enabled ]; then
+ do_start
+ prt_res $?
+ else
+ echo "don't exist oma-ds-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
+