aboutsummaryrefslogtreecommitdiff
path: root/sysutils/smartmontools
diff options
context:
space:
mode:
authorPav Lucistnik <pav@FreeBSD.org>2008-12-19 13:14:29 +0000
committerPav Lucistnik <pav@FreeBSD.org>2008-12-19 13:14:29 +0000
commitf1fdf32a0cc5c9692c61bc3f3d42b89bca60efa8 (patch)
treecff4321f07611be7be0be4155162376f04689e7e /sysutils/smartmontools
parent14695d5e4a07d7c953cfbed6a18e1f1af27905c4 (diff)
downloadports-f1fdf32a0cc5c9692c61bc3f3d42b89bca60efa8.tar.gz
ports-f1fdf32a0cc5c9692c61bc3f3d42b89bca60efa8.zip
Notes
Diffstat (limited to 'sysutils/smartmontools')
-rw-r--r--sysutils/smartmontools/Makefile5
-rw-r--r--sysutils/smartmontools/files/pkg-message.in7
-rw-r--r--sysutils/smartmontools/files/smart.in52
-rw-r--r--sysutils/smartmontools/pkg-plist3
4 files changed, 65 insertions, 2 deletions
diff --git a/sysutils/smartmontools/Makefile b/sysutils/smartmontools/Makefile
index fed31cf28b3f..0668320d1535 100644
--- a/sysutils/smartmontools/Makefile
+++ b/sysutils/smartmontools/Makefile
@@ -7,6 +7,7 @@
PORTNAME= smartmontools
PORTVERSION= 5.38
+PORTREVISION= 1
CATEGORIES= sysutils
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE}
MASTER_SITE_SUBDIR= ${PORTNAME}
@@ -18,7 +19,7 @@ USE_GMAKE= yes
GNU_CONFIGURE= yes
CONFIGURE_ARGS= --with-docdir=${DOCSDIR} --enable-sample
-SUB_FILES= pkg-message
+SUB_FILES= pkg-message smart
USE_RC_SUBR= smartd
MAN5= smartd.conf.5
@@ -28,6 +29,8 @@ post-patch:
@${REINPLACE_CMD} -e 's| install-initdDATA | |' ${WRKSRC}/Makefile.in
post-install:
+ ${MKDIR} ${PREFIX}/etc/periodic/daily
+ ${INSTALL_SCRIPT} ${WRKDIR}/smart ${PREFIX}/etc/periodic/daily/smart
@${CAT} ${PKGMESSAGE}
.include <bsd.port.mk>
diff --git a/sysutils/smartmontools/files/pkg-message.in b/sysutils/smartmontools/files/pkg-message.in
index ee9f662c7703..85cab06bfad7 100644
--- a/sysutils/smartmontools/files/pkg-message.in
+++ b/sysutils/smartmontools/files/pkg-message.in
@@ -5,7 +5,12 @@ To check the status of drives, use the following:
%%PREFIX%%/sbin/smartctl -a /dev/ad0 for first ATA drive
%%PREFIX%%/sbin/smartctl -a /dev/da0 for first SCSI drive
-To enable monitor of drives, you can use %%PREFIX%%/sbin/smartd
+To include drive health information in your daily status reports,
+add a line like the following to /etc/periodic.conf:
+ daily_status_smart_devices="/dev/ad0 /dev/da0"
+substituting the appropriate device names for your SMART-capable disks.
+
+To enable drive monitoring, you can use %%PREFIX%%/sbin/smartd.
A sample configuration file has been installed as
%%PREFIX%%/etc/smartd.conf.sample
Copy this file to %%PREFIX%%/etc/smartd.conf and edit appropriately
diff --git a/sysutils/smartmontools/files/smart.in b/sysutils/smartmontools/files/smart.in
new file mode 100644
index 000000000000..166e4bf87187
--- /dev/null
+++ b/sysutils/smartmontools/files/smart.in
@@ -0,0 +1,52 @@
+#!/bin/sh
+# This script is in the public domain. Original author: Garrett Wollman
+#
+# $FreeBSD$
+#
+
+if [ -r /etc/defaults/periodic.conf ]; then
+ . /etc/defaults/periodic.conf
+ source_periodic_confs
+fi
+
+smartctl=%%PREFIX%%/sbin/smartctl
+: ${daily_status_smartctl_flags="-H"}
+: ${daily_status_smartctl_extra_status_flags="-a"}
+# no default for ${daily_status_smart_devices}
+if [ -z "${daily_status_smart_devices}" ]; then
+ : ${daily_status_smart_enabled="NO"}
+else
+ : ${daily_status_smart_enabled="YES"}
+fi
+trim_junk="tail -n +4"
+
+tmpfile="$(mktemp /var/run/daily.XXXXXXXX)"
+trap "rm -f ${tmpfile}" 0 1 3 15
+
+rc=0
+case "${daily_status_smart_enable}" in
+ [Nn][Oo])
+ ;;
+ *)
+ for device in ${daily_status_smart_devices}; do
+ if [ -e ${device} ]; then
+ echo
+ echo "Checking health of ${device}:"
+ echo
+ ${smartctl} ${daily_status_smartctl_flags} ${device} > "${tmpfile}"
+ status=$?
+ if [ $((status & 3)) -ne 0 ]; then
+ rc=2
+ ${trim_junk} "${tmpfile}"
+ elif [ $status -ne 0 ]; then
+ rc=1
+ ${smartctl} ${daily_status_smartctl_extra_status_flags} ${device} | ${trim_junk}
+ else
+ ${trim_junk} "${tmpfile}"
+ fi
+ fi
+ done
+ ;;
+esac
+
+exit "$rc"
diff --git a/sysutils/smartmontools/pkg-plist b/sysutils/smartmontools/pkg-plist
index 4e77c480f242..7ca96cbea442 100644
--- a/sysutils/smartmontools/pkg-plist
+++ b/sysutils/smartmontools/pkg-plist
@@ -1,6 +1,7 @@
@comment $FreeBSD$
@unexec /bin/echo "===>" Stopping smartd ...
@unexec /usr/bin/killall smartd 2>/dev/null || true
+etc/periodic/daily/smart
etc/smartd.conf.sample
sbin/smartctl
sbin/smartd
@@ -20,3 +21,5 @@ sbin/smartd
%%DOCSDIR%%/smartd.conf
@dirrm %%DOCSDIR%%/examplescripts
@dirrm %%DOCSDIR%%
+@dirrmtry etc/periodic/daily
+@dirrmtry etc/periodic