#! /bin/sh
#
# Startup script for bme-dbus-proxy
#
# Copyright (C) 2004 Nokia.  All rights reserved.
#
# @author Mikko K. Ylinen <mikko.k.ylinen@nokia.com>

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/bme-dbus-proxy
NAME=bme-dbus-proxy
DSMETOOL=/usr/sbin/dsmetool
DESC="BME D-BUS proxy server"
INITFILE=/etc/init.d/$NAME

ENABLED=0

# abort if no executable exists
test -x $DAEMON || exit 0

#disable the usage of dsmetool if it does not exist
test -x $DSMETOOL || USE_DSMETOOL=no

[ -f /etc/default/bme-dbus-proxy ] && . /etc/default/bme-dbus-proxy

if [ $ENABLED = 0 ] ; then
	exit 0
fi

set -e

case "$1" in
start)
	printf "Starting $DESC: $NAME"
if [ x"$USE_DSMETOOL" = x"no" ]; then
	start-stop-daemon --start --quiet --pidfile /tmp/$NAME.pid \
		--exec $DAEMON
else
	$DSMETOOL -n -1 -t "$DAEMON -N"
fi
	printf ".\n"
	;;
stop)
	printf "Stopping $DESC: $NAME"
if [ x"$USE_DSMETOOL" = x"no" ]; then
	start-stop-daemon --stop --quiet --exec $DAEMON
else
	$DSMETOOL -n -1 -k "$DAEMON -N"
fi
	printf ".\n"
	;;

restart)
	# Not implemented
	;;

force-reload)
	# Not implemented
	;;

*)
	printf "Usage: $INITFILE {start|stop|restart|force-reload}\n" >&2
	exit 1
	;;
esac

exit 0
