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