-
-
Save mqu/115fdc9eb471d81ac0ef1884746faefa to your computer and use it in GitHub Desktop.
smartdrive-ctl : bash wrapper against smartdrive to wakeup and standby drives and getting status.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
drives='sda sdb sdc sdd' | |
delay=60 | |
# 60 = 5mn | |
# 72 = 6mn (5*72=360s) | |
_in_standby() { | |
smartctl -i -n standby $1 > /dev/null | grep -q 'Device is in STANDBY mode' | |
return $? | |
} | |
case "$1" in | |
start|wakeup) | |
;; | |
stop) | |
;; | |
standby) | |
# set (force) in standby mode | |
for d in $drives ; do | |
# _in_standby $d || hdparm -q -y /dev/$d | |
hdparm -q -y /dev/$d | |
done | |
;; | |
status) | |
# status | |
for d in $drives ; do | |
status=$(smartctl -i -n standby /dev/$d | egrep 'Device is in|Power mode') | |
echo "/dev/$d: $status" | |
done | |
;; | |
setup) | |
# set timeout of inactivity before shutdown in standby mode. | |
for d in $drives ; do | |
smartctl -s on /dev/$d | |
hdparm -q -S $delay /dev/$d | |
done | |
;; | |
test) | |
drive=/dev/sda | |
_in_standby /dev/sdb && echo "sda in standby" | |
drive=/dev/sdb | |
_in_standby /dev/sdb && echo "sdb in standby" | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment