2005-01-07 06:02:58 +00:00
|
|
|
#! /bin/sh
|
|
|
|
|
|
|
|
# smartmontools init file for smartd
|
|
|
|
# Copyright (C) 2002-4 Bruce Allen <smartmontools-support@lists.sourceforge.net>
|
2009-11-02 16:54:13 +00:00
|
|
|
# $Id: smartd.initd,v 1.11 2009/11/02 16:54:12 mhlavink Exp $
|
2005-01-07 06:02:58 +00:00
|
|
|
|
|
|
|
# For RedHat and cousins:
|
2007-09-04 11:59:22 +00:00
|
|
|
# chkconfig: - 99 01
|
2005-01-07 06:02:58 +00:00
|
|
|
# description: Self Monitoring and Reporting Technology (SMART) Daemon
|
|
|
|
# processname: smartd
|
|
|
|
|
2007-09-04 11:59:22 +00:00
|
|
|
### BEGIN INIT INFO
|
|
|
|
# Provides: smartd
|
|
|
|
# Required-Start: $local_fs $network
|
|
|
|
# Required-Stop: $local_fs $network
|
|
|
|
# Should-Start:
|
2009-11-02 16:54:13 +00:00
|
|
|
# Default-Start:
|
|
|
|
# Default-Stop: 0 1 2 3 4 5 6
|
2007-09-04 11:59:22 +00:00
|
|
|
# Short-Description: Self Monitoring and Reporting Technology (SMART) Daemon
|
|
|
|
# Description: The smartd daemon monitors SMART status of the local hard drives and
|
|
|
|
# provides advanced warnings of of disk degradation or failures.
|
|
|
|
### END INIT INFO
|
|
|
|
|
2005-01-07 06:02:58 +00:00
|
|
|
# This program is free software; you can redistribute it and/or modify it
|
|
|
|
# under the terms of the GNU General Public License as published by the Free
|
|
|
|
# Software Foundation; either version 2, or (at your option) any later
|
|
|
|
# version.
|
|
|
|
# You should have received a copy of the GNU General Public License (for
|
|
|
|
# example COPYING); if not, write to the Free Software Foundation, Inc., 675
|
|
|
|
# Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
# This code was originally developed as a Senior Thesis by Michael Cornwell
|
|
|
|
# at the Concurrent Systems Laboratory (now part of the Storage Systems
|
|
|
|
# Research Center), Jack Baskin School of Engineering, University of
|
|
|
|
# California, Santa Cruz. http://ssrc.soe.ucsc.edu/.
|
|
|
|
|
|
|
|
# Uncomment the line below to pass options to smartd on startup.
|
|
|
|
# Note that distribution specific configuration files like
|
|
|
|
# /etc/{default,sysconfig}/smartmontools might override these
|
|
|
|
#smartd_opts="--interval=1800"
|
|
|
|
|
|
|
|
SMARTD_BIN=/usr/sbin/smartd
|
|
|
|
|
|
|
|
# Source function library
|
|
|
|
. /etc/rc.d/init.d/functions
|
|
|
|
|
|
|
|
[ -r /etc/sysconfig/smartmontools ] && . /etc/sysconfig/smartmontools
|
2006-05-02 13:47:46 +00:00
|
|
|
|
2007-09-04 11:59:22 +00:00
|
|
|
RETVAL=0
|
|
|
|
prog=smartd
|
|
|
|
pidfile=/var/lock/subsys/smartd
|
2009-10-09 09:02:25 +00:00
|
|
|
config=/etc/smartd.conf
|
2005-01-07 06:02:58 +00:00
|
|
|
|
2007-09-04 11:59:22 +00:00
|
|
|
start()
|
|
|
|
{
|
2009-10-09 09:02:25 +00:00
|
|
|
[ $UID -eq 0 ] || exit 4
|
|
|
|
[ -x $SMARTD_BIN ] || exit 5
|
|
|
|
[ -f $config ] || exit 6
|
2007-09-04 11:59:22 +00:00
|
|
|
echo -n $"Starting $prog: "
|
|
|
|
daemon $SMARTD_BIN $smartd_opts
|
|
|
|
RETVAL=$?
|
|
|
|
echo
|
|
|
|
[ $RETVAL = 0 ] && touch $pidfile
|
|
|
|
return $RETVAL
|
|
|
|
}
|
|
|
|
|
|
|
|
stop()
|
|
|
|
{
|
2009-10-09 09:02:25 +00:00
|
|
|
[ $UID -eq 0 ] || exit 4
|
2007-09-04 11:59:22 +00:00
|
|
|
echo -n $"Shutting down $prog: "
|
|
|
|
killproc $SMARTD_BIN
|
|
|
|
RETVAL=$?
|
|
|
|
echo
|
|
|
|
rm -f $pidfile
|
|
|
|
return $RETVAL
|
|
|
|
}
|
|
|
|
|
|
|
|
reload()
|
|
|
|
{
|
|
|
|
echo -n $"Reloading $prog daemon configuration: "
|
|
|
|
killproc $SMARTD_BIN -HUP
|
|
|
|
RETVAL=$?
|
|
|
|
echo
|
|
|
|
return $RETVAL
|
|
|
|
}
|
|
|
|
|
|
|
|
report()
|
|
|
|
{
|
|
|
|
echo -n $"Checking SMART devices now: "
|
|
|
|
killproc $SMARTD_BIN -USR1
|
|
|
|
RETVAL=$?
|
|
|
|
echo
|
|
|
|
return $RETVAL
|
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
2005-01-07 06:02:58 +00:00
|
|
|
start)
|
2007-09-04 11:59:22 +00:00
|
|
|
start
|
|
|
|
;;
|
2005-01-07 06:02:58 +00:00
|
|
|
stop)
|
2007-09-04 11:59:22 +00:00
|
|
|
stop
|
|
|
|
;;
|
2005-01-07 06:02:58 +00:00
|
|
|
reload)
|
2007-09-04 11:59:22 +00:00
|
|
|
reload
|
|
|
|
;;
|
2005-01-07 06:02:58 +00:00
|
|
|
report)
|
2007-09-04 11:59:22 +00:00
|
|
|
report
|
|
|
|
;;
|
2005-01-07 06:02:58 +00:00
|
|
|
restart)
|
2007-09-04 11:59:22 +00:00
|
|
|
stop
|
|
|
|
start
|
|
|
|
;;
|
2009-10-09 09:02:25 +00:00
|
|
|
condrestart|try-restart)
|
2007-09-04 11:59:22 +00:00
|
|
|
if [ -f $pidfile ]; then
|
|
|
|
stop
|
|
|
|
start
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
force-reload)
|
|
|
|
reload || (stop; start)
|
|
|
|
;;
|
2005-01-07 06:02:58 +00:00
|
|
|
status)
|
2007-09-04 11:59:22 +00:00
|
|
|
status $prog
|
|
|
|
RETVAL=$?
|
|
|
|
;;
|
2005-01-07 06:02:58 +00:00
|
|
|
*)
|
2009-10-09 09:02:25 +00:00
|
|
|
echo $"Usage: $0 {start|stop|restart|status|condrestart|try-restart|reload|force-reload|report}"
|
|
|
|
RETVAL=2
|
2009-10-09 18:51:01 +00:00
|
|
|
[ "$1" = 'usage' ] && RETVAL=0
|
2007-09-04 11:59:22 +00:00
|
|
|
esac
|
2008-05-12 10:17:58 +00:00
|
|
|
|
2007-09-04 11:59:22 +00:00
|
|
|
exit $RETVAL
|
2005-01-07 06:02:58 +00:00
|
|
|
|