1、脚本代码详解
echo "------------------------------------BEGIN------------------------------------"
function create_yum
{
echo -e "\033[32;40mThe local source installation starts! \033[0m"
cd /etc/yum.repos.d/
mkdir repo
mv *.repo ./repo
cat << EOF > base_local.repo
[LocalRepo_BaseOS]
name=LocalRepository_BaseOS
baseurl=file:///mnt/BaseOS
enabled=1
gpgcheck=0
[LocalRepo_AppStream]
name=LocalRepository_AppStream
baseurl=file:///mnt/AppStream
enabled=1
gpgcheck=0
EOF
if [ -f base_local.repo ];then
echo -e "\033[32;40mThe local source is created successfully! \033[0m"
else
echo -e "\033[31;40mERROR! The local source fails to be created. Procedure \033[0m"
fi
cd ~
sleep 1s
}
function mount_iso
{
cd /root
mount CentOS-8.2.2004-x86_64-dvd1.iso /mnt
yum clean all > /dev/null
yum makecache > /dev/null
echo -e "\033[32;40mISO is mount successfully! \033[0m"
cd ~
sleep 1s
}
function yum_install
{
yum install -y "telnet" "net-tools" "openssl" "libcurl" "compat-openssl10" "bzip2" "iptables-services" "llvm-libs" "tk" "psmisc" "wget" "nmap" "traceroute" > /dev/null
echo -e "\033[32;40mThe packet Successful installation! \033[0m"
sleep 1s
}
create_yum && mount_iso && yum_install
echo "-------------------------------------END-------------------------------------"
2、代码执行结果
3、脚本参数调整
- 第10行可修改存放repo配置文件目录名称,修改位置
repo ; - 第13行可修改生效repo配置文件名称,修改位置
base_local.repo ; - 第42行可修改挂载镜像名称与路径,修改位置
CentOS-8.2.2004-x86_64-dvd1.iso ,如/dev/sr0; - 第52行可修改yum安装rpm包名称,修改位置
"telnet" "net-tools" ... ,以空格间隔;
|