#!/bin/bash
if [ `id -g` != 0 ] ;then
echo -e "\033[31m Please use root user\033[0m"
exit 1
fi
rpm -qa |grep multipath >/var/log/mapper.log 2>&1
if [ $? = 0 ];then
echo -e "\033[31mERROR : Please check multipath is already installed \033[0m "
exit 7
fi
rpm -ivh --test device-mapper-multipath-0.4.9-87.el6.x86_64.rpm device-mapper-multipath-libs-0.4.9-87.el6.x86_64.rpm >>/var/log/mapper.log 2>&1
if [ $? = 0 ];then
rpm -ivh device-mapper-multipath-0.4.9-87.el6.x86_64.rpm device-mapper-multipath-libs-0.4.9-87.el6.x86_64.rpm >>/var/log/mapper.log 2>&1
else
echo -e "\033[31m ERROR : Test install is not successful , Please view the mapper log /var/log/mapper.log \033[0m"
exit 8
fi
if [ $? = 0 ];then
chkconfig multipathd on &&
service multipathd start >>/var/log/mapper.log 2>&1 &&
cp /usr/share/doc/device-mapper-multipath-0.4.9/multipath.conf /etc/multipath.conf >>/var/log/mapper.log 2>&1
multipath -F >>/var/log/mapper.log 2>&1 && multipath -v2 >>/var/log/mapper.log 2>&1 && multipath -ll >>/var/log/mapper.log 2>&1
else
echo -e "\n \033[31m ERROR : Install Error,Please Check!! or view the mapper.log /var/log/mapper.log \033[0m \n"
exit 9
fi