#!/bin/sh
# --------------------------------------------------------------
# Copyright (c) 2012 QUALCOMM Incorporated. All Rights Reserved.
# QUALCOMM Proprietary and Confidential.
# --------------------------------------------------------------
# mbim: init.d script to start QBI's MBIM control channel daemon

set -e

case "$1" in
  start)
        echo -n "Starting mbimd: "
        rm -f /var/run/qbi_session_active
        start-stop-daemon -S -b -a /usr/bin/mbimd
        start-stop-daemon -S -b -N 5 -o -x /usr/sbin/restart_mbimd
        echo "done"
        ;;
  stop)
        echo -n "Stopping mbimd: "
        start-stop-daemon -K -o -n restart_mbimd
        start-stop-daemon -K -n mbimd
        rm -f /var/run/qbi_session_active
        echo "done"
        ;;
  restart)
        $0 stop
        $0 start
        ;;
  *)
        echo "Usage: mbim {start | stop | restart}" >&2
        exit 1
        ;;
esac

exit 0
