#!/bin/sh
#
# connmand - Connection Manager
#
# chkconfig: - 23 84
# description: The ConnMan project provides a \
#              daemon for managing internet \
#              connections within embedded devices \
#              running the Linux operating system. \
#              The Connection Connection Manager \
#              is designed to be slim and to use \
#              as few resources as possible, so it \
#              can be easily integrated.
#
# processname: connmand
#
### BEGIN INIT INFO
# Provides: connmand $network
# Required-Start: messagebus
# Required-Stop: messagebus
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop Connection Manager
# Description: ConnMan provides a daemon for managing internet connections.
### END INIT INFO

# Source function library.
. /etc/rc.d/init.d/functions

exec="/usr/sbin/connmand"
prog=${exec##*/}

[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog

lockfile=/var/lock/subsys/$prog

start() {
    echo -n $"Starting $prog: "
    daemon $exec -n
    retval=$?
    [ $retval -eq 0 ] && touch $lockfile
    return $retval
}

stop() {
    echo -n $"Stopping $prog: "
    killproc $prog
    retval=$?
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
}

restart() {
    stop
    start
}

case "$1" in
    start|stop|restart)
        $1
        ;;
    force-reload)
        restart
        ;;
    status)
        status $prog
        ;;
    try-restart|condrestart)
        if status $prog >/dev/null ; then
            restart
        fi
	;;
    reload)
        status $prog >/dev/null || exit 7
        killproc $prog -HUP
        exit 3
        ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|try-restart|force-reload}"
        exit 2
esac
