操作环境:CentOS 7
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.7.1908 (Core)
[root@localhost ~]# vim local_yum.sh
#!/bin/bash
#create by liujun at 2020-03-05
#mount cd
mkdir /mnt/cdrom
mount /dev/sr0 /mnt/cdrom &> /dev/null
#clean yum.repos
rm -rf /etc/yum.repos.d/*
#edit yum.repo
cat > /etc/yum.repos.d/local.repo << EOF
[local]
name=local
baseurl=file:///mnt/cdrom
enabled=1
gpgcheck=0
EOF
#yum makecache
yum clean all
yum makecache
学习shell编程第一章