diff options
author | Pav Lucistnik <pav@FreeBSD.org> | 2008-12-31 16:58:11 +0000 |
---|---|---|
committer | Pav Lucistnik <pav@FreeBSD.org> | 2008-12-31 16:58:11 +0000 |
commit | 76613624de8301b6d89468469a3cf02a95924123 (patch) | |
tree | 48fda7f20ada47a936218b5dd7260e924c63ccf5 | |
parent | 3c247af366f2c80ab8146c47645cda529fc9a1fc (diff) | |
download | ports-76613624de8301b6d89468469a3cf02a95924123.tar.gz ports-76613624de8301b6d89468469a3cf02a95924123.zip |
Notes
-rw-r--r-- | sysutils/smartmontools-devel/Makefile | 2 | ||||
-rw-r--r-- | sysutils/smartmontools-devel/files/smart.in | 88 | ||||
-rw-r--r-- | sysutils/smartmontools/Makefile | 2 | ||||
-rw-r--r-- | sysutils/smartmontools/files/smart.in | 88 |
4 files changed, 68 insertions, 112 deletions
diff --git a/sysutils/smartmontools-devel/Makefile b/sysutils/smartmontools-devel/Makefile index 706f59929982..fa100a00b5e5 100644 --- a/sysutils/smartmontools-devel/Makefile +++ b/sysutils/smartmontools-devel/Makefile @@ -7,7 +7,7 @@ PORTNAME= smartmontools PORTVERSION= 5.38 -PORTREVISION= 2 +PORTREVISION= 3 CATEGORIES= sysutils MASTER_SITES= ${MASTER_SITE_SOURCEFORGE} MASTER_SITE_SUBDIR= ${PORTNAME} diff --git a/sysutils/smartmontools-devel/files/smart.in b/sysutils/smartmontools-devel/files/smart.in index 407467bd5db3..166e4bf87187 100644 --- a/sysutils/smartmontools-devel/files/smart.in +++ b/sysutils/smartmontools-devel/files/smart.in @@ -4,43 +4,6 @@ # $FreeBSD$ # -# -# Stolen from comp.unix.shell FAQ Q11 -# (http://cfaj.freeshell.org/shell/cus-faq-2.html#11) -# -run_status() { - local j com k l a - j=1 - while eval "\${pipestatus_$j+:} false"; do - unset pipestatus_$j - j=$(($j+1)) - done - j=1 com= k=1 l= - for a; do - if [ "x$a" = 'x|' ]; then - com="$com { $l "'3>&- - echo "pipestatus_'$j'=$?" >&3 - } 4>&- |' - j=$(($j+1)) l= - else - l="$l \"\$$k\"" - fi - k=$(($k+1)) - done - com="$com $l"' 3>&- >&4 4>&- - echo "pipestatus_'$j'=$?"' - exec 4>&1 - eval "$(exec 3>&1; eval "$com")" - exec 4>&- - j=1 - while eval "\${pipestatus_$j+:} false"; do - eval "[ \$pipestatus_$j -eq 0 ]" || return 1 - j=$(($j+1)) - done - return 0 -} - - if [ -r /etc/defaults/periodic.conf ]; then . /etc/defaults/periodic.conf source_periodic_confs @@ -49,26 +12,41 @@ fi smartctl=%%PREFIX%%/sbin/smartctl : ${daily_status_smartctl_flags="-H"} : ${daily_status_smartctl_extra_status_flags="-a"} -rc=0 - # no default for ${daily_status_smart_devices} -if [ -n "${daily_status_smart_devices}" ]; then - for device in ${daily_status_smart_devices}; do - if [ -e ${device} ]; then - echo - echo "Checking health of ${device}:" - run_status ${smartctl} ${daily_status_smartctl_flags} ${device} \| \ - grep 'SMART overall-health self-assessment test result' - if [ $((pipestatus_1 & 3)) -ne 0 ]; then - rc=2 - ${smartctl} ${daily_status_smartctl_flags} ${device} - elif [ $pipestatus_1 -ne 0 ]; then - rc=3 +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_extra_status_flags} ${device} + ${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 - fi - done -fi + done + ;; +esac exit "$rc" diff --git a/sysutils/smartmontools/Makefile b/sysutils/smartmontools/Makefile index 706f59929982..fa100a00b5e5 100644 --- a/sysutils/smartmontools/Makefile +++ b/sysutils/smartmontools/Makefile @@ -7,7 +7,7 @@ PORTNAME= smartmontools PORTVERSION= 5.38 -PORTREVISION= 2 +PORTREVISION= 3 CATEGORIES= sysutils MASTER_SITES= ${MASTER_SITE_SOURCEFORGE} MASTER_SITE_SUBDIR= ${PORTNAME} diff --git a/sysutils/smartmontools/files/smart.in b/sysutils/smartmontools/files/smart.in index 407467bd5db3..166e4bf87187 100644 --- a/sysutils/smartmontools/files/smart.in +++ b/sysutils/smartmontools/files/smart.in @@ -4,43 +4,6 @@ # $FreeBSD$ # -# -# Stolen from comp.unix.shell FAQ Q11 -# (http://cfaj.freeshell.org/shell/cus-faq-2.html#11) -# -run_status() { - local j com k l a - j=1 - while eval "\${pipestatus_$j+:} false"; do - unset pipestatus_$j - j=$(($j+1)) - done - j=1 com= k=1 l= - for a; do - if [ "x$a" = 'x|' ]; then - com="$com { $l "'3>&- - echo "pipestatus_'$j'=$?" >&3 - } 4>&- |' - j=$(($j+1)) l= - else - l="$l \"\$$k\"" - fi - k=$(($k+1)) - done - com="$com $l"' 3>&- >&4 4>&- - echo "pipestatus_'$j'=$?"' - exec 4>&1 - eval "$(exec 3>&1; eval "$com")" - exec 4>&- - j=1 - while eval "\${pipestatus_$j+:} false"; do - eval "[ \$pipestatus_$j -eq 0 ]" || return 1 - j=$(($j+1)) - done - return 0 -} - - if [ -r /etc/defaults/periodic.conf ]; then . /etc/defaults/periodic.conf source_periodic_confs @@ -49,26 +12,41 @@ fi smartctl=%%PREFIX%%/sbin/smartctl : ${daily_status_smartctl_flags="-H"} : ${daily_status_smartctl_extra_status_flags="-a"} -rc=0 - # no default for ${daily_status_smart_devices} -if [ -n "${daily_status_smart_devices}" ]; then - for device in ${daily_status_smart_devices}; do - if [ -e ${device} ]; then - echo - echo "Checking health of ${device}:" - run_status ${smartctl} ${daily_status_smartctl_flags} ${device} \| \ - grep 'SMART overall-health self-assessment test result' - if [ $((pipestatus_1 & 3)) -ne 0 ]; then - rc=2 - ${smartctl} ${daily_status_smartctl_flags} ${device} - elif [ $pipestatus_1 -ne 0 ]; then - rc=3 +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_extra_status_flags} ${device} + ${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 - fi - done -fi + done + ;; +esac exit "$rc" |