#!/bin/sh

# chkconfig: 2345 40 40
# description: Self Monitoring and Reporting Technology (SMART) Daemon
# processname: smartd

### BEGIN INIT INFO
# Provides:  smartd
# Required-Start: $syslog
# X-UnitedLinux-Should-Start: $sendmail
# Should-Start: $sendmail
# Required-Stop: $syslog
# Default-Start: 2 3 5
# Default-Stop:
# Short-Description: Monitors disk and tape health via S.M.A.R.T.
# Description: Start S.M.A.R.T. disk and tape monitor.
### END INIT INFO

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

# Source configuration file
[ -r /etc/sysconfig/smartd ] && . /etc/sysconfig/smartd

RETVAL=0
prog=smartd

case "$1" in
    start)
	gprintf "Starting %s: " "$prog"
	daemon /usr/sbin/smartd $SMARTD_OPTIONS
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
	;;
    stop)
	gprintf "Shutting down %s: " "$prog"
	killproc $prog
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog

	;;
    reload)
	gprintf "Reloading %s daemon configuration: " "$prog"
	killproc $prog -HUP
	RETVAL=$?
	echo
	;;
    report)
	gprintf "Checking SMART devices now: "
	killproc $prog -USR1
	RETVAL=$?
	echo
	;;
    restart)
	$0 stop
	$0 start
	;;
    status)
	status $prog
	;;
    *)
	gprintf "Usage: %s {start|stop|reload|report|restart|status}\n" "$0"
	RETVAL=1
	;;
esac

exit $RETVAL
