diff --git a/ChangeMirrors.sh b/ChangeMirrors.sh
index 7ae9c6d..ead6bbf 100644
--- a/ChangeMirrors.sh
+++ b/ChangeMirrors.sh
@@ -1,36 +1,32 @@
#!/bin/bash
## Author: SuperManito
-## Modified: 2022-09-14
+## Modified: 2023-04-18
## License: GPL-2.0
## Github: https://github.com/SuperManito/LinuxMirrors
## Gitee: https://gitee.com/SuperManito/LinuxMirrors
-function AuthorSignature() {
- echo -e "\n${GREEN} ------------ 脚本执行结束 ------------ ${PLAIN}\n"
- echo -e " \033[1;34m官方网站\033[0m https://supermanito.github.io/LinuxMirrors\n"
-}
-
## 定义系统判定变量
-DebianRelease="lsb_release"
ARCH=$(uname -m)
+DebianRelease_CMD="lsb_release"
SYSTEM_DEBIAN="Debian"
SYSTEM_UBUNTU="Ubuntu"
SYSTEM_KALI="Kali"
SYSTEM_REDHAT="RedHat"
SYSTEM_RHEL="RedHat"
SYSTEM_CENTOS="CentOS"
+SYSTEM_CENTOS_STREAM="CentOS Stream"
SYSTEM_FEDORA="Fedora"
## 定义目录和文件
-LinuxRelease=/etc/os-release
-RedHatRelease=/etc/redhat-release
-DebianVersion=/etc/debian_version
-DebianSourceList=/etc/apt/sources.list
-DebianSourceListBackup=/etc/apt/sources.list.bak
-DebianExtendListDir=/etc/apt/sources.list.d
-DebianExtendListDirBackup=/etc/apt/sources.list.d.bak
-RedHatReposDir=/etc/yum.repos.d
-RedHatReposDirBackup=/etc/yum.repos.d.bak
+File_LinuxRelease=/etc/os-release
+File_RedHatRelease=/etc/redhat-release
+File_DebianVersion=/etc/debian_version
+File_DebianSourceList=/etc/apt/sources.list
+File_DebianSourceListBackup=/etc/apt/sources.list.bak
+Dir_DebianExtendSource=/etc/apt/sources.list.d
+Dir_DebianExtendSourceBackup=/etc/apt/sources.list.d.bak
+Dir_RedHatRepos=/etc/yum.repos.d
+Dir_RedHatReposBackup=/etc/yum.repos.d.bak
SelinuxConfig=/etc/selinux/config
RED='\033[31m'
@@ -45,6 +41,11 @@ WARN='[\033[33mWARN\033[0m]'
ERROR='[\033[31mERROR\033[0m]'
WORKING='[\033[34m*\033[0m]'
+function AuthorSignature() {
+ echo -e "\n${GREEN} ------------ 脚本执行结束 ------------ ${PLAIN}\n"
+ echo -e " \033[1;34m官方网站\033[0m https://supermanito.github.io/LinuxMirrors\n"
+}
+
## 组合函数
function Combin_Function() {
PermissionJudgment
@@ -60,18 +61,18 @@ function Combin_Function() {
## 系统判定变量
function EnvJudgment() {
## 判定当前系统基于 Debian or RedHat
- if [ -s $RedHatRelease ]; then
+ if [ -s $File_RedHatRelease ]; then
SYSTEM_FACTIONS=${SYSTEM_REDHAT}
- elif [ -s $DebianVersion ]; then
+ elif [ -s $File_DebianVersion ]; then
SYSTEM_FACTIONS=${SYSTEM_DEBIAN}
else
- echo -e "\n$ERROR 无法判断当前运行环境,请先确认本脚本针对当前操作系统是否适配\n"
+ echo -e "\n$ERROR 无法判断当前运行环境,请先确认本脚本是否已经适配当前操作系统\n"
exit
fi
## 定义系统名称
- SYSTEM_NAME=$(cat $LinuxRelease | grep -E "^NAME=" | awk -F '=' '{print$2}' | sed "s/[\'\"]//g")
+ SYSTEM_NAME=$(cat $File_LinuxRelease | grep -E "^NAME=" | awk -F '=' '{print$2}' | sed "s/[\'\"]//g")
## 定义系统版本号
- SYSTEM_VERSION_NUMBER=$(cat $LinuxRelease | grep -E "VERSION_ID=" | awk -F '=' '{print$2}' | sed "s/[\'\"]//g")
+ SYSTEM_VERSION_NUMBER=$(cat $File_LinuxRelease | grep -E "VERSION_ID=" | awk -F '=' '{print$2}' | sed "s/[\'\"]//g")
## 判定系统名称、版本、版本号
case ${SYSTEM_FACTIONS} in
Debian)
@@ -81,19 +82,22 @@ function EnvJudgment() {
clear
else
echo -e "\n$ERROR lsb-release 软件包安装失败"
- echo -e "\n本脚本需要通过 lsb_release 指令判断系统类型,当前可能为精简安装的系统一般系统自带,请自行安装后重新执行脚本!\n"
+ echo -e "\n本脚本需要通过 lsb_release 指令判断系统类型,当前可能为精简安装的系统,因为正常情况下系统会自带该软件包,请自行安装后重新执行脚本!\n"
exit
fi
fi
- SYSTEM_JUDGMENT=$(${DebianRelease} -is)
- SYSTEM_VERSION=$(${DebianRelease} -cs)
+ SYSTEM_JUDGMENT=$(${DebianRelease_CMD} -is)
+ SYSTEM_VERSION=$(${DebianRelease_CMD} -cs)
;;
RedHat)
- SYSTEM_JUDGMENT=$(cat $RedHatRelease | sed 's/ //g' | cut -c1-6)
- if [[ ${SYSTEM_JUDGMENT} = ${SYSTEM_CENTOS} || ${SYSTEM_JUDGMENT} = ${SYSTEM_RHEL} ]]; then
- CENTOS_VERSION=$(echo ${SYSTEM_VERSION_NUMBER} | cut -c1)
+ SYSTEM_JUDGMENT=$(cat $File_RedHatRelease | sed 's/ //g' | cut -c1-6)
+ if [[ "${SYSTEM_JUDGMENT}" = ${SYSTEM_CENTOS} || "${SYSTEM_JUDGMENT}" = ${SYSTEM_RHEL} ]]; then
+ SYSTEM_VERSION_NUMBER=${SYSTEM_VERSION_NUMBER}
+ # 判断是否为 CentOS Stream
+ cat $File_RedHatRelease | grep -q "Stream"
+ [ $? -eq 0 ] && SYSTEM_JUDGMENT="${SYSTEM_CENTOS_STREAM}"
else
- CENTOS_VERSION=""
+ SYSTEM_VERSION_NUMBER=""
fi
;;
esac
@@ -119,14 +123,12 @@ function EnvJudgment() {
;;
esac
## 定义软件源分支名称
- if [ ${SYSTEM_JUDGMENT} = ${SYSTEM_UBUNTU} ]; then
+ if [ "${SYSTEM_JUDGMENT}" = ${SYSTEM_UBUNTU} ]; then
if [ ${ARCH} = "x86_64" ] || [ ${ARCH} = "*i?86*" ]; then
SOURCE_BRANCH=${SYSTEM_JUDGMENT,,}
else
SOURCE_BRANCH=ubuntu-ports
fi
- elif [ ${SYSTEM_JUDGMENT} = ${SYSTEM_RHEL} ]; then
- SOURCE_BRANCH="centos"
else
SOURCE_BRANCH=${SYSTEM_JUDGMENT,,}
fi
@@ -173,92 +175,92 @@ function CloseFirewall() {
function BackupMirrors() {
if [ ${SYSTEM_FACTIONS} = ${SYSTEM_DEBIAN} ]; then
## 判断 /etc/apt/sources.list.d 目录下是否存在文件
- [ -d $DebianExtendListDir ] && ls $DebianExtendListDir | grep *.list -q
+ [ -d $Dir_DebianExtendSource ] && ls $Dir_DebianExtendSource | grep *.list -q
VERIFICATION_FILES=$?
## 判断 /etc/apt/sources.list.d.bak 目录下是否存在文件
- [ -d $DebianExtendListDirBackup ] && ls $DebianExtendListDirBackup | grep *.list -q
+ [ -d $Dir_DebianExtendSourceBackup ] && ls $Dir_DebianExtendSourceBackup | grep *.list -q
VERIFICATION_BACKUPFILES=$?
elif [ ${SYSTEM_FACTIONS} = ${SYSTEM_REDHAT} ]; then
## 判断 /etc/yum.repos.d 目录下是否存在文件
- [ -d $RedHatReposDir ] && ls $RedHatReposDir | grep repo -q
+ [ -d $Dir_RedHatRepos ] && ls $Dir_RedHatRepos | grep repo -q
VERIFICATION_FILES=$?
## 判断 /etc/yum.repos.d.bak 目录下是否存在文件
- [ -d $RedHatReposDirBackup ] && ls $RedHatReposDirBackup | grep repo -q
+ [ -d $Dir_RedHatReposBackup ] && ls $Dir_RedHatReposBackup | grep repo -q
VERIFICATION_BACKUPFILES=$?
fi
if [ ${SYSTEM_FACTIONS} = ${SYSTEM_DEBIAN} ]; then
## /etc/apt/sources.list
- if [ -s $DebianSourceList ]; then
- if [ -s $DebianSourceListBackup ]; then
- CHOICE_BACKUP1=$(echo -e "\n${BOLD}└─ 检测到系统存在已备份的 list 源文件,是否覆盖备份? [Y/n] ${PLAIN}")
+ if [ -s $File_DebianSourceList ]; then
+ if [ -s $File_DebianSourceListBackup ]; then
+ CHOICE_BACKUP1=$(echo -e "\n${BOLD}└─ 检测到系统存在已备份的 list 源文件,是否跳过覆盖备份? [Y/n] ${PLAIN}")
read -p "${CHOICE_BACKUP1}" INPUT
[ -z ${INPUT} ] && INPUT=Y
case $INPUT in
- [Yy] | [Yy][Ee][Ss])
- cp -rf $DebianSourceList $DebianSourceListBackup >/dev/null 2>&1
+ [Yy] | [Yy][Ee][Ss]) ;;
+ [Nn] | [Nn][Oo])
+ cp -rf $File_DebianSourceList $File_DebianSourceListBackup >/dev/null 2>&1
;;
- [Nn] | [Nn][Oo]) ;;
*)
echo -e "\n$WARN 输入错误,默认不覆盖!"
;;
esac
else
- cp -rf $DebianSourceList $DebianSourceListBackup >/dev/null 2>&1
- echo -e "\n$COMPLETE 已备份原有 list 源文件至 $DebianSourceListBackup"
+ cp -rf $File_DebianSourceList $File_DebianSourceListBackup >/dev/null 2>&1
+ echo -e "\n$COMPLETE 已备份原有 list 源文件至 $File_DebianSourceListBackup"
sleep 1s
fi
else
- [ -f $DebianSourceList ] || touch $DebianSourceList
+ [ -f $File_DebianSourceList ] || touch $File_DebianSourceList
echo -e ''
fi
## /etc/apt/sources.list.d
- if [ -d $DebianExtendListDir ] && [ ${VERIFICATION_FILES} -eq 0 ]; then
- if [ -d $DebianExtendListDirBackup ] && [ ${VERIFICATION_BACKUPFILES} -eq 0 ]; then
- CHOICE_BACKUP2=$(echo -e "\n${BOLD}└─ 检测到系统存在已备份的 list 第三方源文件,是否覆盖备份? [Y/n] ${PLAIN}")
+ if [ -d $Dir_DebianExtendSource ] && [ ${VERIFICATION_FILES} -eq 0 ]; then
+ if [ -d $Dir_DebianExtendSourceBackup ] && [ ${VERIFICATION_BACKUPFILES} -eq 0 ]; then
+ CHOICE_BACKUP2=$(echo -e "\n${BOLD}└─ 检测到系统存在已备份的 list 第三方源文件,是否跳过覆盖备份? [Y/n] ${PLAIN}")
read -p "${CHOICE_BACKUP2}" INPUT
[ -z ${INPUT} ] && INPUT=Y
case $INPUT in
- [Yy] | [Yy][Ee][Ss])
- cp -rf $DebianExtendListDir/* $DebianExtendListDirBackup >/dev/null 2>&1
+ [Yy] | [Yy][Ee][Ss]) ;;
+ [Nn] | [Nn][Oo])
+ cp -rf $Dir_DebianExtendSource/* $Dir_DebianExtendSourceBackup >/dev/null 2>&1
;;
- [Nn] | [Nn][Oo]) ;;
*)
echo -e "\n$WARN 输入错误,默认不覆盖!"
;;
esac
else
- [ -d $DebianExtendListDirBackup ] || mkdir -p $DebianExtendListDirBackup
- cp -rf $DebianExtendListDir/* $DebianExtendListDirBackup >/dev/null 2>&1
- echo -e "$COMPLETE 已备份原有 list 第三方源文件至 $DebianExtendListDirBackup 目录"
+ [ -d $Dir_DebianExtendSourceBackup ] || mkdir -p $Dir_DebianExtendSourceBackup
+ cp -rf $Dir_DebianExtendSource/* $Dir_DebianExtendSourceBackup >/dev/null 2>&1
+ echo -e "$COMPLETE 已备份原有 list 第三方源文件至 $Dir_DebianExtendSourceBackup 目录"
sleep 1s
fi
fi
elif [ ${SYSTEM_FACTIONS} = ${SYSTEM_REDHAT} ]; then
## /etc/yum.repos.d
if [ ${VERIFICATION_FILES} -eq 0 ]; then
- if [ -d $RedHatReposDirBackup ] && [ ${VERIFICATION_BACKUPFILES} -eq 0 ]; then
- CHOICE_BACKUP3=$(echo -e "\n${BOLD}└─ 检测到系统存在已备份的 repo 源文件,是否覆盖备份? [Y/n] ${PLAIN}")
+ if [ -d $Dir_RedHatReposBackup ] && [ ${VERIFICATION_BACKUPFILES} -eq 0 ]; then
+ CHOICE_BACKUP3=$(echo -e "\n${BOLD}└─ 检测到系统存在已备份的 repo 源文件,是否跳过覆盖备份? [Y/n] ${PLAIN}")
read -p "${CHOICE_BACKUP3}" INPUT
[ -z ${INPUT} ] && INPUT=Y
case $INPUT in
- [Yy] | [Yy][Ee][Ss])
- cp -rf $RedHatReposDir/* $RedHatReposDirBackup >/dev/null 2>&1
+ [Yy] | [Yy][Ee][Ss]) ;;
+ [Nn] | [Nn][Oo])
+ cp -rf $Dir_RedHatRepos/* $Dir_RedHatReposBackup >/dev/null 2>&1
;;
- [Nn] | [Nn][Oo]) ;;
*)
echo -e "\n$WARN 输入错误,默认不覆盖!"
;;
esac
else
- [ -d $RedHatReposDirBackup ] || mkdir -p $RedHatReposDirBackup
- cp -rf $RedHatReposDir/* $RedHatReposDirBackup >/dev/null 2>&1
- echo -e "\n$COMPLETE 已备份原有 repo 源文件至 $RedHatReposDirBackup 目录"
+ [ -d $Dir_RedHatReposBackup ] || mkdir -p $Dir_RedHatReposBackup
+ cp -rf $Dir_RedHatRepos/* $Dir_RedHatReposBackup >/dev/null 2>&1
+ echo -e "\n$COMPLETE 已备份原有 repo 源文件至 $Dir_RedHatReposBackup 目录"
sleep 1s
fi
else
- [ -d $RedHatReposDir ] || mkdir -p $RedHatReposDir
+ [ -d $Dir_RedHatRepos ] || mkdir -p $Dir_RedHatRepos
fi
fi
}
@@ -266,13 +268,18 @@ function BackupMirrors() {
## 删除原有源
function RemoveOldMirrorsFiles() {
if [ ${SYSTEM_FACTIONS} = ${SYSTEM_DEBIAN} ]; then
- [ -f $DebianSourceList ] && sed -i '1,$d' $DebianSourceList
+ [ -f $File_DebianSourceList ] && sed -i '1,$d' $File_DebianSourceList
elif [ ${SYSTEM_FACTIONS} = ${SYSTEM_REDHAT} ]; then
- if [ -d $RedHatReposDir ]; then
- if [ -f $RedHatReposDir/epel.repo ]; then
- ls $RedHatReposDir/ | egrep -v epel | xargs rm -rf
+ if [ -d $Dir_RedHatRepos ]; then
+ # Fedora 系统特殊,只删除以 fedora 开头的文件
+ if [ "${SYSTEM_JUDGMENT}" = $SYSTEM_FEDORA ]; then
+ rm -rf $Dir_RedHatRepos/fedora*
else
- rm -rf $RedHatReposDir/*
+ if [ -f $Dir_RedHatRepos/epel.repo ]; then
+ ls $Dir_RedHatRepos/ | egrep -v epel | xargs rm -rf
+ else
+ rm -rf $Dir_RedHatRepos/*
+ fi
fi
fi
fi
@@ -299,8 +306,8 @@ function ChangeMirrors() {
echo -e "\n$COMPLETE 软件源更换完毕"
else
echo -e "\n$ERROR 软件源${SYNC_TXT}失败\n"
- echo -e "请再次执行脚本并更换软件源后进行尝试,如果仍然${SYNC_TXT}失败那么可能由以下原因导致"
- echo -e "1. 网络问题:例如网络异常、网络间歇式中断、由地区影响的网络因素等"
+ echo -e "请再次执行脚本并更换相同软件源后进行尝试,若仍然${SYNC_TXT}失败那么可能由以下原因导致"
+ echo -e "1. 网络问题:例如连接异常、网络间歇式中断、由地区影响的网络因素等"
echo -e "2. 软件源问题:所选镜像站正在维护,或者出现罕见的少数文件同步出错导致软件源${SYNC_TXT}命令执行后返回错误状态"
echo ''
exit
@@ -309,11 +316,12 @@ function ChangeMirrors() {
## 更新软件包
function UpgradeSoftware() {
- CHOICE_B=$(echo -e "\n${BOLD}└─ 是否更新软件包? [Y/n] ${PLAIN}")
+ CHOICE_B=$(echo -e "\n${BOLD}└─ 是否跳过更新软件包? [Y/n] ${PLAIN}")
read -p "${CHOICE_B}" INPUT
[ -z ${INPUT} ] && INPUT=Y
case $INPUT in
- [Yy] | [Yy][Ee][Ss])
+ [Yy] | [Yy][Ee][Ss]) ;;
+ [Nn] | [Nn][Oo])
echo -e ''
case ${SYSTEM_FACTIONS} in
Debian)
@@ -344,7 +352,6 @@ function UpgradeSoftware() {
;;
esac
;;
- [Nn] | [Nn][Oo]) ;;
*)
echo -e "\n$WARN 输入错误,默认不更新!"
;;
@@ -354,7 +361,7 @@ function UpgradeSoftware() {
## 更换基于 Debian 系 Linux 发行版的国内源
function DebianMirrors() {
## 修改国内源
- case ${SYSTEM_JUDGMENT} in
+ case "${SYSTEM_JUDGMENT}" in
Ubuntu)
echo "## 默认禁用源码镜像以提高速度,如需启用请自行取消注释
deb ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION} main restricted universe multiverse
@@ -368,7 +375,7 @@ deb ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION}-backports mai
## 预发布软件源(不建议启用)
# deb ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION}-proposed main restricted universe multiverse
-# deb-src ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION}-proposed main restricted universe multiverse" >>$DebianSourceList
+# deb-src ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION}-proposed main restricted universe multiverse" >>$File_DebianSourceList
;;
Debian)
echo "## 默认禁用源码镜像以提高速度,如需启用请自行取消注释
@@ -378,14 +385,14 @@ deb ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION}-updates main
# deb-src ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION}-updates main contrib non-free
deb ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION}-backports main contrib non-free
# deb-src ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION}-backports main contrib non-free
-
+
## 预发布软件源(不建议启用)
# deb ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH}-security ${SYSTEM_VERSION}/updates main contrib non-free
-# deb-src ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH}-security ${SYSTEM_VERSION}/updates main contrib non-free" >>$DebianSourceList
+# deb-src ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH}-security ${SYSTEM_VERSION}/updates main contrib non-free" >>$File_DebianSourceList
;;
Kali)
echo "deb ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION} main non-free contrib
-deb-src ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION} main non-free contrib" >>$DebianSourceList
+deb-src ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION} main non-free contrib" >>$File_DebianSourceList
;;
esac
}
@@ -393,60 +400,98 @@ deb-src ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION} main non-
## 更换基于 RedHat 系 Linux 发行版的国内源
function RedHatMirrors() {
## 生成基于 RedHat 发行版和及其衍生发行版的官方 repo 源文件
- case ${SYSTEM_JUDGMENT} in
+ case "${SYSTEM_JUDGMENT}" in
RedHat | CentOS)
- CreateCentOSRepoFiles
+ GenRepoFiles_CentOS
+ ;;
+ "CentOS Stream")
+ GenRepoFiles_CentOSStream
;;
Fedora)
- CreateReposRepoFiles
+ GenRepoFiles_Fedora
;;
esac
## 修改源
- cd $RedHatReposDir
- if [ ${SYSTEM_JUDGMENT} = ${SYSTEM_CENTOS} -o ${SYSTEM_JUDGMENT} = ${SYSTEM_RHEL} ]; then
+ cd $Dir_RedHatRepos
+ case "${SYSTEM_JUDGMENT}" in
+ RedHat | CentOS)
sed -i 's|^mirrorlist=|#mirrorlist=|g' ${SYSTEM_CENTOS}-*
## CentOS 8 操作系统版本结束了生命周期(EOL),Linux 社区已不再维护该操作系统版本,最终版本为 8.5.2011
- ## 原 centos 镜像中的 CentOS 8 相关内容已被官方移动,从 2022-02 开始切换至 centos-vault 源
- if [ ${CENTOS_VERSION} -eq "8" ]; then
- sed -i 's|^#baseurl=http://mirror.centos.org/$contentdir|#baseurl=http://mirror.centos.org/centos-vault|g' ${SYSTEM_CENTOS}-*
+ # 原 centos 镜像中的 CentOS 8 相关内容已被官方移动,从 2022-02 开始切换至 centos-vault 源
+ if [ ${SYSTEM_VERSION_NUMBER} -eq "8" ]; then
+ sed -i 's|mirror.centos.org/$contentdir|mirror.centos.org/centos-vault|g' ${SYSTEM_CENTOS}-*
sed -i "s/\$releasever/8.5.2111/g" ${SYSTEM_CENTOS}-*
fi
- ## WEB协议
+ # 更换 WEB 协议(HTTP/HTTPS)
sed -i "s|^#baseurl=http|baseurl=${WEB_PROTOCOL}|g" ${SYSTEM_CENTOS}-*
- ## 更换软件源
+ # 更换软件源
sed -i "s|mirror.centos.org|${SOURCE}|g" ${SYSTEM_CENTOS}-*
- ## Red Hat Enterprise Linux 修改版本号
- if [ ${SYSTEM_JUDGMENT} = ${SYSTEM_RHEL} ]; then
- if [ ${CENTOS_VERSION} -eq "8" ]; then
+ # Red Hat Enterprise Linux 修改版本号
+ if [ "${SYSTEM_JUDGMENT}" = ${SYSTEM_RHEL} ]; then
+ case ${SYSTEM_VERSION_NUMBER} in
+ 8)
sed -i "s/\$releasever/8.5.2111/g" ${SYSTEM_CENTOS}-*
- elif [ ${CENTOS_VERSION} -eq "7" ]; then
+ ;;
+ 7)
sed -i "s/\$releasever/7/g" ${SYSTEM_CENTOS}-*
- fi
+ ;;
+ esac
fi
## 安装/更换基于 RHEL/CentOS 的 EPEL 扩展国内源
[ ${EPEL_INSTALL} = "True" ] && EPELMirrors
- elif [ ${SYSTEM_JUDGMENT} = ${SYSTEM_FEDORA} ]; then
+ ;;
+ "CentOS Stream")
+ case ${SYSTEM_VERSION_NUMBER} in
+ 9)
+ sed -i 's|^mirrorlist=|#mirrorlist=|g' centos*
+
+ # 更换 WEB 协议(HTTP/HTTPS)
+ sed -i "s|^#baseurl=http|baseurl=${WEB_PROTOCOL}|g" centos*
+ # 更换软件源
+ sed -i "s|mirror.centos.org|${SOURCE}|g" centos*
+ ;;
+ 8)
+ sed -i 's|^mirrorlist=|#mirrorlist=|g' ${SYSTEM_CENTOS}-*
+ sed -i 's|vault.centos.org/$contentdir|mirror.centos.org/centos-vault|g' ${SYSTEM_CENTOS}-* # 单独处理 CentOS-Stream-Sources.repo
+
+ # 更换 WEB 协议(HTTP/HTTPS)
+ sed -i "s|^#baseurl=http|baseurl=${WEB_PROTOCOL}|g" ${SYSTEM_CENTOS}-*
+ # 更换软件源
+ sed -i "s|mirror.centos.org|${SOURCE}|g" ${SYSTEM_CENTOS}-*
+ ;;
+ esac
+
+ ## 安装/更换基于 RHEL/CentOS 的 EPEL 扩展国内源
+ [ ${EPEL_INSTALL} = "True" ] && EPELMirrors
+ ;;
+ Fedora)
sed -i 's|^metalink=|#metalink=|g' \
- ${SOURCE_BRANCH}.repo \
- ${SOURCE_BRANCH}-updates.repo \
- ${SOURCE_BRANCH}-modular.repo \
- ${SOURCE_BRANCH}-updates-modular.repo \
- ${SOURCE_BRANCH}-updates-testing.repo \
- ${SOURCE_BRANCH}-updates-testing-modular.repo
+ fedora.repo \
+ fedora-updates.repo \
+ fedora-modular.repo \
+ fedora-updates-modular.repo \
+ fedora-updates-testing.repo \
+ fedora-updates-testing-modular.repo
+
+ # 更换 WEB 协议(HTTP/HTTPS)
sed -i "s|^#baseurl=http|baseurl=${WEB_PROTOCOL}|g" fedora*
+
+ # 更换软件源
sed -i "s|download.example/pub/fedora/linux|${SOURCE}/fedora|g" \
fedora.repo \
- ${SOURCE_BRANCH}-updates.repo \
- ${SOURCE_BRANCH}-modular.repo \
- ${SOURCE_BRANCH}-updates-modular.repo \
- ${SOURCE_BRANCH}-updates-testing.repo \
- ${SOURCE_BRANCH}-updates-testing-modular.repo
- fi
+ fedora-updates.repo \
+ fedora-modular.repo \
+ fedora-updates-modular.repo \
+ fedora-updates-testing.repo \
+ fedora-updates-testing-modular.repo
+ ;;
+ esac
+
## 清理 yum 缓存
yum clean all >/dev/null 2>&1
}
@@ -456,33 +501,44 @@ function EPELMirrors() {
## 安装 EPEL 软件包
if [ ${VERIFICATION_EPEL} -ne 0 ]; then
echo -e "\n${WORKING} 安装 epel-release 软件包...\n"
- yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-${CENTOS_VERSION}.noarch.rpm
+ yum install -y https://mirrors.cloud.tencent.com/epel/epel-release-latest-${SYSTEM_VERSION_NUMBER}.noarch.rpm
fi
## 删除原有 EPEL 扩展 repo 源文件
- [ ${VERIFICATION_EPELFILES} -eq 0 ] && rm -rf $RedHatReposDir/epel*
- [ ${VERIFICATION_EPELBACKUPFILES} -eq 0 ] && rm -rf $RedHatReposDirBackup/epel*
+ [ ${VERIFICATION_EPELFILES} -eq 0 ] && rm -rf $Dir_RedHatRepos/epel*
+ [ ${VERIFICATION_EPELBACKUPFILES} -eq 0 ] && rm -rf $Dir_RedHatReposBackup/epel*
## 生成官方 EPEL 扩展 repo 源文件
EPELReposCreate
- ## 更换国内源
- sed -i 's|^metalink=|#metalink=|g' $RedHatReposDir/epel*
- case ${CENTOS_VERSION} in
- 8)
- sed -i "s|^#baseurl=https|baseurl=${WEB_PROTOCOL}|g" $RedHatReposDir/epel*
+
+ sed -i 's|^metalink=|#metalink=|g' $Dir_RedHatRepos/epel*
+
+ # 更换 WEB 协议(HTTP/HTTPS)
+ case ${SYSTEM_VERSION_NUMBER} in
+ 9 | 8)
+ sed -i "s|^#baseurl=https|baseurl=${WEB_PROTOCOL}|g" $Dir_RedHatRepos/epel*
;;
7)
- sed -i "s|^#baseurl=http|baseurl=${WEB_PROTOCOL}|g" $RedHatReposDir/epel*
+ sed -i "s|^#baseurl=http|baseurl=${WEB_PROTOCOL}|g" $Dir_RedHatRepos/epel*
;;
esac
- sed -i "s|download.fedoraproject.org/pub|${SOURCE}|g" $RedHatReposDir/epel*
- rm -rf $RedHatReposDir/epel*rpmnew
+ # 修改源
+ case ${SYSTEM_VERSION_NUMBER} in
+ 9)
+ sed -i "s|download.example/pub|${SOURCE}|g" $Dir_RedHatRepos/epel*
+ ;;
+ 8 | 7)
+ sed -i "s|download.fedoraproject.org/pub|${SOURCE}|g" $Dir_RedHatRepos/epel*
+ ;;
+ esac
+
+ rm -rf $Dir_RedHatRepos/epel*rpmnew
}
## 选择国内源
function ChooseMirrors() {
## 云计算厂商的软件源
- ## 分外网(公网)地址和内网地址,内网地址仅面向云计算厂商云服务器用户使用
- ## 内网地址不支持使用 HTTPS 协议
+ # 分外网(公网)地址和内网地址,内网地址仅面向云计算厂商云服务器用户使用
+ # 内网地址不支持使用 HTTPS 协议
function Cloud_Computing_Vendors_Mirrors() {
local Extranet Intranet
## 公网地址
@@ -530,21 +586,15 @@ function ChooseMirrors() {
}
clear
- echo -e '+---------------------------------------------------+'
- echo -e '| |'
- echo -e '| ============================================= |'
- echo -e '| |'
- echo -e '| 欢迎使用 Linux 一键更换国内软件源脚本 |'
- echo -e '| |'
- echo -e '| ============================================= |'
- echo -e '| |'
- echo -e '+---------------------------------------------------+'
- echo -e ''
- echo -e '#####################################################'
- echo -e ''
- echo -e ' 提供以下国内软件源可供选择:'
- echo -e ''
- echo -e '#####################################################'
+ echo -e '+-----------------------------------------------+'
+ echo -e '| |'
+ echo -e '| ========================================= |'
+ echo -e '| |'
+ echo -e '| 欢迎使用 Linux 一键更换国内软件源脚本 |'
+ echo -e '| |'
+ echo -e '| ========================================= |'
+ echo -e '| |'
+ echo -e '+-----------------------------------------------+'
echo -e ''
echo -e ' ❖ 阿里云 1)'
echo -e ' ❖ 腾讯云 2)'
@@ -560,12 +610,8 @@ function ChooseMirrors() {
echo -e ' ❖ 哈尔滨工业大学 12)'
echo -e ' ❖ 中国科学技术大学 13)'
echo -e ''
- echo -e '#####################################################'
- echo -e ''
- echo -e " 运行环境 ${BLUE}${SYSTEM_NAME} ${SYSTEM_VERSION_NUMBER} ${SYSTEM_ARCH}${PLAIN}"
- echo -e " 系统时间 ${BLUE}$(date "+%Y-%m-%d %H:%M:%S")${PLAIN}"
- echo -e ''
- echo -e '#####################################################'
+ echo -e " 运行环境 ${BLUE}${SYSTEM_NAME} ${SYSTEM_VERSION_NUMBER} ${SYSTEM_ARCH}${PLAIN}"
+ echo -e " 系统时间 ${BLUE}$(date "+%Y-%m-%d %H:%M:%S")${PLAIN}"
CHOICE_A=$(echo -e "\n${BOLD}└─ 请选择并输入你想使用的软件源 [ 1-13 ]:${PLAIN}")
read -p "${CHOICE_A}" INPUT
case $INPUT in
@@ -610,15 +656,15 @@ function ChooseMirrors() {
esac
## 更换基于 RHEL/CentOS 的 EPEL (Extra Packages for Enterprise Linux) 扩展国内源
- if [ ${SYSTEM_JUDGMENT} = ${SYSTEM_CENTOS} -o ${SYSTEM_JUDGMENT} = ${SYSTEM_RHEL} ]; then
+ if [[ "${SYSTEM_JUDGMENT}" = ${SYSTEM_CENTOS} || "${SYSTEM_JUDGMENT}" = ${SYSTEM_RHEL} || "${SYSTEM_JUDGMENT}" = ${SYSTEM_CENTOS_STREAM} ]]; then
## 判断是否已安装 EPEL 软件包
rpm -qa | grep epel-release -q
VERIFICATION_EPEL=$?
## 判断 /etc/yum.repos.d 目录下是否存在 epel 扩展 repo 源文件
- [ -d $RedHatReposDir ] && ls $RedHatReposDir | grep epel -q
+ [ -d $Dir_RedHatRepos ] && ls $Dir_RedHatRepos | grep epel -q
VERIFICATION_EPELFILES=$?
## 判断 /etc/yum.repos.d.bak 目录下是否存在 epel 扩展 repo 源文件
- [ -d $RedHatReposDirBackup ] && ls $RedHatReposDirBackup | grep epel -q
+ [ -d $Dir_RedHatReposBackup ] && ls $Dir_RedHatReposBackup | grep epel -q
VERIFICATION_EPELBACKUPFILES=$?
if [ ${VERIFICATION_EPEL} -eq 0 ]; then
@@ -668,13 +714,14 @@ function ChooseMirrors() {
}
## 生成 CentOS 官方 repo 源文件
-function CreateCentOSRepoFiles() {
- if [ ${CENTOS_VERSION} -eq "8" ]; then
- CentOS8_RepoFiles='CentOS-Linux-AppStream.repo CentOS-Linux-BaseOS.repo CentOS-Linux-ContinuousRelease.repo CentOS-Linux-Debuginfo.repo CentOS-Linux-Devel.repo CentOS-Linux-Extras.repo CentOS-Linux-FastTrack.repo CentOS-Linux-HighAvailability.repo CentOS-Linux-Media.repo CentOS-Linux-Plus.repo CentOS-Linux-PowerTools.repo CentOS-Linux-Sources.repo'
+function GenRepoFiles_CentOS() {
+ case ${SYSTEM_VERSION_NUMBER} in
+ 8)
+ local CentOS8_RepoFiles="CentOS-Linux-AppStream.repo CentOS-Linux-BaseOS.repo CentOS-Linux-ContinuousRelease.repo CentOS-Linux-Debuginfo.repo CentOS-Linux-Devel.repo CentOS-Linux-Extras.repo CentOS-Linux-FastTrack.repo CentOS-Linux-HighAvailability.repo CentOS-Linux-Media.repo CentOS-Linux-Plus.repo CentOS-Linux-PowerTools.repo CentOS-Linux-Sources.repo"
for REPOS in $CentOS8_RepoFiles; do
touch $REPOS
done
- cat >$RedHatReposDir/${SYSTEM_CENTOS}-Linux-AppStream.repo <<\EOF
+ cat >$Dir_RedHatRepos/${SYSTEM_CENTOS}-Linux-AppStream.repo <<\EOF
# CentOS-Linux-AppStream.repo
#
# The mirrorlist system uses the connecting IP address of the client and the
@@ -693,7 +740,7 @@ gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
EOF
- cat >$RedHatReposDir/${SYSTEM_CENTOS}-Linux-BaseOS.repo <<\EOF
+ cat >$Dir_RedHatRepos/${SYSTEM_CENTOS}-Linux-BaseOS.repo <<\EOF
# CentOS-Linux-BaseOS.repo
#
# The mirrorlist system uses the connecting IP address of the client and the
@@ -712,7 +759,7 @@ gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
EOF
- cat >$RedHatReposDir/${SYSTEM_CENTOS}-Linux-ContinuousRelease.repo <<\EOF
+ cat >$Dir_RedHatRepos/${SYSTEM_CENTOS}-Linux-ContinuousRelease.repo <<\EOF
# CentOS-Linux-ContinuousRelease.repo
#
# The mirrorlist system uses the connecting IP address of the client and the
@@ -738,7 +785,7 @@ gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
EOF
- cat >$RedHatReposDir/${SYSTEM_CENTOS}-Linux-Debuginfo.repo <<\EOF
+ cat >$Dir_RedHatRepos/${SYSTEM_CENTOS}-Linux-Debuginfo.repo <<\EOF
# CentOS-Linux-Debuginfo.repo
#
# All debug packages are merged into a single repo, split by basearch, and are
@@ -751,7 +798,7 @@ gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
EOF
- cat >$RedHatReposDir/${SYSTEM_CENTOS}-Linux-Devel.repo <<\EOF
+ cat >$Dir_RedHatRepos/${SYSTEM_CENTOS}-Linux-Devel.repo <<\EOF
# CentOS-Linux-Devel.repo
#
# The mirrorlist system uses the connecting IP address of the client and the
@@ -770,7 +817,7 @@ gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
EOF
- cat >$RedHatReposDir/${SYSTEM_CENTOS}-Linux-Extras.repo <<\EOF
+ cat >$Dir_RedHatRepos/${SYSTEM_CENTOS}-Linux-Extras.repo <<\EOF
# CentOS-Linux-Extras.repo
#
# The mirrorlist system uses the connecting IP address of the client and the
@@ -789,7 +836,7 @@ gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
EOF
- cat >$RedHatReposDir/${SYSTEM_CENTOS}-Linux-FastTrack.repo <<\EOF
+ cat >$Dir_RedHatRepos/${SYSTEM_CENTOS}-Linux-FastTrack.repo <<\EOF
# CentOS-Linux-FastTrack.repo
#
# The mirrorlist system uses the connecting IP address of the client and the
@@ -808,7 +855,7 @@ gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
EOF
- cat >$RedHatReposDir/${SYSTEM_CENTOS}-Linux-HighAvailability.repo <<\EOF
+ cat >$Dir_RedHatRepos/${SYSTEM_CENTOS}-Linux-HighAvailability.repo <<\EOF
# CentOS-Linux-HighAvailability.repo
#
# The mirrorlist system uses the connecting IP address of the client and the
@@ -827,7 +874,7 @@ gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
EOF
- cat >$RedHatReposDir/${SYSTEM_CENTOS}-Linux-Media.repo <<\EOF
+ cat >$Dir_RedHatRepos/${SYSTEM_CENTOS}-Linux-Media.repo <<\EOF
# CentOS-Linux-Media.repo
#
# You can use this repo to install items directly off the installation media.
@@ -851,7 +898,7 @@ gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
EOF
- cat >$RedHatReposDir/${SYSTEM_CENTOS}-Linux-Plus.repo <<\EOF
+ cat >$Dir_RedHatRepos/${SYSTEM_CENTOS}-Linux-Plus.repo <<\EOF
# CentOS-Linux-Plus.repo
#
# The mirrorlist system uses the connecting IP address of the client and the
@@ -870,7 +917,7 @@ gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
EOF
- cat >$RedHatReposDir/${SYSTEM_CENTOS}-Linux-PowerTools.repo <<\EOF
+ cat >$Dir_RedHatRepos/${SYSTEM_CENTOS}-Linux-PowerTools.repo <<\EOF
# CentOS-Linux-PowerTools.repo
#
# The mirrorlist system uses the connecting IP address of the client and the
@@ -889,7 +936,7 @@ gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
EOF
- cat >$RedHatReposDir/${SYSTEM_CENTOS}-Linux-Sources.repo <<\EOF
+ cat >$Dir_RedHatRepos/${SYSTEM_CENTOS}-Linux-Sources.repo <<\EOF
# CentOS-Linux-Sources.repo
@@ -921,12 +968,13 @@ gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
EOF
- elif [ ${CENTOS_VERSION} -eq "7" ]; then
- CentOS7_RepoFiles='CentOS-Base.repo CentOS-CR.repo CentOS-Debuginfo.repo CentOS-fasttrack.repo CentOS-Media.repo CentOS-Sources.repo CentOS-Vault.repo'
+ ;;
+ 7)
+ local CentOS7_RepoFiles="CentOS-Base.repo CentOS-CR.repo CentOS-Debuginfo.repo CentOS-fasttrack.repo CentOS-Media.repo CentOS-Sources.repo CentOS-Vault.repo"
for REPOS in $CentOS7_RepoFiles; do
touch $REPOS
done
- cat >$RedHatReposDir/${SYSTEM_CENTOS}-Base.repo <<\EOF
+ cat >$Dir_RedHatRepos/${SYSTEM_CENTOS}-Base.repo <<\EOF
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
@@ -971,7 +1019,7 @@ gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
EOF
- cat >$RedHatReposDir/${SYSTEM_CENTOS}-CR.repo <<\EOF
+ cat >$Dir_RedHatRepos/${SYSTEM_CENTOS}-CR.repo <<\EOF
# CentOS-CR.repo
#
# The Continuous Release ( CR ) repository contains rpms that are due in the next
@@ -1001,7 +1049,7 @@ gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
enabled=0
EOF
- cat >$RedHatReposDir/${SYSTEM_CENTOS}-Debuginfo.repo <<\EOF
+ cat >$Dir_RedHatRepos/${SYSTEM_CENTOS}-Debuginfo.repo <<\EOF
# CentOS-Debug.repo
#
# The mirror system uses the connecting IP address of the client and the
@@ -1024,7 +1072,7 @@ gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Debug-7
enabled=0
#
EOF
- cat >$RedHatReposDir/${SYSTEM_CENTOS}-fasttrack.repo <<\EOF
+ cat >$Dir_RedHatRepos/${SYSTEM_CENTOS}-fasttrack.repo <<\EOF
[fasttrack]
name=CentOS-7 - fasttrack
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=fasttrack&infra=$infra
@@ -1033,7 +1081,7 @@ gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
EOF
- cat >$RedHatReposDir/${SYSTEM_CENTOS}-Media.repo <<\EOF
+ cat >$Dir_RedHatRepos/${SYSTEM_CENTOS}-Media.repo <<\EOF
# CentOS-Media.repo
#
# This repo can be used with mounted DVD media, verify the mount point for
@@ -1056,7 +1104,7 @@ gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
EOF
- cat >$RedHatReposDir/${SYSTEM_CENTOS}-Sources.repo <<\EOF
+ cat >$Dir_RedHatRepos/${SYSTEM_CENTOS}-Sources.repo <<\EOF
# CentOS-Sources.repo
#
# The mirror system uses the connecting IP address of the client and the
@@ -1100,16 +1148,521 @@ gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
EOF
- fi
+ ;;
+ esac
+}
+
+## 生成 CentOS Stream 官方 repo 源文件
+function GenRepoFiles_CentOSStream() {
+ case ${SYSTEM_VERSION_NUMBER} in
+ 9)
+ local CentOSStream9_RepoFiles="centos-addons.repo centos.repo"
+ for REPOS in $CentOSStream9_RepoFiles; do
+ touch $REPOS
+ done
+ cat >$Dir_RedHatRepos/centos-addons.repo <<\EOF
+[highavailability]
+name=CentOS Stream $releasever - HighAvailability
+metalink=https://mirrors.centos.org/metalink?repo=centos-highavailability-$stream&arch=$basearch&protocol=https,http
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
+gpgcheck=1
+repo_gpgcheck=0
+metadata_expire=6h
+countme=1
+enabled=0
+
+[highavailability-debug]
+name=CentOS Stream $releasever - HighAvailability - Debug
+metalink=https://mirrors.centos.org/metalink?repo=centos-highavailability-debug-$stream&arch=$basearch&protocol=https,http
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
+gpgcheck=1
+repo_gpgcheck=0
+metadata_expire=6h
+enabled=0
+
+[highavailability-source]
+name=CentOS Stream $releasever - HighAvailability - Source
+metalink=https://mirrors.centos.org/metalink?repo=centos-highavailability-source-$stream&arch=source&protocol=https,http
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
+gpgcheck=1
+repo_gpgcheck=0
+metadata_expire=6h
+enabled=0
+
+[nfv]
+name=CentOS Stream $releasever - NFV
+metalink=https://mirrors.centos.org/metalink?repo=centos-nfv-$stream&arch=$basearch&protocol=https,http
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
+gpgcheck=1
+repo_gpgcheck=0
+metadata_expire=6h
+countme=1
+enabled=0
+
+[nfv-debug]
+name=CentOS Stream $releasever - NFV - Debug
+metalink=https://mirrors.centos.org/metalink?repo=centos-nfv-debug-$stream&arch=$basearch&protocol=https,http
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
+gpgcheck=1
+repo_gpgcheck=0
+metadata_expire=6h
+enabled=0
+
+[nfv-source]
+name=CentOS Stream $releasever - NFV - Source
+metalink=https://mirrors.centos.org/metalink?repo=centos-nfv-source-$stream&arch=source&protocol=https,http
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
+gpgcheck=1
+repo_gpgcheck=0
+metadata_expire=6h
+enabled=0
+
+[rt]
+name=CentOS Stream $releasever - RT
+metalink=https://mirrors.centos.org/metalink?repo=centos-rt-$stream&arch=$basearch&protocol=https,http
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
+gpgcheck=1
+repo_gpgcheck=0
+metadata_expire=6h
+countme=1
+enabled=0
+
+[rt-debug]
+name=CentOS Stream $releasever - RT - Debug
+metalink=https://mirrors.centos.org/metalink?repo=centos-rt-debug-$stream&arch=$basearch&protocol=https,http
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
+gpgcheck=1
+repo_gpgcheck=0
+metadata_expire=6h
+enabled=0
+
+[rt-source]
+name=CentOS Stream $releasever - RT - Source
+metalink=https://mirrors.centos.org/metalink?repo=centos-rt-source-$stream&arch=source&protocol=https,http
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
+gpgcheck=1
+repo_gpgcheck=0
+metadata_expire=6h
+enabled=0
+
+[resilientstorage]
+name=CentOS Stream $releasever - ResilientStorage
+metalink=https://mirrors.centos.org/metalink?repo=centos-resilientstorage-$stream&arch=$basearch&protocol=https,http
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
+gpgcheck=1
+repo_gpgcheck=0
+metadata_expire=6h
+countme=1
+enabled=0
+
+[resilientstorage-debug]
+name=CentOS Stream $releasever - ResilientStorage - Debug
+metalink=https://mirrors.centos.org/metalink?repo=centos-resilientstorage-debug-$stream&arch=$basearch&protocol=https,http
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
+gpgcheck=1
+repo_gpgcheck=0
+metadata_expire=6h
+enabled=0
+
+[resilientstorage-source]
+name=CentOS Stream $releasever - ResilientStorage - Source
+metalink=https://mirrors.centos.org/metalink?repo=centos-resilientstorage-source-$stream&arch=source&protocol=https,http
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
+gpgcheck=1
+repo_gpgcheck=0
+metadata_expire=6h
+enabled=0
+
+[extras-common]
+name=CentOS Stream $releasever - Extras packages
+metalink=https://mirrors.centos.org/metalink?repo=centos-extras-sig-extras-common-$stream&arch=$basearch&protocol=https,http
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Extras-SHA512
+gpgcheck=1
+repo_gpgcheck=0
+metadata_expire=6h
+countme=1
+enabled=1
+
+[extras-common-source]
+name=CentOS Stream $releasever - Extras packages - Source
+metalink=https://mirrors.centos.org/metalink?repo=centos-extras-sig-extras-common-source-$stream&arch=source&protocol=https,http
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Extras-SHA512
+gpgcheck=1
+repo_gpgcheck=0
+metadata_expire=6h
+enabled=0
+EOF
+
+ cat >$Dir_RedHatRepos/centos.repo <<\EOF
+[baseos]
+name=CentOS Stream $releasever - BaseOS
+metalink=https://mirrors.centos.org/metalink?repo=centos-baseos-$stream&arch=$basearch&protocol=https,http
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
+gpgcheck=1
+repo_gpgcheck=0
+metadata_expire=6h
+countme=1
+enabled=1
+
+[baseos-debug]
+name=CentOS Stream $releasever - BaseOS - Debug
+metalink=https://mirrors.centos.org/metalink?repo=centos-baseos-debug-$stream&arch=$basearch&protocol=https,http
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
+gpgcheck=1
+repo_gpgcheck=0
+metadata_expire=6h
+enabled=0
+
+[baseos-source]
+name=CentOS Stream $releasever - BaseOS - Source
+metalink=https://mirrors.centos.org/metalink?repo=centos-baseos-source-$stream&arch=source&protocol=https,http
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
+gpgcheck=1
+repo_gpgcheck=0
+metadata_expire=6h
+enabled=0
+
+[appstream]
+name=CentOS Stream $releasever - AppStream
+metalink=https://mirrors.centos.org/metalink?repo=centos-appstream-$stream&arch=$basearch&protocol=https,http
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
+gpgcheck=1
+repo_gpgcheck=0
+metadata_expire=6h
+countme=1
+enabled=1
+
+[appstream-debug]
+name=CentOS Stream $releasever - AppStream - Debug
+metalink=https://mirrors.centos.org/metalink?repo=centos-appstream-debug-$stream&arch=$basearch&protocol=https,http
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
+gpgcheck=1
+repo_gpgcheck=0
+metadata_expire=6h
+enabled=0
+
+[appstream-source]
+name=CentOS Stream $releasever - AppStream - Source
+metalink=https://mirrors.centos.org/metalink?repo=centos-appstream-source-$stream&arch=source&protocol=https,http
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
+gpgcheck=1
+repo_gpgcheck=0
+metadata_expire=6h
+enabled=0
+
+[crb]
+name=CentOS Stream $releasever - CRB
+metalink=https://mirrors.centos.org/metalink?repo=centos-crb-$stream&arch=$basearch&protocol=https,http
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
+gpgcheck=1
+repo_gpgcheck=0
+metadata_expire=6h
+countme=1
+enabled=0
+
+[crb-debug]
+name=CentOS Stream $releasever - CRB - Debug
+metalink=https://mirrors.centos.org/metalink?repo=centos-crb-debug-$stream&arch=$basearch&protocol=https,http
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
+gpgcheck=1
+repo_gpgcheck=0
+metadata_expire=6h
+enabled=0
+
+[crb-source]
+name=CentOS Stream $releasever - CRB - Source
+metalink=https://mirrors.centos.org/metalink?repo=centos-crb-source-$stream&arch=source&protocol=https,http
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
+gpgcheck=1
+repo_gpgcheck=0
+metadata_expire=6h
+enabled=0
+EOF
+ ;;
+ 8)
+ local CentOSStream8_RepoFiles="CentOS-Stream-AppStream.repo CentOS-Stream-BaseOS.repo CentOS-Stream-Debuginfo.repo CentOS-Stream-Extras-common.repo CentOS-Stream-Extras.repo CentOS-Stream-HighAvailability.repo CentOS-Stream-Media.repo CentOS-Stream-NFV.repo CentOS-Stream-PowerTools.repo CentOS-Stream-RealTime.repo CentOS-Stream-ResilientStorage.repo CentOS-Stream-Sources.repo"
+ for REPOS in $CentOSStream8_RepoFiles; do
+ touch $REPOS
+ done
+
+ cat >$Dir_RedHatRepos/${SYSTEM_CENTOS}-Stream-AppStream.repo <<\EOF
+# CentOS-Stream-AppStream.repo
+#
+# The mirrorlist system uses the connecting IP address of the client and the
+# update status of each mirror to pick current mirrors that are geographically
+# close to the client. You should use this for CentOS updates unless you are
+# manually picking other mirrors.
+#
+# If the mirrorlist does not work for you, you can try the commented out
+# baseurl line instead.
+
+[appstream]
+name=CentOS Stream $releasever - AppStream
+mirrorlist=http://mirrorlist.centos.org/?release=$stream&arch=$basearch&repo=AppStream&infra=$infra
+#baseurl=http://mirror.centos.org/$contentdir/$stream/AppStream/$basearch/os/
+gpgcheck=1
+enabled=1
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
+EOF
+ cat >$Dir_RedHatRepos/${SYSTEM_CENTOS}-Stream-BaseOS.repo <<\EOF
+# CentOS-Stream-BaseOS.repo
+#
+# The mirrorlist system uses the connecting IP address of the client and the
+# update status of each mirror to pick current mirrors that are geographically
+# close to the client. You should use this for CentOS updates unless you are
+# manually picking other mirrors.
+#
+# If the mirrorlist does not work for you, you can try the commented out
+# baseurl line instead.
+
+[baseos]
+name=CentOS Stream $releasever - BaseOS
+mirrorlist=http://mirrorlist.centos.org/?release=$stream&arch=$basearch&repo=BaseOS&infra=$infra
+#baseurl=http://mirror.centos.org/$contentdir/$stream/BaseOS/$basearch/os/
+gpgcheck=1
+enabled=1
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
+EOF
+ cat >$Dir_RedHatRepos/${SYSTEM_CENTOS}-Stream-Debuginfo.repo <<\EOF
+# CentOS-Stream-Debuginfo.repo
+#
+# All debug packages are merged into a single repo, split by basearch, and are
+# not signed.
+
+[debuginfo]
+name=CentOS Stream $releasever - Debuginfo
+baseurl=http://debuginfo.centos.org/$stream/$basearch/
+gpgcheck=1
+enabled=0
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
+EOF
+ cat >$Dir_RedHatRepos/${SYSTEM_CENTOS}-Stream-Extras-common.repo <<\EOF
+# CentOS-Stream-Extras-common.repo
+#
+# The mirrorlist system uses the connecting IP address of the client and the
+# update status of each mirror to pick current mirrors that are geographically
+# close to the client. You should use this for CentOS updates unless you are
+# manually picking other mirrors.
+#
+# If the mirrorlist does not work for you, you can try the commented out
+# baseurl line instead.
+
+[extras-common]
+name=CentOS Stream $releasever - Extras common packages
+mirrorlist=http://mirrorlist.centos.org/?release=$stream&arch=$basearch&repo=extras-extras-common
+#baseurl=http://mirror.centos.org/$contentdir/$stream/extras/$basearch/extras-common/
+gpgcheck=1
+enabled=1
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-Extras
+EOF
+ cat >$Dir_RedHatRepos/${SYSTEM_CENTOS}-Stream-Extras.repo <<\EOF
+# CentOS-Stream-Extras.repo
+#
+# The mirrorlist system uses the connecting IP address of the client and the
+# update status of each mirror to pick current mirrors that are geographically
+# close to the client. You should use this for CentOS updates unless you are
+# manually picking other mirrors.
+#
+# If the mirrorlist does not work for you, you can try the commented out
+# baseurl line instead.
+
+[extras]
+name=CentOS Stream $releasever - Extras
+mirrorlist=http://mirrorlist.centos.org/?release=$stream&arch=$basearch&repo=extras&infra=$infra
+#baseurl=http://mirror.centos.org/$contentdir/$stream/extras/$basearch/os/
+gpgcheck=1
+enabled=1
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
+EOF
+ cat >$Dir_RedHatRepos/${SYSTEM_CENTOS}-Stream-HighAvailability.repo <<\EOF
+# CentOS-Stream-HighAvailability.repo
+#
+# The mirrorlist system uses the connecting IP address of the client and the
+# update status of each mirror to pick current mirrors that are geographically
+# close to the client. You should use this for CentOS updates unless you are
+# manually picking other mirrors.
+#
+# If the mirrorlist does not work for you, you can try the commented out
+# baseurl line instead.
+
+[ha]
+name=CentOS Stream $releasever - HighAvailability
+mirrorlist=http://mirrorlist.centos.org/?release=$stream&arch=$basearch&repo=HighAvailability&infra=$infra
+#baseurl=http://mirror.centos.org/$contentdir/$stream/HighAvailability/$basearch/os/
+gpgcheck=1
+enabled=0
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
+EOF
+ cat >$Dir_RedHatRepos/${SYSTEM_CENTOS}-Stream-Media.repo <<\EOF
+# CentOS-Stream-Media.repo
+#
+# You can use this repo to install items directly off the installation media.
+# Verify your mount point matches one of the below file:// paths.
+
+[media-baseos]
+name=CentOS Stream $releasever - Media - BaseOS
+baseurl=file:///media/CentOS/BaseOS
+ file:///media/cdrom/BaseOS
+ file:///media/cdrecorder/BaseOS
+gpgcheck=1
+enabled=0
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
+
+[media-appstream]
+name=CentOS Stream $releasever - Media - AppStream
+baseurl=file:///media/CentOS/AppStream
+ file:///media/cdrom/AppStream
+ file:///media/cdrecorder/AppStream
+gpgcheck=1
+enabled=0
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
+EOF
+ cat >$Dir_RedHatRepos/${SYSTEM_CENTOS}-Stream-NFV.repo <<\EOF
+# CentOS-Stream-NFV.repo
+#
+# The mirrorlist system uses the connecting IP address of the client and the
+# update status of each mirror to pick current mirrors that are geographically
+# close to the client. You should use this for CentOS updates unless you are
+# manually picking other mirrors.
+#
+# If the mirrorlist does not work for you, you can try the commented out
+# baseurl line instead.
+
+[nfv]
+name=CentOS Stream $releasever - NFV
+mirrorlist=http://mirrorlist.centos.org/?release=$stream&arch=$basearch&repo=NFV&infra=$infra
+#baseurl=http://mirror.centos.org/$contentdir/$stream/NFV/$basearch/os/
+gpgcheck=1
+enabled=0
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
+EOF
+ cat >$Dir_RedHatRepos/${SYSTEM_CENTOS}-Stream-PowerTools.repo <<\EOF
+# CentOS-Stream-PowerTools.repo
+#
+# The mirrorlist system uses the connecting IP address of the client and the
+# update status of each mirror to pick current mirrors that are geographically
+# close to the client. You should use this for CentOS updates unless you are
+# manually picking other mirrors.
+#
+# If the mirrorlist does not work for you, you can try the commented out
+# baseurl line instead.
+
+[powertools]
+name=CentOS Stream $releasever - PowerTools
+mirrorlist=http://mirrorlist.centos.org/?release=$stream&arch=$basearch&repo=PowerTools&infra=$infra
+#baseurl=http://mirror.centos.org/$contentdir/$stream/PowerTools/$basearch/os/
+gpgcheck=1
+enabled=0
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
+EOF
+ cat >$Dir_RedHatRepos/${SYSTEM_CENTOS}-Stream-RealTime.repo <<\EOF
+# CentOS-Stream-RealTime.repo
+#
+# The mirrorlist system uses the connecting IP address of the client and the
+# update status of each mirror to pick current mirrors that are geographically
+# close to the client. You should use this for CentOS updates unless you are
+# manually picking other mirrors.
+#
+# If the mirrorlist does not work for you, you can try the commented out
+# baseurl line instead.
+
+[rt]
+name=CentOS Stream $releasever - RealTime
+mirrorlist=http://mirrorlist.centos.org/?release=$stream&arch=$basearch&repo=RT&infra=$infra
+#baseurl=http://mirror.centos.org/$contentdir/$stream/RT/$basearch/os/
+gpgcheck=1
+enabled=0
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
+EOF
+ cat >$Dir_RedHatRepos/${SYSTEM_CENTOS}-Stream-ResilientStorage.repo <<\EOF
+# CentOS-Stream-ResilientStorage.repo
+#
+# The mirrorlist system uses the connecting IP address of the client and the
+# update status of each mirror to pick current mirrors that are geographically
+# close to the client. You should use this for CentOS updates unless you are
+# manually picking other mirrors.
+#
+# If the mirrorlist does not work for you, you can try the commented out
+# baseurl line instead.
+
+[resilientstorage]
+name=CentOS Stream $releasever - ResilientStorage
+mirrorlist=http://mirrorlist.centos.org/?release=$stream&arch=$basearch&repo=ResilientStorage&infra=$infra
+#baseurl=http://mirror.centos.org/$contentdir/$stream/ResilientStorage/$basearch/os/
+gpgcheck=1
+enabled=0
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
+EOF
+ cat >$Dir_RedHatRepos/${SYSTEM_CENTOS}-Stream-Sources.repo <<\EOF
+# CentOS-Stream-Sources.repo
+
+[baseos-source]
+name=CentOS Stream $releasever - BaseOS - Source
+baseurl=http://vault.centos.org/$contentdir/$stream/BaseOS/Source/
+gpgcheck=1
+enabled=0
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
+
+[appstream-source]
+name=CentOS Stream $releasever - AppStream - Source
+baseurl=http://vault.centos.org/$contentdir/$stream/AppStream/Source/
+gpgcheck=1
+enabled=0
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
+
+[powertools-source]
+name=CentOS Stream $releasever - PowerTools - Source
+baseurl=http://vault.centos.org/$contentdir/$stream/PowerTools/Source/
+gpgcheck=1
+enabled=0
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
+
+[extras-source]
+name=CentOS Stream $releasever - Extras - Source
+baseurl=http://vault.centos.org/$contentdir/$stream/extras/Source/
+gpgcheck=1
+enabled=0
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
+
+[ha-source]
+name=CentOS Stream $releasever - HighAvailability - Source
+baseurl=http://vault.centos.org/$contentdir/$stream/HighAvailability/Source/
+gpgcheck=1
+enabled=0
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
+
+[rt-source]
+name=CentOS Stream $releasever - RT - Source
+baseurl=http://vault.centos.org/$contentdir/$stream/RT/Source/
+gpgcheck=1
+enabled=0
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
+
+[resilientstorage-source]
+name=CentOS Stream $releasever - ResilientStorage - Source
+baseurl=http://vault.centos.org/$contentdir/$stream/ResilientStorage/Source/
+gpgcheck=1
+enabled=0
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
+
+[nfv-source]
+name=CentOS Stream $releasever - NFV - Source
+baseurl=http://vault.centos.org/$contentdir/$stream/NFV/Source/
+gpgcheck=1
+enabled=0
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
+EOF
+ ;;
+ esac
}
## 生成 Fedora 官方 repo 源文件
-function CreateReposRepoFiles() {
- Fedora_RepoFiles='fedora-cisco-openh264.repo fedora.repo fedora-updates.repo fedora-modular.repo fedora-updates-modular.repo fedora-updates-testing.repo fedora-updates-testing-modular.repo'
+function GenRepoFiles_Fedora() {
+ local Fedora_RepoFiles="fedora-cisco-openh264.repo fedora.repo fedora-updates.repo fedora-modular.repo fedora-updates-modular.repo fedora-updates-testing.repo fedora-updates-testing-modular.repo"
for REPOS in $Fedora_RepoFiles; do
touch $REPOS
done
- cat >$RedHatReposDir/${SOURCE_BRANCH}-cisco-openh264.repo <<\EOF
+ cat >$Dir_RedHatRepos/fedora-cisco-openh264.repo <<\EOF
[fedora-cisco-openh264]
name=Fedora $releasever openh264 (From Cisco) - $basearch
metalink=https://mirrors.fedoraproject.org/metalink?repo=fedora-cisco-openh264-$releasever&arch=$basearch
@@ -1132,7 +1685,7 @@ gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch
skip_if_unavailable=True
EOF
- cat >$RedHatReposDir/${SOURCE_BRANCH}.repo <<\EOF
+ cat >$Dir_RedHatRepos/fedora.repo <<\EOF
[fedora]
name=Fedora $releasever - $basearch
#baseurl=http://download.example/pub/fedora/linux/releases/$releasever/Everything/$basearch/os/
@@ -1170,7 +1723,7 @@ gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch
skip_if_unavailable=False
EOF
- cat >$RedHatReposDir/${SOURCE_BRANCH}-updates.repo <<\EOF
+ cat >$Dir_RedHatRepos/fedora-updates.repo <<\EOF
[updates]
name=Fedora $releasever - $basearch - Updates
#baseurl=http://download.example/pub/fedora/linux/updates/$releasever/Everything/$basearch/
@@ -1208,7 +1761,7 @@ metadata_expire=6h
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch
skip_if_unavailable=False
EOF
- cat >$RedHatReposDir/${SOURCE_BRANCH}-modular.repo <<\EOF
+ cat >$Dir_RedHatRepos/fedora-modular.repo <<\EOF
[fedora-modular]
name=Fedora Modular $releasever - $basearch
#baseurl=http://download.example/pub/fedora/linux/releases/$releasever/Modular/$basearch/os/
@@ -1246,7 +1799,7 @@ gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch
skip_if_unavailable=False
EOF
- cat >$RedHatReposDir/${SOURCE_BRANCH}-updates-modular.repo <<\EOF
+ cat >$Dir_RedHatRepos/fedora-updates-modular.repo <<\EOF
[updates-modular]
name=Fedora Modular $releasever - $basearch - Updates
#baseurl=http://download.example/pub/fedora/linux/updates/$releasever/Modular/$basearch/
@@ -1284,7 +1837,7 @@ metadata_expire=6h
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch
skip_if_unavailable=False
EOF
- cat >$RedHatReposDir/${SOURCE_BRANCH}-updates-testing.repo <<\EOF
+ cat >$Dir_RedHatRepos/fedora-updates-testing.repo <<\EOF
[updates-testing]
name=Fedora $releasever - $basearch - Test Updates
#baseurl=http://download.example/pub/fedora/linux/updates/testing/$releasever/Everything/$basearch/
@@ -1322,7 +1875,7 @@ metadata_expire=6h
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch
skip_if_unavailable=False
EOF
- cat >$RedHatReposDir/${SOURCE_BRANCH}-updates-testing-modular.repo <<\EOF
+ cat >$Dir_RedHatRepos/fedora-updates-testing-modular.repo <<\EOF
[updates-testing-modular]
name=Fedora Modular $releasever - $basearch - Test Updates
#baseurl=http://download.example/pub/fedora/linux/updates/testing/$releasever/Modular/$basearch/
@@ -1364,13 +1917,85 @@ EOF
## 生成 EPEL 扩展 repo 官方源文件
function EPELReposCreate() {
- cd $RedHatReposDir
- if [ ${CENTOS_VERSION} -eq "8" ]; then
- EPEL8_RepoFiles='epel.repo epel-modular.repo epel-playground.repo epel-testing.repo epel-testing-modular.repo'
+ cd $Dir_RedHatRepos
+
+ case ${SYSTEM_VERSION_NUMBER} in
+ 9)
+ EPEL9_RepoFiles="epel.repo epel-testing.repo"
+ for REPOS in $EPEL9_RepoFiles; do
+ touch $REPOS
+ done
+ cat >$Dir_RedHatRepos/epel.repo <<\EOF
+[epel]
+name=Extra Packages for Enterprise Linux $releasever - $basearch
+# It is much more secure to use the metalink, but if you wish to use a local mirror
+# place its address here.
+#baseurl=https://download.example/pub/epel/$releasever/Everything/$basearch/
+metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-$releasever&arch=$basearch&infra=$infra&content=$contentdir
+enabled=1
+gpgcheck=1
+countme=1
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$releasever
+
+[epel-debuginfo]
+name=Extra Packages for Enterprise Linux $releasever - $basearch - Debug
+# It is much more secure to use the metalink, but if you wish to use a local mirror
+# place its address here.
+#baseurl=https://download.example/pub/epel/$releasever/Everything/$basearch/debug/
+metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-$releasever&arch=$basearch&infra=$infra&content=$contentdir
+enabled=0
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$releasever
+gpgcheck=1
+
+[epel-source]
+name=Extra Packages for Enterprise Linux $releasever - $basearch - Source
+# It is much more secure to use the metalink, but if you wish to use a local mirror
+# place its address here.
+#baseurl=https://download.example/pub/epel/$releasever/Everything/source/tree/
+metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-source-$releasever&arch=$basearch&infra=$infra&content=$contentdir
+enabled=0
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$releasever
+gpgcheck=1
+EOF
+ cat >$Dir_RedHatRepos/epel-testing.repo <<\EOF
+[epel-testing]
+name=Extra Packages for Enterprise Linux $releasever - Testing - $basearch
+# It is much more secure to use the metalink, but if you wish to use a local mirror
+# place its address here.
+#baseurl=https://download.example/pub/epel/testing/$releasever/Everything/$basearch/
+metalink=https://mirrors.fedoraproject.org/metalink?repo=testing-epel$releasever&arch=$basearch&infra=$infra&content=$contentdir
+enabled=0
+gpgcheck=1
+countme=1
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$releasever
+
+[epel-testing-debuginfo]
+name=Extra Packages for Enterprise Linux $releasever - Testing - $basearch - Debug
+# It is much more secure to use the metalink, but if you wish to use a local mirror
+# place its address here.
+#baseurl=https://download.example/pub/epel/testing/$releasever/Everything/$basearch/debug/
+metalink=https://mirrors.fedoraproject.org/metalink?repo=testing-debug-epel$releasever&arch=$basearch&infra=$infra&content=$contentdir
+enabled=0
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$releasever
+gpgcheck=1
+
+[epel-testing-source]
+name=Extra Packages for Enterprise Linux $releasever - Testing - $basearch - Source
+# It is much more secure to use the metalink, but if you wish to use a local mirror
+# place its address here.
+#baseurl=https://download.example/pub/epel/testing/$releasever/Everything/source/tree/
+metalink=https://mirrors.fedoraproject.org/metalink?repo=testing-source-epel$releasever&arch=$basearch&infra=$infra&content=$contentdir
+enabled=0
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$releasever
+gpgcheck=1
+EOF
+ ;;
+ 8)
+ EPEL8_RepoFiles="epel.repo epel-modular.repo epel-playground.repo epel-testing.repo epel-testing-modular.repo"
for REPOS in $EPEL8_RepoFiles; do
touch $REPOS
done
- cat >$RedHatReposDir/epel.repo <<\EOF
+ cat >$Dir_RedHatRepos/epel.repo <<\EOF
[epel]
name=Extra Packages for Enterprise Linux $releasever - $basearch
#baseurl=https://download.fedoraproject.org/pub/epel/8/Everything/$basearch
@@ -1395,7 +2020,7 @@ enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8
gpgcheck=1
EOF
- cat >$RedHatReposDir/epel-modular.repo <<\EOF
+ cat >$Dir_RedHatRepos/epel-modular.repo <<\EOF
[epel-modular]
name=Extra Packages for Enterprise Linux Modular $releasever - $basearch
#baseurl=https://download.fedoraproject.org/pub/epel/8/Modular/$basearch
@@ -1420,7 +2045,7 @@ enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8
gpgcheck=1
EOF
- cat >$RedHatReposDir/epel-playground.repo <<\EOF
+ cat >$Dir_RedHatRepos/epel-playground.repo <<\EOF
[epel-playground]
name=Extra Packages for Enterprise Linux $releasever - Playground - $basearch
#baseurl=https://download.fedoraproject.org/pub/epel/playground/$releasever/Everything/$basearch/os
@@ -1445,7 +2070,7 @@ enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8
gpgcheck=1
EOF
- cat >$RedHatReposDir/epel-testing.repo <<\EOF
+ cat >$Dir_RedHatRepos/epel-testing.repo <<\EOF
[epel-testing]
name=Extra Packages for Enterprise Linux $releasever - Testing - $basearch
#baseurl=https://download.fedoraproject.org/pub/epel/testing/$releasever/Everything/$basearch
@@ -1470,7 +2095,7 @@ enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8
gpgcheck=1
EOF
- cat >$RedHatReposDir/epel-testing-modular.repo <<\EOF
+ cat >$Dir_RedHatRepos/epel-testing-modular.repo <<\EOF
[epel-testing-modular]
name=Extra Packages for Enterprise Linux Modular $releasever - Testing - $basearch
#baseurl=https://download.fedoraproject.org/pub/epel/testing/$releasever/Modular/$basearch
@@ -1495,12 +2120,13 @@ enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8
gpgcheck=1
EOF
- elif [ ${CENTOS_VERSION} -eq "7" ]; then
- EPEL7_RepoFiles='epel.repo epel-testing.repo'
+ ;;
+ 7)
+ EPEL7_RepoFiles="epel.repo epel-testing.repo"
for REPOS in $EPEL7_RepoFiles; do
touch $REPOS
done
- cat >$RedHatReposDir/epel.repo <<\EOF
+ cat >$Dir_RedHatRepos/epel.repo <<\EOF
[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
@@ -1528,7 +2154,7 @@ enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1
EOF
- cat >$RedHatReposDir/epel-testing.repo <<\EOF
+ cat >$Dir_RedHatRepos/epel-testing.repo <<\EOF
[epel-testing]
name=Extra Packages for Enterprise Linux 7 - Testing - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/testing/7/$basearch
@@ -1556,7 +2182,8 @@ enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1
EOF
- fi
+ ;;
+ esac
}
Combin_Function
diff --git a/README.md b/README.md
index 56f3152..989bb36 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,5 @@
# 
-
-
-
- __`GNU/Linux` 一键更换国内软件源脚本__
- __本项目旨在为从事计算机相关行业的朋友们提供便利__
- __理论支持所有架构的环境,ARM 环境已经过测试__
@@ -13,7 +10,7 @@