#!/bin/sh -e
#
# Startup script for the Uptime daemon
#
# description: Uptime daemon tracks your best 3 uptimes.
#

FLAGS="defaults 50"
DAEMON="/usr/bin/ud"
PIDFILE="/var/run/ud.pid"
OPTIONS="-s"

# Reads config file (will override defaults above)
[ -r /etc/default/ud ] && . /etc/default/ud

test -f $DAEMON || exit 0

case "$1" in
  start)
	echo -n "Starting uptime daemon: ud"
	start-stop-daemon --start --quiet --pidfile $PIDFILE \
                --exec $DAEMON -- $OPTIONS
	echo "."
	;;
  stop)
	echo -n "Stopping uptime daemon: ud"
	start-stop-daemon --stop --quiet --pidfile $PIDFILE \
                --exec $DAEMON
	echo "."
	;;
  restart|force-reload)
        echo "Restarting uptime daemon: ud"
	start-stop-daemon --stop --quiet --pidfile $PIDFILE \
                --exec $DAEMON
        sleep 1
	start-stop-daemon --start --quiet --pidfile $PIDFILE \
                --exec $DAEMON -- $OPTIONS
        ;;
  *)
	echo "Usage: ud {start|stop|restart|force-reload}"
	exit 1
        ;;
esac

exit 0

