#!/bin/bash
LOCAL_SHELL_PATH="$(dirname $0)"
LOCAL_SHELL_NAME="$(basename $0)"
check_return_code()
{
retcode="$1"
action="$2"
msg="$3"
if [ "${retcode}" != "0" ]; then
echo "${action} failed! Error message: ${msg}"
exit 2
else
echo "${action} sucessfully!"
fi
}
install_rpm()
{
filepath=$2
rpmname=$1
echo "Start installing ${rpmname}.rpm ..."
existed=$(rpmquery -a | grep ${rpmname})
if [ "${existed}" == "" ]; then
msg=$(rpm -i ${filepath}/${rpmname}.rpm 2>&1)
check_return_code $? "Install ${rpmname}.rpm" "${msg}"
else
echo "Rpm ${rpmname}.rpm is already installed!"
fi
return 0
}
install_rpm flashcache-utils-3.1.2-1.el6.elrepo.x86_64 $LOCAL_SHELL_PATH
install_rpm kmod-flashcache-3.1.2-1.el6.elrepo.x86_64 $LOCAL_SHELL_PATH