#! /bin/sh -
#
# connmand/rc.main
#
# Connman daemon (connmand).
#

# Redirects the standard error to the standard output
exec 2>&1

TARGET="$1"
SVNAME="${2:-connmand}"

start()
{
    echo "*** ${SVNAME}: Starting connmand ..."

    # Check first if 'dbus' is running before to run 'connmand'
    perpok dbus || exit $?

    if test ! -e /var/run/connman
    then
        mkdir -p /var/run/connman || exit $?
    fi
    exec /usr/sbin/connmand --nodaemon
}

reset()
{
    case $3 in
    exit)
        echo "*** ${SVNAME}: Exited status $4"
        ;;
    signal)
        echo "*** ${SVNAME}: Killed on signal $5"
        ;;
    *)
        echo "*** ${SVNAME}: Stopped (${3})"
        ;;
    esac
}

# Branch to target
eval ${TARGET} "$@"

