执行更换脚本配置系统repo和epel repo

    1. #!/bin/bash
    2. # centos7系统配置国内系统镜像源和epel源
    3. yum_cfg()
    4. {
    5. echo -e " start yum repo configuration"
    6. which wget || yum install -y wget
    7. cd /etc/yum.repos.d/
    8. yum_set_base(){
    9. [ -f /etc/yum.repos.d/CentOS-Base.repo ] && mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.def
    10. wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    11. sed -i '/aliyuncs/d' /etc/yum.repos.d/CentOS-Base.repo
    12. }
    13. yum_set_epel(){
    14. [ -f /etc/yum.repos.d/epel.repo ] && mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.def
    15. wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
    16. sed -i '/aliyuncs/d' /etc/yum.repos.d/epel.repo
    17. }
    18. yum_set_base
    19. yum_set_epel
    20. yum clean all
    21. yum makecache
    22. yum grouplist > /dev/null || { echo "line $LINENO yum set error!;";exit 1; }
    23. echo -e " configuration yum succeed!!"
    24. }
    25. yum_cfg