Skip to content

Instantly share code, notes, and snippets.

@Razva
Last active February 24, 2017 13:45
Show Gist options
  • Save Razva/8a6f60a0ed5a9bda68fc to your computer and use it in GitHub Desktop.
Save Razva/8a6f60a0ed5a9bda68fc to your computer and use it in GitHub Desktop.
Y / N
printf "\nThis script will install, check, enable, test and activate SmartMonTools.\n"
read -p "Do you want to continue? Y/N " -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]
then
printf '\n'
printf %s "Installing smartmontools ... "
#rm -rf smartmon-install.log &>/dev/null
yum install -y smartmontools >> smartmon-install.log
printf '%s\n' "DONE!"
echo "========"
echo "Here's a list of all your drives:"
grep "\bsd[a-z]\b" /proc/diskstats | awk '{print $3}'
echo "========"
echo "Let's see if your drives have S.M.A.R.T. support."
read -p "Insert drive name: " drive
echo "========"
smartctl -i /dev/$drive | grep 'SMART support is'
echo "========"
read -p "Is your drive SMART Enabled? Y/N " -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]
then
printf '\n'
printf %s "Enabling SMART ... "
smartctl -s on /dev/$drive &>/dev/null
printf '%s\n' "DONE!"
printf %s "Generating a LONG test ..."
smartctl -t long /dev/$drive &>/dev/null
printf '%s\n' "DONE!"
echo "========"
# read -p "Do you want to enable SMART for another drive? Y/N " -n 1 -r
# if [[ $REPLY =~ ^[Yy]$ ]]
# then continue
# fi
# break
echo "========"
echo "Starting the SMART daemon, please check if [ OK ]"
service smartd start
printf %s "Enabling SMART daemon at startup ... "
chkconfig smartd on &>/dev/null
printf '%s\n' "DONE!"
echo "You should edit the /etc/aliases file in order to receive root alerts on your email. Hint: check the last line."
read -p "Do you want to edit the file now? Y/N " -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]
then
nano -w /etc/aliases
fi
printf "\nInstallation successful. Bye!\n"
exit
fi
printf "\nYou need a SMART enabled drive in order to use SmartMonTools. Get a better disk or server. Bye!\n"
exit
fi
printf '\nInstallation canceled. Bye!\n'
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment