一叶知秋.

业精于勤,荒于嬉;行成于思,毁于随。

CentOS7本地yum配置脚本

CentOS7本地yum配置脚本

脚本下载

#bin/env bash
#date:2020-08-02
#name:repo.sh
iso=/dev/cdrom
read -p "请输入要创建的yum名称:" yum

if [[ -z "$yum" ]];then
    #echo -e "\033[33m没有任何输入,请输入\033[0m"
    read -p "请输入要创建的yum名称:" yum
    [[ -z "$yum" ]] && echo -e "\033[31m没有输入,请重试!\033[0m" && exit
    
fi
 
mkdir -p /mnt/cdrom
mount $iso /mnt/cdrom &> /dev/null
if [[ $? -eq 0 ]];then
    echo -e "\033[31m镜像没有连接,请先连接\033[0m"
    exit
fi

echo "mount $iso /mnt/cdrom" >>/etc/rc.local

tee >> /etc/yum.repos.d/"$yum".repo<<-eof
[$yum]
name=$yum
baseurl=file:///mnt/cdrom
gpgcheck=0
enable=1
eof

yum clean all &> /dev/null
echo -e "\033[32m本地yum源配置成功\033[0m"

posted @ 2020-08-05 07:45  ccku  阅读(296)  评论(0编辑  收藏  举报