#!/bin/sh -e
set -x
#cd 到utils 路径,然后执行这个路径下的两个脚本文件后,通过cd - 返回到当前目录
cd ../../utils
. ./sys_info.sh
./sh-test-lib
cd -
#通过whoami 判断是否是root 用户,如果是root用户,则输出root
if [ `whoami` != 'root' ] ; then
echo "You must be the superuser to run this script" >&2
exit 1
fi
version="1.0.5"
from_repo="Estuary"
package="blktrace"
#打印需要安装的包的名字
for P in ${package};do
echo "$P install"
# Install package
case $distro in
"centos" )
#目前看起来只支持centos,则通过yum安装这个包
yum install -y "$P"
print_info $? "$P"
;;
esac
# Check the package version && source
#检查包的信息和repo信息是否正确
#首先得到repo信息
from=$(yum info $P | grep "From repo" | awk '{print $4}')
if [ "$from" = "$from_repo" ];then
echo "$P source is $from : [pass]" | tee -a ${RESULT_FILE}
else
rmflag=1
if [ "$from" != "Estuary" ];then
#如果repo信息不对,则删除这个包
yum remove -y $P
yum install -y $P
from=$(yum info $P | grep "From repo" | awk '{print $4}')
if [ "$from" = "$from_repo" ];then
echo "$P install [pass]" | tee -a ${RESULT_FILE}
else
echo "$P source is $from : [failed]" | tee -a ${RESULT_FILE}
fi
fi
fi
#得到这个包的版本信息
vers=$(yum info $P | grep "Version" | awk '{print $3}')
#判断这个包的版本信息是否相等,本质上就是判断字符串是否相等
if [ "$vers" = "$version" ];then
echo "$P version is $vers : [pass]" | tee -a ${RESULT_FILE}
else
echo "$P version is $vers : [failed]" | tee -a ${RESULT_FILE}
fi
done
#执行blktrace 命令,并输出结果
# Display the blktrace result on screen.
blktrace -d /dev/sda -w 5 -o - |blkparse -i -
print_info $? display
# Output the blktrace result on file.
blktrace -d /dev/sda -w 10 -o trace | blkparse -i -
print_info $? output
#测试完成后删除这个包.
# Remove the blktrace package
yum remove -y "$P"
print_info $? remove