diff options
| author | Anton Bobov <abobov@gmail.com> | 2013-09-25 19:29:06 +0600 |
|---|---|---|
| committer | Anton Bobov <abobov@gmail.com> | 2013-09-25 20:19:55 +0600 |
| commit | 30012dbda6ac6fd4e2f11707c93aedd8ef7b86b6 (patch) | |
| tree | 3359884b0f2d0e7c5be3be2c66fc29912ab37b49 /smartinfo | |
| parent | b323d38acdae3c2e01408184456289124ea3a59f (diff) | |
Update.
Diffstat (limited to 'smartinfo')
| -rwxr-xr-x | smartinfo | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/smartinfo b/smartinfo new file mode 100755 index 0000000..a98c0cc --- /dev/null +++ b/smartinfo @@ -0,0 +1,32 @@ +#!/bin/bash +# Get device S.M.A.R.T. and store in appropriate file. + +set -e + +die() { + echo $1 + exit 1 +} + +get_file_name() { + sn=$(sed -n 's/Serial Number: \+//p' < "$1" | tr ' ' '_') + printf 'smart-%s-%s.txt' "$sn" "$(date +%F)" +} + +[ -b "$1" ] && DEVICE="$1" || die 'First parameter must be block device.' + +tmp=$(tempfile) +sudo smartctl -Ai "$DEVICE" > "$tmp" +fname=$(get_file_name "$tmp") +if [ -f "$fname" ] ; then + echo "File $fname already exists. Override? [yN] " + read answer + case "$answer" in + y|Y) + ;; + *) + exit 0 + ;; + esac +fi +mv "$tmp" "$fname" |
