-
Notifications
You must be signed in to change notification settings - Fork 2
/
smartester
executable file
·46 lines (41 loc) · 1.07 KB
/
smartester
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
# (c) 2020 Leif Sawyer
# License: GPL 3.0 (see https://github.com/akhepcat/)
# Permanent home: https://github.com/akhepcat/Miscellaneous/
# Direct download: https://raw.githubusercontent.com/akhepcat/Miscellaneous/master/smartester
#
#
# Run this inside of screen, then 'watch' a status version live or in another screen.
drive=$1
if [ -z "${drive}" -o ! -b "${drive}" ]
then
echo "$0 [drive]"
exit 1
fi
start() {
smartctl --test=long ${drive}
status
}
stop() {
running=$(smartctl -a ${drive} 2>&1 | grep -i 'Self-test routine in progress')
if [ -n "${running}" ]
then
echo "Interrupting a self-test in progress"
smartctl -X ${drive}
else
echo "No test running"
fi
}
status() {
smartctl -a ${drive} 2>&1 | grep -i -A3 '^Self-test execution'
}
case $2 in
start) start
;;
stop) stop
;;
status) status
;;
*) echo "$0 [drive] [start|stop|status]"
;;
esac