From: <abe...@us...> - 2014-10-28 15:49:01
|
Revision: 6786 http://sourceforge.net/p/astlinux/code/6786 Author: abelbeck Date: 2014-10-28 15:48:57 +0000 (Tue, 28 Oct 2014) Log Message: ----------- smartmontools, add smart-status script, Usage: smart-status attr[ibutes]|ATTR[IBUTES]|health|info Modified Paths: -------------- branches/1.0/package/smartmontools/smartmontools.mk Added Paths: ----------- branches/1.0/package/smartmontools/smart-status.sh Added: branches/1.0/package/smartmontools/smart-status.sh =================================================================== --- branches/1.0/package/smartmontools/smart-status.sh (rev 0) +++ branches/1.0/package/smartmontools/smart-status.sh 2014-10-28 15:48:57 UTC (rev 6786) @@ -0,0 +1,60 @@ +#!/bin/sh + +## +## Wrapper for smartctl +## + +DRIVE="$(/sbin/findfs LABEL=RUNNIX)" +DRIVE="${DRIVE%[1-9]}" + +if [ -z "$DRIVE" ]; then + echo "smart-status: Drive not Found" + exit 1 +fi + +clean_output() +{ + sed -n '/^=== START/,$ p' | sed -e 's/^=== START.*$//' -e '/^$/d' +} + +do_smartctl() { + local output rtn; + + output="$(smartctl "$@")" + rtn=$? + + if [ $rtn -eq 0 ]; then + echo "$output" | clean_output + else + echo "Error retrieving S.M.A.R.T information." + echo "$output" | grep '^SMART support is:' + fi + + return $rtn +} + +case $1 in + +attr*) + do_smartctl -A -f brief "$DRIVE" + ;; + +ATTR*) + do_smartctl -A -f old "$DRIVE" + ;; + +health) + do_smartctl -H "$DRIVE" + ;; + +info) + do_smartctl -i "$DRIVE" + ;; + +*) + echo "Usage: smart-status attr[ibutes]|ATTR[IBUTES]|health|info" + exit 1 + ;; + +esac + Modified: branches/1.0/package/smartmontools/smartmontools.mk =================================================================== --- branches/1.0/package/smartmontools/smartmontools.mk 2014-10-27 23:26:28 UTC (rev 6785) +++ branches/1.0/package/smartmontools/smartmontools.mk 2014-10-28 15:48:57 UTC (rev 6786) @@ -9,11 +9,13 @@ define SMARTMONTOOLS_INSTALL_TARGET_CMDS $(INSTALL) -m 0755 -D $(@D)/smartctl $(TARGET_DIR)/usr/sbin/smartctl + $(INSTALL) -m 0755 -D package/smartmontools/smart-status.sh $(TARGET_DIR)/usr/sbin/smart-status ln -sf /tmp/etc/smart_drivedb.h $(TARGET_DIR)/etc/smart_drivedb.h endef define SMARTMONTOOLS_UNINSTALL_TARGET_CMDS rm -f $(TARGET_DIR)/usr/sbin/smartctl + rm -f $(TARGET_DIR)/usr/sbin/smart-status rm -f $(TARGET_DIR)/etc/smart_drivedb.h endef This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |