#!/bin/sh
#
# hddtemp       This shell script takes care of starting and stopping hddtemp.
#
# chkconfig:    - 90 10
# description:  hddtemp provides information about hard drives' temperature
# processname:  hddtemp
# config:       /etc/sysconfig/hddtemp

. /etc/sysconfig/hddtemp

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

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0

# Backwards compatibility.
[ -z "$HDDTEMP_OPTIONS" -a -n "$HDDTEMPARGS" ] && \
  HDDTEMP_OPTIONS="$HDDTEMPARGS"
HDDTEMP_OPTIONS="$HDDTEMP_OPTIONS $HDDTEMP_DAEMON_OPTIONS"

exec="/usr/sbin/hddtemp"
prog=$(basename $exec)
lockfile=/var/lock/subsys/$prog

start() {
    echo -n $"Starting hard disk temperature monitor daemon ($prog): "
    daemon $exec -d $HDDTEMP_OPTIONS
    retval=$?
    echo
    [ $retval -eq 0 ] && touch $lockfile
    return $retval
}

stop() {
    echo -n $"Stopping hard disk temperature monitor daemon ($prog): "
    killproc $prog
    retval=$?
    echo
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
}

restart() {
    stop
    start
}

# See how we were called.
case "$1" in
    start|stop|restart)
        $1
        ;;
    reload|force-reload)
        restart
        ;;
    status)
        status $prog
        ;;
    try-restart|condrestart)
        [ ! -f $lockfile ] || restart
        ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|try-restart|reload|force-reload}"
        exit 2
esac
