-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhddguardian.sh
More file actions
executable file
·31 lines (22 loc) · 848 Bytes
/
hddguardian.sh
File metadata and controls
executable file
·31 lines (22 loc) · 848 Bytes
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
#! /bin/bash
fullfilename=${0##*/}
filename="${fullfilename%.*}"
logfile="/var/log/scripts/$filename.log"
email=pasula.ubuntu@gmail.com
savepath="/home/Shared Docs/SMART/"
runcmd="/usr/sbin/smartctl -a"
echo "Script output will be logged to $logfile"
logger -p syslog.info "Updating SMART attributes. Output stored in ${savepath}"
exec > "$logfile" 2>&1
/opt/scripts/scriptheader.sh "HDD Guardian Update"
for i in {a,b,c,d,e}
do
read MN <<< $(sudo hdparm -I /dev/sd${i} | awk '/Model Number:/ { print $3 }')
read SN <<< $(sudo hdparm -I /dev/sd${i} | awk '/Serial Number:/ { print $3 }')
fullpath="${savepath}${MN}_${SN}.txt"
sudo /usr/sbin/smartctl -a /dev/sd${i} > "${fullpath}"
done
if [[ -f ${logfile} ]]; then
# echo "Mailing log to ${email}"
# mail -s "${filename^} Log - $(date +%m-%d-%Y)" ${email} < ${logfile}
fi