亚洲国产第一_开心网五月色综合亚洲_日本一级特黄特色大片免费观看_久久久久久久久久免观看

Hello! 歡迎來到小浪云!


centos各版本更換阿里源的腳本


avatar
小浪云 2024-09-15 253


本文介紹一個centos各版本更換阿里源的腳本,以作參考

#!/bin/bash

 

# Detect centos version

if [ -f /etc/os-release ]; then

    . /etc/os-release

    OS_NAME=$ID

    OS_VERSION_ID=$VERSION_ID

elif [ -f /etc/centos-release ]; then

    OS_NAME=centos

    OS_VERSION_ID=$(rpm -q –qf “%{VERSION}” $(rpm -q –whatprovides redhat-release))

else

    echo “不支持的系統類型.”

    exit 1

fi

 

function to backup and replace yum repo files

replace_yum_repo() {

    local url=$1

    local dest_dir=“/etc/yum.repos.d”

 

    # Backup existing repo files

    mkdir -p ${dest_dir}/backup”

    mv ${dest_dir}/*.repo ${dest_dir}/backup/

 

    # Download new repo file

    cURL -o ${dest_dir}/centos-Base.repo ${url}

}

 

# Replace yum repo based on centos version

case $OS_VERSION_ID in

    6)

        echo “Detected centos 6″

        replace_yum_repo http://www.landui.com/repo/centos-6.repo”

        ;;

    7)

        echo “Detected centos 7″

        replace_yum_repo http://www.landui.com/repo/centos-7.repo”

        ;;

    8)

        echo “Detected centos 8″

        replace_yum_repo http://www.landui.com/repo/centos-8.repo”

        ;;

    *)

        echo “不支持的系統版本$OS_VERSION_ID

        exit 1

        ;;

esac

 

# Clean yum cache

yum clean all

yum makecache

 

echo yum已成功更換為阿里源!”

 

# End of script

相關閱讀