- fix #271741 - smartd-conf.py should allow customization of parameters

- fix #253753 - service starting by default, perhaps shouldn't
- update initscript (related #247058 - initscript review)
This commit is contained in:
Tomas Smetana 2007-09-04 11:59:22 +00:00
parent 7d9c446d5c
commit b021c51f2e
4 changed files with 140 additions and 76 deletions

View File

@ -73,12 +73,17 @@ def getfile(fname):
line = '' line = ''
return line return line
try:
execfile('/etc/sysconfig/smartmontools')
except IOError:
pass
for drive in drives: for drive in drives:
if getfile("%s/removable" % drive.sysfspath) == '0': if getfile("%s/removable" % drive.sysfspath) == '0':
driver = '' driver = ''
comment = '' comment = ''
if getfile("%s/device/vendor" % drive.sysfspath) == 'ATA': if getfile("%s/device/vendor" % drive.sysfspath) == 'ATA':
driver = '-d ata ' driver = '-d ata'
if float(getfile("/sys/module/libata/version")) < 1.20: if float(getfile("/sys/module/libata/version")) < 1.20:
comment = "# not yet supported in this kernel version\n# " comment = "# not yet supported in this kernel version\n# "
if not comment: if not comment:
@ -86,7 +91,10 @@ for drive in drives:
(driver, drive.device)) (driver, drive.device))
if not os.WIFEXITED(status) or os.WEXITSTATUS(status) != 0: if not os.WIFEXITED(status) or os.WEXITSTATUS(status) != 0:
comment = "# smartctl -i returns error for this drive\n# " comment = "# smartctl -i returns error for this drive\n# "
print "%s%s %s-H -m root" % (comment, drive.device, driver) try:
print "%s%s %s %s" % (comment, drive.device, driver, smartd_conf_opts)
except NameError:
print "%s%s %s -H -m root" % (comment, drive.device, driver)
print """ print """
# First two SCSI disks. This will monitor everything that smartd can # First two SCSI disks. This will monitor everything that smartd can

View File

@ -2,13 +2,23 @@
# smartmontools init file for smartd # smartmontools init file for smartd
# Copyright (C) 2002-4 Bruce Allen <smartmontools-support@lists.sourceforge.net> # Copyright (C) 2002-4 Bruce Allen <smartmontools-support@lists.sourceforge.net>
# $Id: smartd.initd,v 1.5 2007/06/21 13:26:38 tsmetana Exp $ # $Id: smartd.initd,v 1.6 2007/09/04 11:59:22 tsmetana Exp $
# For RedHat and cousins: # For RedHat and cousins:
# chkconfig: 2345 99 01 # chkconfig: - 99 01
# description: Self Monitoring and Reporting Technology (SMART) Daemon # description: Self Monitoring and Reporting Technology (SMART) Daemon
# processname: smartd # processname: smartd
### BEGIN INIT INFO
# Provides: smartd
# Required-Start: $local_fs $network
# Required-Stop: $local_fs $network
# Should-Start:
# 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
# This program is free software; you can redistribute it and/or modify it # 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 # 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 # Software Foundation; either version 2, or (at your option) any later
@ -33,8 +43,12 @@ SMARTD_BIN=/usr/sbin/smartd
[ -r /etc/sysconfig/smartmontools ] && . /etc/sysconfig/smartmontools [ -r /etc/sysconfig/smartmontools ] && . /etc/sysconfig/smartmontools
case "$1" in RETVAL=0
start | reload | restart) prog=smartd
pidfile=/var/lock/subsys/smartd
genconfig()
{
if [ -x /usr/sbin/smartd-conf.py ]; then if [ -x /usr/sbin/smartd-conf.py ]; then
GEN_CONF="*SMARTD*AUTOGENERATED*" GEN_CONF="*SMARTD*AUTOGENERATED*"
[ ! -f /etc/smartd.conf ] || read DUMMY GEN_CONF DUMMY </etc/smartd.conf \ [ ! -f /etc/smartd.conf ] || read DUMMY GEN_CONF DUMMY </etc/smartd.conf \
@ -42,50 +56,85 @@ case "$1" in
&& smartd-conf.py 2>/dev/null >/etc/smartd.conf.new-autogenerated \ && smartd-conf.py 2>/dev/null >/etc/smartd.conf.new-autogenerated \
&& mv -f /etc/smartd.conf.new-autogenerated /etc/smartd.conf && mv -f /etc/smartd.conf.new-autogenerated /etc/smartd.conf
fi fi
;; }
esac
RETVAL=0 start()
{
prog=smartd
case "$1" in
start)
echo -n $"Starting $prog: " echo -n $"Starting $prog: "
daemon $SMARTD_BIN $smartd_opts daemon $SMARTD_BIN $smartd_opts
touch /var/lock/subsys/smartd RETVAL=$?
echo echo
exit 0 [ $RETVAL = 0 ] && touch $pidfile
;; return $RETVAL
stop) }
stop()
{
echo -n $"Shutting down $prog: " echo -n $"Shutting down $prog: "
killproc $SMARTD_BIN killproc $SMARTD_BIN
rm -f /var/lock/subsys/smartd RETVAL=$?
echo echo
;; rm -f $pidfile
reload) return $RETVAL
}
reload()
{
echo -n $"Reloading $prog daemon configuration: " echo -n $"Reloading $prog daemon configuration: "
killproc $SMARTD_BIN -HUP killproc $SMARTD_BIN -HUP
RETVAL=$? RETVAL=$?
echo echo
;; return $RETVAL
report) }
report()
{
echo -n $"Checking SMART devices now: " echo -n $"Checking SMART devices now: "
killproc $SMARTD_BIN -USR1 killproc $SMARTD_BIN -USR1
RETVAL=$? RETVAL=$?
echo echo
return $RETVAL
}
case "$1" in
start)
genconfig
start
;;
stop)
stop
;;
reload)
genconfig
reload
;;
report)
report
;; ;;
restart) restart)
$0 stop stop
$0 start genconfig
start
;;
try-restart)
if [ -f $pidfile ]; then
stop
genconfig
start
fi
;;
force-reload)
genconfig
reload || (stop; start)
;; ;;
status) status)
status $prog status $prog
RETVAL=$?
;; ;;
*) *)
echo $"Usage: $0 {start|stop|reload|report|restart|status}" echo $"Usage: $0 {start|stop|reload|force-reload|report|restart|try-restart|status}"
RETVAL=1 RETVAL=3
esac esac
exit $RETVAL exit $RETVAL

View File

@ -1,7 +1,7 @@
Summary: Tools for monitoring SMART capable hard disks Summary: Tools for monitoring SMART capable hard disks
Name: smartmontools Name: smartmontools
Version: 5.37 Version: 5.37
Release: 5%{?dist} Release: 6%{?dist}
Epoch: 1 Epoch: 1
Group: System Environment/Base Group: System Environment/Base
License: GPLv2+ License: GPLv2+
@ -91,6 +91,11 @@ exit 0
%exclude %{_sbindir}/smartd-conf.py[co] %exclude %{_sbindir}/smartd-conf.py[co]
%changelog %changelog
* Tue Sep 04 2007 Tomas Smetana <tsmetana@redhat.com> - 1:5.37-6
- fix #271741 - smartd-conf.py should allow customization of parameters
- fix #253753 - service starting by default, perhaps shouldn't
- update initscript (related #247058 - initscript review)
* Mon Aug 20 2007 Tomas Smetana <tsmetana@redhat.com> - 1:5.37-5 * Mon Aug 20 2007 Tomas Smetana <tsmetana@redhat.com> - 1:5.37-5
- add support for 24 disks on 3ware RAID controllers (related #252055) - add support for 24 disks on 3ware RAID controllers (related #252055)
- fix #245442 - add %%{arm} to smartmontools's set of build archs - fix #245442 - add %%{arm} to smartmontools's set of build archs

View File

@ -1,2 +1,4 @@
# command line options for smartd # command line options for smartd
smartd_opts="-q never" smartd_opts="-q never"
# autogenerated config file options
# smartd_conf_opts="-H -m root"