#!/bin/bash
. /etc/init.d/functions
# 定义ISO镜像位置
IsoPath=/root/CentOS-7-x86_64-DVD-1708.iso
Time=$(date +%F).bak
Yum(){
# 挂载镜像
mkdir /mnt/centos
mount ${IsoPath} /mnt/centos
# 备份
(mkdir /etc/yum.repos.d/${Time}
mv /etc/yum.repos.d/* /etc/yum.repos.d/${Time})
# 添加repo文件
cat >> /etc/yum.repos.d/localhost.repo <<EOF
[localhost]
name=localhost
baseurl=file:///mnt/centos
gpgcheck=0
enabled=1
EOF
yum clean all
}
Yum &>/dev/null
if (yum -y install bc-1.06.95-13.el7.x86_64 &>/dev/null);then
action "Yum:"
else
action "Yum:" false
fi