#!/bin/bash # # Script to detect and install proper RAID health monitoring # x86_64=0 # # Check for x86_64 (Test 1) # if [ "`uname -i|grep x86_64`" == "x86_64" ]; then x86_64=1 fi # # Check for x86_64 (Test 2) - some OSs (ie. Gentoo) return Processor manufacturer # rather than architecture with "uname -i" # if [ "`uname -a|grep x86_64`" != "" ]; then x86_64=1 fi ware=0 # # Check for 3Ware SATA RAID # if [ "`lsmod|grep 3w-xxxx`" != "" ]; then ware=1 fi if [ "`lsmod|grep 3w_xxxx`" != "" ]; then ware=1 fi megaraid=0 # # Check for MegaRAID cards # if [ "`lsmod|grep -w megaraid`" != "" ] || [ "`lsmod|grep -w megaraid_mbox`" != "" ]; then megaraid=1 fi # # 3Ware Install # if [ $ware == 1 ]; then echo "3Ware Hardware RAID Device Detected, Installing 3Ware Scripts" mkdir /home/temp cd /home/temp rm -f tw_cli* > /dev/null 2>&1 if [ $x86_64 == 1 ]; then /usr/bin/wget http://layer3.example.com/scripts/dsinstall/raid/tw_cli-linux-x86_64-9.3.0.3.tgz tar xzf tw_cli-linux-x86_64-9.3.0.3.tgz mv -f tw_cli /usr/local/bin/tw_cli chmod 755 /usr/local/bin/tw_cli else /usr/bin/wget http://layer3.example.com/scripts/dsinstall/raid/tw_cli-linux-x86-9.3.0.3.tgz tar xzf tw_cli-linux-x86-9.3.0.3.tgz chmod 755 tw_cli cp -f tw_cli /usr/local/bin/ fi /usr/bin/wget http://layer3.example.com/scripts/dsinstall/raid/3warecheck.sh chmod 755 3warecheck.sh cp -f 3warecheck.sh /usr/local/bin echo "0,30 * * * * /usr/local/bin/3warecheck.sh > /dev/null 2>&1 " >> /var/spool/cron/root /etc/init.d/crond restart fi # # MegaRAID Install (same binary works on 32/64 bit) # if [ $megaraid == 1 ]; then echo "Megaraid Hardware RAID Device Detected, Installing Megaraid Scripts" mkdir /home/temp cd /home/temp /usr/bin/wget http://layer3.example.com/scripts/dsinstall/raid/megarc.bin chmod 755 megarc.bin cp -f megarc.bin /usr/local/bin/ /usr/bin/wget http://layer3.example.com/scripts/dsinstall/raid/checkmegaraid.sh /usr/bin/wget http://layer3.example.com/scripts/dsinstall/raid/megarc chmod 755 megarc chmod 755 checkmegaraid.sh cp -f megarc /usr/local/bin/ cp -f checkmegaraid.sh /usr/local/bin echo "0,30 * * * * /usr/local/bin/checkmegaraid.sh > /dev/null 2>&1 " >> /var/spool/cron/root /etc/init.d/crond restart fi # # MegaRAID SAS # if [ "`lsmod | grep megaraid_sas`" != "" ]; then echo "Megaraid SAS device detected, installing SAS packages" wget -P /home/temp http://layer3.example.com/scripts/dsinstall/raid/MegaCli-1.01.39-0.i386.rpm rpm -ivh /home/temp/MegaCli-1.01.39-0.i386.rpm /usr/bin/wget -P /usr/local/bin/ http://layer3.example.com/scripts/dsinstall/raid/sascheck.sh chmod +x /usr/local/bin/sascheck.sh echo "0,30 * * * * /usr/local/bin/sascheck.sh > /dev/null 2>&1" >> /var/spool/cron/root /etc/init.d/crond restart fi # # Software RAID Check/Install # if [ "`mount|grep /dev/md`" != "" ]; then echo "Software RAID Device Detected, Installing MDADM" /usr/bin/yum -y install mdadm echo "MAILADDR support@example.com" >> /etc/mdadm.conf /sbin/chkconfig --add mdmonitor /sbin/chkconfig --level 345 mdmonitor on /etc/init.d/mdmonitor restart fi