#!/bin/bash
#
# thermd        Startup script for the Thermometer Daemon
#
# chkconfig: 2345 95 05
# description: thermd is the Thermometer Daemon
#
# config: /etc/sysconfig/thermd
#
# Graciously donated by Gerald Ruderman of Nova Scotia

# Source function library.
. /etc/rc.d/init.d/functions

if [ -f /etc/sysconfig/thermd ]; then
         . /etc/sysconfig/thermd
fi

lockfile=/var/lock/subsys/thermd
thermd=/usr/local/bin/thermd
RETVAL=0

start() {
         echo -n $"Starting thermd: "
                 $thermd -daemon >/dev/null
                 RETVAL=$?
                 [ $RETVAL = 0 ] || {
                         echo_failure
                                 echo
                         return $RETVAL
                 }
         echo_success
         echo
         touch ${lockfile}
         return 0
}

stop() {
         echo -n $"Shutdown thermd: "
         killproc $thermd
         RETVAL=$?
         echo
         [ $RETVAL = 0 ] && rm -f ${lockfile}
}

# See how we were called.
case "$1" in
   start)
         start
         ;;
   stop)
         stop
         ;;
   status)
         status $thermd
         ;;
   restart)
         stop
         start
         ;;
   condrestart)
         if /sbin/pidof $thermd >/dev/null ; then
                 stop
                 start
         fi
         ;;
   *)
         echo $"Usage: $prog {start|stop|restart|condrestart|status}"
         exit 1
esac

exit $RETVAL
