#!/bin/bash
read -p "input iso letter:" name
if [ -a "$name" ]
then
mkdir -p /media/iso/
mount -t iso9660 $name /media/iso
# 备份原本地源
cp -rf /etc/yum.repos.d /etc/yum.repos.d_$(date '+%Y%m%d_%H%M%S')
# 删除默认原本地源
rm -rf /etc/yum.repos.d/*
# 配置本地源,创建Media.repo文件,并配置如下内容
cd /etc/yum.repos.d/
>Media.repo
echo '[iso]' >> Media.repo
echo 'name=Media' >> Media.repo
echo 'baseurl=file:///media/iso/' >> Media.repo
echo 'gpgcheck=0' >> Media.repo
echo 'enabled=1' >> Media.repo
# 清除yum缓存
yum clean all
# 缓存本地yum源
yum makecache
# 安装工具
yum install -y conntrack conntrack-tools libnetfilter_cthelper libnetfilter_cttimeout libnetfilter_queue libseccomp java python3 tcpdump sysstat net-tools netstat bind-utils psmisc dstat iostat
else
echo "iso letter does not exist"
fi
sh yum.sh
输入iso镜像绝对路径