#!/bin/bash
#By:zhaocheng
#Date:2019-01-18
#Version v1

[ -d /media/cdrom ] || mkdir /media/cdrom
[ -d /media/cdrom/Packages ] || mount /dev/cdrom /media/cdrom &> /dev/null
echo "正在搭建本地yum仓库,请耐心等待..."
#修改yum仓库配置文件
cd /etc/yum.repos.d/
[ -d  bak ] || mkdir bak
mv *.r* bak
cp bak/*M* .
cat << EOF > CentOS-Media.repo
[c7-media]
name=CentOS-$releasever - Media
baseurl=file:///media/CentOS/
        file:///media/cdrom/
        file:///media/cdrecorder/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
EOF
cd /media/cdrom/
rpm --import *K*
yum -y clean all &>/dev/null
yum makecache &>/dev/null
echo "启动成功"

05-22 05:19