diff --git a/smartd-conf.py b/smartd-conf.py index 1691f7e..28eb497 100755 --- a/smartd-conf.py +++ b/smartd-conf.py @@ -1,9 +1,36 @@ #!/usr/bin/python -# Copyright 2004 Red Hat, Inc. Distributed under the GPL. -# Author: Will Woods -import kudzu +# Copyright 2004-2006 Red Hat, Inc. Distributed under the GPL. +# Authors: Will Woods , Tomas Mraz + import os -drives=kudzu.probe(kudzu.CLASS_HD,kudzu.BUS_IDE|kudzu.BUS_SCSI,kudzu.PROBE_ALL) +import dbus + +class Drive: + def __init__(self, bus, device, sysfspath): + self.bus = bus + self.device = device + self.sysfspath = sysfspath + +def listDrivesbyHAL(): + drives = [] + bus = dbus.SystemBus() + halm_obj = bus.get_object('org.freedesktop.Hal', '/org/freedesktop/Hal/Manager') + halm = dbus.Interface(halm_obj, 'org.freedesktop.Hal.Manager') + + storage_udi_list = halm.FindDeviceByCapability('storage') + for udi in storage_udi_list: + drive_obj = bus.get_object('org.freedesktop.Hal', udi) + drive = dbus.Interface(drive_obj, 'org.freedesktop.Hal.Device') + storage_bus = drive.GetProperty('storage.bus') + drive_type = drive.GetProperty('storage.drive_type') + if (storage_bus == 'ide' or storage_bus == 'scsi') and drive_type == 'disk': + device_file = drive.GetProperty('block.device') + sysfs_path = drive.GetProperty('linux.sysfs_path') + drv = Drive(storage_bus, device_file, sysfs_path) + drives += [drv] + return drives + +drives = listDrivesbyHAL() print """# *SMARTD*AUTOGENERATED* /etc/smartd.conf # Remove the line above if you have edited the file and you do not want @@ -47,19 +74,19 @@ def getfile(fname): return line for drive in drives: - if getfile("/sys/block/%s/removable" % drive.device) == '0': + if getfile("%s/removable" % drive.sysfspath) == '0': driver = '' comment = '' - if getfile("/sys/block/%s/device/vendor" % drive.device) == 'ATA': + if getfile("%s/device/vendor" % drive.sysfspath) == 'ATA': driver = '-d ata ' if float(getfile("/sys/module/libata/version")) < 1.20: comment = "# not yet supported in this kernel version\n# " if not comment: - status = os.system("/usr/sbin/smartctl -i %s/dev/%s 2>&1 >/dev/null" % + status = os.system("/usr/sbin/smartctl -i %s%s 2>&1 >/dev/null" % (driver, drive.device)) if not os.WIFEXITED(status) or os.WEXITSTATUS(status) != 0: comment = "# smartctl -i returns error for this drive\n# " - print "%s/dev/%s %s-H -m root" % (comment, drive.device, driver) + print "%s%s %s-H -m root" % (comment, drive.device, driver) print """ # First two SCSI disks. This will monitor everything that smartd can diff --git a/smartd.initd b/smartd.initd index 1221d40..054d258 100644 --- a/smartd.initd +++ b/smartd.initd @@ -2,10 +2,10 @@ # smartmontools init file for smartd # Copyright (C) 2002-4 Bruce Allen -# $Id: smartd.initd,v 1.2 2006/05/02 13:47:46 tmraz Exp $ +# $Id: smartd.initd,v 1.3 2006/06/27 15:40:29 tmraz Exp $ # For RedHat and cousins: -# chkconfig: 2345 40 40 +# chkconfig: 2345 99 01 # description: Self Monitoring and Reporting Technology (SMART) Daemon # processname: smartd @@ -37,7 +37,9 @@ case "$1" in start | reload | restart) GEN_CONF="*SMARTD*AUTOGENERATED*" [ ! -f /etc/smartd.conf ] || read DUMMY GEN_CONF DUMMY /etc/smartd.conf +&& [ $GEN_CONF == "*SMARTD*AUTOGENERATED*" ] \ +&& smartd-conf.py 2>/dev/null >/etc/smartd.conf.new-autogenerated \ +&& mv -f /etc/smartd.conf.new-autogenerated /etc/smartd.conf ;; esac diff --git a/smartmontools.spec b/smartmontools.spec index a72cfba..fc0a68c 100644 --- a/smartmontools.spec +++ b/smartmontools.spec @@ -1,7 +1,7 @@ Summary: Tools for monitoring SMART capable hard disks Name: smartmontools Version: 5.36 -Release: 1 +Release: 2 Epoch: 1 Group: System Environment/Base License: GPL @@ -15,7 +15,7 @@ Patch1: http://people.fedora.de/rsc/smartmontools-5.36-cciss.patch BuildRoot: %{_tmppath}/%{name}-%{version}-root PreReq: /sbin/chkconfig /sbin/service -Requires: fileutils kudzu +Requires: fileutils hal >= 0.5.2 dbus-python >= 0.33 BuildRequires: readline-devel ncurses-devel /usr/bin/aclocal /usr/bin/automake /usr/bin/autoconf util-linux groff gettext Obsoletes: kernel-utils ExclusiveArch: i386 x86_64 ia64 ppc ppc64 @@ -76,6 +76,11 @@ exit 0 %changelog +* Tue Jun 27 2006 Tomas Mraz - 1:5.36-2 +- kudzu is deprecated, replace it with HAL (#195752) +- moved later in the boot process so haldaemon is already running + when drives are being detected + * Thu May 11 2006 Tomas Mraz - 1:5.36-1 - new upstream version - included patch with support for cciss controllers (#191288)