#!/bin/sh
#
# $PDP11: ethtimed-ubuntu,v 1.1 2014/06/09 10:42:09 form Exp $

NAME=ethtimed
DAEMON=/usr/sbin/ethtimed
DEFAULTS=/etc/default/ethtimed

[ -x $DAEMON ] || exit 0
[ -f $DEFAULTS ] && . $DEFAULTS

[ -f /lib/lsb/init-functions ] && . /lib/lsb/init-functions

set -e

case "$1" in
start)
	echo -n "Starting $NAME: "
	if status_of_proc $DAEMON $NAME >/dev/null; then
		log_begin_msg "Already running."
	else
		start-stop-daemon --start --quiet --exec $DAEMON -- $DAEMON_OPTS
		echo $NAME
	fi
	;;
stop)
	echo -n "Stopping $NAME: "
	start-stop-daemon --stop --oknodo --quiet --user root --exec $DAEMON
	echo "$NAME."
	;;
restart)
	echo -n "Restarting $NAME: "
	start-stop-daemon --stop --oknodo --quiet --user root --exec $DAEMON
	start-stop-daemon --start --quiet --exec $DAEMON -- $DAEMON_OPTS
	echo "$NAME."
	;;
status)
	start-stop-daemon --test --stop --quiet --user root --exec $DAEMON && \
		log_success_msg "$NAME is running." || \
		(log_failure_msg "$NAME daemon is NOT running" && exit 1)
	;;
*)
	echo "usage: /etc/init.d/$NAME {start|stop|restart|status}"
	;;
esac
