File: //etc/rc1.d/K01uptimed
#! /bin/sh
### BEGIN INIT INFO
# Provides: uptimed
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Should-Start: uptimed-init
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Uptime daemon
### END INIT INFO
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/uptimed
NAME=uptimed
DESC="uptime daemon"
USER="daemon"
PIDDIR=/run/uptimed
PIDFILE=$PIDDIR/uptimed.pid
test -f $DAEMON || exit 0
. /lib/lsb/init-functions
# Source defaults file; edit that file to configure this script.
if [ -e /etc/default/uptimed ]; then
. /etc/default/uptimed
fi
case "$1" in
start)
if [ ! -d $PIDDIR ]; then
mkdir $PIDDIR
chown $USER:$USER $PIDDIR
fi
echo -n "Starting $DESC: "
start-stop-daemon --start --quiet --user daemon --chuid daemon --pidfile $PIDFILE --exec $DAEMON
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
start-stop-daemon --stop --quiet --user daemon --pidfile $PIDFILE --exec $DAEMON
echo "$NAME."
;;
restart|force-reload)
$0 stop
sleep 2
$0 start
;;
status)
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
exit 1
;;
esac
exit 0