commit d5549cac0766ccd49273e0c878fd3383b0c3e205 Author: Super Manito <68613938+SuperManito@users.noreply.github.com> Date: Fri Oct 8 00:03:44 2021 +0800 Update diff --git a/.gitee/issue_template.md b/.gitee/issue_template.md new file mode 100644 index 0000000..635ecd6 --- /dev/null +++ b/.gitee/issue_template.md @@ -0,0 +1,45 @@ + + + + +## 1. 处理器架构 + +- [ ] `x86_64` `x86_32` +- [ ] `arm64` `arm/v8` `arm/v7` `arm/v6` +- [ ] `ppc64le` `s390x` +- [ ] `Other` + +## 2. 使用环境 + +- [ ] `Debian` +- [ ] `Ubuntu` +- [ ] `Kali Linux` +- [ ] `Red Hat Enterprise Linux` +- [ ] `CentOS` +- [ ] `Fedora` + +## 3. 使用环境版本 + +A: + +## 4. 详细叙述您的问题 +### (1) 具体问题 +A: + + +### (2) 详细的系统日志 + +A: diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..ca480e1 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,54 @@ +--- +name: Bug report +about: 错误提交 +title: '' +labels: '' +assignees: '' + +--- + + + + + +## 1. 处理器架构 + +- [ ] `x86_64` `x86_32` +- [ ] `arm64` `arm/v8` `arm/v7` `arm/v6` +- [ ] `ppc64le` `s390x` +- [ ] `Other` + +## 2. 使用环境 + +- [ ] `Debian` +- [ ] `Ubuntu` +- [ ] `Kali Linux` +- [ ] `Red Hat Enterprise Linux` +- [ ] `CentOS` +- [ ] `Fedora` + +## 3. 使用环境版本 + +A: + +## 4. 详细叙述您的问题 +### (1) 具体问题 +A: + + +### (2) 详细的系统日志 + +A: diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..ec4bb38 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1 @@ +blank_issues_enabled: false \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..a090227 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,10 @@ +--- +name: Feature request +about: 意见与建议 +title: '' +labels: '' +assignees: '' + +--- + + diff --git a/.github/workflows/auto-sync.yml b/.github/workflows/auto-sync.yml new file mode 100644 index 0000000..7b75d46 --- /dev/null +++ b/.github/workflows/auto-sync.yml @@ -0,0 +1,29 @@ +# 通过 Github actions, 在 Github 仓库的每一次 commit 后自动同步到 Gitee 上 +name: Github > Gitee +on: + push: + branches: + - main +jobs: + repo-sync: + env: + dst_key: ${{ secrets.GITEE_PRIVATE_KEY }} + dst_token: ${{ secrets.GITEE_TOKEN }} + gitee_user: ${{ secrets.GITEE_USER }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + persist-credentials: false + + - name: sync github -> gitee + uses: Yikun/hub-mirror-action@master + if: env.dst_key && env.dst_token && env.gitee_user + with: + + src: github/SuperManito + dst: gitee/SuperManito + dst_key: ${{ secrets.GITEE_PRIVATE_KEY }} + dst_token: ${{ secrets.GITEE_TOKEN }} + static_list: "LinuxMirrors" + force_update: true diff --git a/ChangeMirrors.sh b/ChangeMirrors.sh new file mode 100644 index 0000000..a0fc281 --- /dev/null +++ b/ChangeMirrors.sh @@ -0,0 +1,1483 @@ +#!/bin/env bash +## Author: SuperManito +## Modified: 2021-09-21 +## License: GPL-2.0 +## https://github.com/SuperManito/LinuxMirrors +## https://gitee.com/SuperManito/LinuxMirrors + +function AuthorSignature() { + if [ ${SYSTEM_FACTIONS} = ${SYSTEM_DEBIAN} ]; then + apt-get install -y figlet toilet >/dev/null 2>&1 + elif [ ${SYSTEM_FACTIONS} = ${SYSTEM_REDHAT} ]; then + yum install -y figlet toilet >/dev/null 2>&1 + fi + if [ $? -eq 0 ]; then + echo -e "\n$(toilet -f slant -F border --gay SuperManito)\n" + else + echo -e '\n\033[35m _____ __ ___ _ __ \033[0m' + echo -e '\033[31m / ___/__ ______ ___ _____/ |/ /___ _____ (_) /_____ \033[0m' + echo -e '\033[33m \__ \/ / / / __ \/ _ \/ ___/ /|_/ / __ `/ __ \/ / __/ __ \ \033[0m' + echo -e '\033[32m ___/ / /_/ / /_/ / __/ / / / / / /_/ / / / / / /_/ /_/ / \033[0m' + echo -e '\033[36m /____/\__,_/ .___/\___/_/ /_/ /_/\__,_/_/ /_/_/\__/\____/ \033[0m' + echo -e '\033[34m /_/ \033[0m\n' + fi +} + +## 定义系统判定变量 +DebianRelease=lsb_release +Arch=$(uname -m) +SYSTEM_DEBIAN="Debian" +SYSTEM_UBUNTU="Ubuntu" +SYSTEM_KALI="Kali" +SYSTEM_REDHAT="RedHat" +SYSTEM_RHEL="RedHat" +SYSTEM_CENTOS="CentOS" +SYSTEM_FEDORA="Fedora" + +## 定义目录和文件 +LinuxRelease=/etc/os-release +RedHatRelease=/etc/redhat-release +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 +SelinuxConfig=/etc/selinux/config + +## 组合函数 +function Combin_Function() { + PermissionJudgment && clear + EnvJudgment + ChooseMirrors + BackupMirrors + RemoveOldMirrorsFiles + ChangeMirrors + UpgradeSoftware + AuthorSignature +} + +## 系统判定变量 +function EnvJudgment() { + ## 判定当前系统基于 Debian or RedHat + if [ -f $RedHatRelease ]; then + SYSTEM_FACTIONS=${SYSTEM_REDHAT} + else + SYSTEM_FACTIONS=${SYSTEM_DEBIAN} + fi + ## 定义系统名称 + SYSTEM_NAME=$(cat $LinuxRelease | grep -E "^NAME" | awk -F '\"' '{print$2}') + ## 定义系统版本号 + SYSTEM_VERSION_NUMBER=$(cat $LinuxRelease | grep -E "VERSION_ID" | awk -F '\"' '{print$2}') + ## 判定系统名称、版本、版本号 + case ${SYSTEM_FACTIONS} in + Debian) + SYSTEM_JUDGMENT=$(${DebianRelease} -is) + SYSTEM_VERSION=$(${DebianRelease} -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) + else + CENTOS_VERSION="" + fi + ;; + esac + ## 判定系统处理器架构 + case $Arch in + x86_64) + SYSTEM_ARCH=x86_64 + ;; + aarch64) + SYSTEM_ARCH=ARM64 + ;; + armv7l) + SYSTEM_ARCH=ARMv7 + ;; + armv6l) + SYSTEM_ARCH=ARMv6 + ;; + i686) + SYSTEM_ARCH=x86_32 + ;; + *) + SYSTEM_ARCH=$Arch + ;; + esac + ## 定义软件源分支名称 + 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 + ## 定义软件源同步/更新文字 + case ${SYSTEM_FACTIONS} in + Debian) + SYNC_TXT="更新" + ;; + RedHat) + SYNC_TXT="同步" + ;; + esac +} + +## 环境判定: +function PermissionJudgment() { + ## 权限判定: + if [ $UID -ne 0 ]; then + echo -e '\033[31m -------- Permission no enough, please use user ROOT! ------------ \033[0m' + exit + fi +} + +## 关闭 防火墙 和 SELINUX +function TurnOffFirewall() { + systemctl status firewalld | grep running -q + if [ $? -eq 0 ]; then + CHOICE_C=$(echo -e '\n\033[37m└ 是否关闭防火墙和 SELINUX [ Y/n ]:\033[0m') + read -p "${CHOICE_C}" INPUT + [ -z ${INPUT} ] && INPUT=Y + case $INPUT in + [Yy]*) + systemctl disable --now firewalld >/dev/null 2>&1 + [ -s $SelinuxConfig ] && sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" $SelinuxConfig && setenforce 0 >/dev/null 2>&1 + ;; + [Nn]*) ;; + *) + echo -e '\n\033[33m------------ 输入错误,默认不关闭 ------------\033[0m' + ;; + esac + fi +} + +## 备份原有源 +function BackupMirrors() { + if [ ${SYSTEM_FACTIONS} = ${SYSTEM_DEBIAN} ]; then + ## 判断 /etc/apt/sources.list.d 目录下是否存在文件 + [ -d $DebianExtendListDir ] && ls $DebianExtendListDir | grep *.list -q + VERIFICATION_FILES=$? + ## 判断 /etc/apt/sources.list.d.bak 目录下是否存在文件 + [ -d $DebianExtendListDirBackup ] && ls $DebianExtendListDirBackup | grep *.list -q + VERIFICATION_BACKUPFILES=$? + elif [ ${SYSTEM_FACTIONS} = ${SYSTEM_REDHAT} ]; then + ## 判断 /etc/yum.repos.d 目录下是否存在文件 + [ -d $RedHatReposDir ] && ls $RedHatReposDir | grep repo -q + VERIFICATION_FILES=$? + ## 判断 /etc/yum.repos.d.bak 目录下是否存在文件 + [ -d $RedHatReposDirBackup ] && ls $RedHatReposDirBackup | 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\033[37m└ 检测到系统存在已备份的 list 源文件,是否覆盖备份 [ Y/n ]:\033[0m") + read -p "${CHOICE_BACKUP1}" INPUT + [ -z ${INPUT} ] && INPUT=Y + case $INPUT in + [Yy]*) + echo -e '' + cp -rf $DebianSourceList $DebianSourceListBackup >/dev/null 2>&1 + ;; + [Nn]*) + echo -e '' + ;; + *) + echo -e '\n\033[33m------------ 输入错误,默认不覆盖 ------------\033[0m\n' + ;; + esac + else + cp -rf $DebianSourceList $DebianSourceListBackup >/dev/null 2>&1 + echo -e "\n\033[37m└ 已备份原有 list 源文件至 $DebianSourceListBackup ... \033[0m\n" + sleep 1s + fi + else + [ -f $DebianSourceList ] || touch $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\033[37m└ 检测到系统存在已备份的 list 第三方源文件,是否覆盖备份 [ Y/n ]:\033[0m") + read -p "${CHOICE_BACKUP2}" INPUT + [ -z ${INPUT} ] && INPUT=Y + case $INPUT in + [Yy]*) + cp -rf $DebianExtendListDir/* $DebianExtendListDirBackup >/dev/null 2>&1 + ;; + [Nn]*) + echo '' + ;; + *) + echo -e '\n\033[33m------------ 输入错误,默认不覆盖 ------------\033[0m\n' + ;; + esac + else + [ -d $DebianExtendListDirBackup ] || mkdir -p $DebianExtendListDirBackup + cp -rf $DebianExtendListDir/* $DebianExtendListDirBackup >/dev/null 2>&1 + echo -e "\033[37m└ 已备份原有 list 第三方源文件至 $DebianExtendListDirBackup 目录... \033[0m\n" + 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\033[37m└ 检测到系统存在已备份的 repo 源文件,是否覆盖备份 [ Y/n ]:\033[0m") + read -p "${CHOICE_BACKUP3}" INPUT + [ -z ${INPUT} ] && INPUT=Y + case $INPUT in + [Yy]*) + cp -rf $RedHatReposDir/* $RedHatReposDirBackup >/dev/null 2>&1 + echo -e '' + ;; + [Nn]*) ;; + *) + echo -e '\n\033[33m------------ 输入错误,默认不覆盖 ------------\033[0m\n' + ;; + esac + else + [ -d $RedHatReposDirBackup ] || mkdir -p $RedHatReposDirBackup + cp -rf $RedHatReposDir/* $RedHatReposDirBackup >/dev/null 2>&1 + echo -e "\n\033[37m└ 已备份原有 repo 源文件至 $RedHatReposDirBackup 目录... \033[0m\n" + sleep 1s + fi + else + [ -d $RedHatReposDir ] || mkdir -p $RedHatReposDir + fi + fi +} + +## 删除原有源 +function RemoveOldMirrorsFiles() { + if [ ${SYSTEM_FACTIONS} = ${SYSTEM_DEBIAN} ]; then + [ -f $DebianSourceList ] && sed -i '1,$d' $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 + else + rm -rf $RedHatReposDir/* + fi + fi + fi +} + +## 更换国内源 +function ChangeMirrors() { + if [ ${SYSTEM_FACTIONS} = ${SYSTEM_DEBIAN} ]; then + DebianMirrors + elif [ ${SYSTEM_FACTIONS} = ${SYSTEM_REDHAT} ]; then + RedHatMirrors + yum clean all >/dev/null 2>&1 + fi + echo -e "\033[32m------------ 开始${SYNC_TXT}软件源 ------------\033[0m\n" + case ${SYSTEM_FACTIONS} in + Debian) + apt-get update + ;; + RedHat) + yum makecache + ;; + esac + VERIFICATION_SOURCESYNC=$? + if [ ${VERIFICATION_SOURCESYNC} -eq 0 ]; then + echo -e "\n\033[32m------------ ${SYNC_TXT}软件源结束 ------------\033[0m" + else + echo -e "\n\033[31m------------ 软件源${SYNC_TXT}失败,请重新执行脚本 ------------\033[0m\n\n如果仍然${SYNC_TXT}失败那么可能由以下原因导致\n1. 网络问题:例如网络异常、网络间歇式中断、由地区影响的网络因素等\n2. 软件源问题:所选镜像站正在维护或者不支持你的操作系统\n" + exit + fi +} + +## 更新软件包 +function UpgradeSoftware() { + CHOICE_B=$(echo -e '\n\033[37m└ 是否更新软件包 [ Y/n ]:\033[0m') + read -p "${CHOICE_B}" INPUT + [ -z ${INPUT} ] && INPUT=Y + case $INPUT in + [Yy]*) + echo -e '' + case ${SYSTEM_FACTIONS} in + Debian) + apt-get upgrade -y + ;; + RedHat) + yum update -y + ;; + esac + CHOICE_C=$(echo -e '\n\033[37m└ 是否清理已下载的软件包缓存 [ Y/n ]:\033[0m') + read -p "${CHOICE_C}" INPUT + [ -z ${INPUT} ] && INPUT=Y + case $INPUT in + [Yy]*) + if [ ${SYSTEM_FACTIONS} = ${SYSTEM_DEBIAN} ]; then + apt-get autoremove -y >/dev/null 2>&1 + apt-get clean >/dev/null 2>&1 + elif [ ${SYSTEM_FACTIONS} = ${SYSTEM_REDHAT} ]; then + yum autoremove -y >/dev/null 2>&1 + yum clean packages -y >/dev/null 2>&1 + fi + + echo -e '\n[OK] 清理完毕' + ;; + [Nn]*) ;; + *) + echo -e '\n\033[33m------------ 输入错误,默认不清理 ------------\033[0m' + ;; + esac + ;; + [Nn]*) ;; + *) + echo -e '\n\033[33m------------ 输入错误,默认不更新 ------------\033[0m' + ;; + esac + echo -e '\n\033[32m------------ 软件源更换完毕 ------------\033[0m' +} + +## 更换基于 Debian 系 Linux 发行版的国内源 +function DebianMirrors() { + ## 修改国内源 + if [ ${SYSTEM_JUDGMENT} = ${SYSTEM_UBUNTU} ]; then + echo "## 默认注释了源码仓库,如有需要可自行取消注释" >>$DebianSourceList + echo "deb ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION} main restricted universe multiverse" >>$DebianSourceList + echo "# deb-src ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION} main restricted universe multiverse" >>$DebianSourceList + echo "deb ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION}-security main restricted universe multiverse" >>$DebianSourceList + echo "# deb-src ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION}-security main restricted universe multiverse" >>$DebianSourceList + echo "deb ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION}-updates main restricted universe multiverse" >>$DebianSourceList + echo "# deb-src ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION}-updates main restricted universe multiverse" >>$DebianSourceList + echo "deb ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION}-backports main restricted universe multiverse" >>$DebianSourceList + echo "# deb-src ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION}-backports main restricted universe multiverse" >>$DebianSourceList + echo '' >>$DebianSourceList + echo "## 预发布软件源,不建议启用" >>$DebianSourceList + echo "# deb ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION}-proposed main restricted universe multiverse" >>$DebianSourceList + echo "# deb-src ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION}-proposed main restricted universe multiverse" >>$DebianSourceList + elif [ ${SYSTEM_JUDGMENT} = ${SYSTEM_DEBIAN} ]; then + echo "## 默认注释了源码仓库,如有需要可自行取消注释" >>$DebianSourceList + echo "deb ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION} main contrib non-free" >>$DebianSourceList + echo "# deb-src ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION} main contrib non-free" >>$DebianSourceList + echo "deb ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION}-updates main contrib non-free" >>$DebianSourceList + echo "# deb-src ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION}-updates main contrib non-free" >>$DebianSourceList + echo "deb ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION}-backports main contrib non-free" >>$DebianSourceList + echo "# deb-src ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION}-backports main contrib non-free" >>$DebianSourceList + echo '' >>$DebianSourceList + echo "## 预发布软件源,不建议启用" >>$DebianSourceList + echo "# deb ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH}-security ${SYSTEM_VERSION}/updates main contrib non-free" >>$DebianSourceList + echo "# deb-src ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH}-security ${SYSTEM_VERSION}/updates main contrib non-free" >>$DebianSourceList + elif [ ${SYSTEM_JUDGMENT} = ${SYSTEM_KALI} ]; then + echo "deb ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION} main non-free contrib" >>$DebianSourceList + echo "deb-src ${WEB_PROTOCOL}://${SOURCE}/${SOURCE_BRANCH} ${SYSTEM_VERSION} main non-free contrib" >>$DebianSourceList + fi +} + +## 更换基于 RedHat 系 Linux 发行版的国内源 +function RedHatMirrors() { + ## 生成基于 RedHat 发行版和及其衍生发行版的官方 repo 源文件 + ## 由于 RedHat 系 Linux 源文件各不相同且不易判断,故通过在删除原有源后重新创建官方源的方式更换国内源 + cd $RedHatReposDir + case ${SYSTEM_JUDGMENT} in + RedHat | CentOS) + CentOSReposCreate + ;; + Fedora) + FedoraReposCreate + ;; + esac + ## 修改国内源 + if [ ${SYSTEM_JUDGMENT} = ${SYSTEM_CENTOS} -o ${SYSTEM_JUDGMENT} = ${SYSTEM_RHEL} ]; then + sed -i 's|^mirrorlist=|#mirrorlist=|g' $RedHatReposDir/${SYSTEM_CENTOS}-* + [ ${CENTOS_VERSION} -eq "8" ] && sed -i 's|^#baseurl=http://mirror.centos.org/$contentdir|baseurl=http://mirror.centos.org/centos|g' $RedHatReposDir/${SYSTEM_CENTOS}-* + sed -i "s|^#baseurl=http|baseurl=${WEB_PROTOCOL}|g" $RedHatReposDir/${SYSTEM_CENTOS}-* + sed -i "s|mirror.centos.org|${SOURCE}|g" $RedHatReposDir/${SYSTEM_CENTOS}-* + ## Red Hat Enterprise Linux 修改版本号 + [ ${SYSTEM_JUDGMENT} = ${SYSTEM_RHEL} ] && sed -i "s/\$releasever/${CENTOS_VERSION}/g" ${SYSTEM_CENTOS}-* + ## 安装/更换基于 CentOS 的 EPEL 扩展国内源 + [ ${EPEL_INSTALL} = "True" ] && EPELMirrors + elif [ ${SYSTEM_JUDGMENT} = ${SYSTEM_FEDORA} ]; then + sed -i 's|^metalink=|#metalink=|g' \ + $RedHatReposDir/${SOURCE_BRANCH}.repo \ + $RedHatReposDir/${SOURCE_BRANCH}-updates.repo \ + $RedHatReposDir/${SOURCE_BRANCH}-modular.repo \ + $RedHatReposDir/${SOURCE_BRANCH}-updates-modular.repo \ + $RedHatReposDir/${SOURCE_BRANCH}-updates-testing.repo \ + $RedHatReposDir/${SOURCE_BRANCH}-updates-testing-modular.repo + sed -i "s|^#baseurl=http|baseurl=${WEB_PROTOCOL}|g" $RedHatReposDir/fedora* + sed -i "s|download.example/pub/fedora/linux|${SOURCE}/fedora|g" \ + $RedHatReposDir/fedora.repo \ + $RedHatReposDir/${SOURCE_BRANCH}-updates.repo \ + $RedHatReposDir/${SOURCE_BRANCH}-modular.repo \ + $RedHatReposDir/${SOURCE_BRANCH}-updates-modular.repo \ + $RedHatReposDir/${SOURCE_BRANCH}-updates-testing.repo \ + $RedHatReposDir/${SOURCE_BRANCH}-updates-testing-modular.repo + fi +} + +## 安装/更换基于 RHEL/CentOS 的 EPEL (Extra Packages for Enterprise Linux) 扩展国内源 +function EPELMirrors() { + ## 安装 EPEL 软件包 + if [ ${VERIFICATION_EPEL} -ne 0 ]; then + echo -e '\033[32m------------ 安装 epel-release 软件包 ------------\033[0m\n' + yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-${CENTOS_VERSION}.noarch.rpm + fi + ## 删除原有 EPEL 扩展 repo 源文件 + [ ${VERIFICATION_EPELFILES} -eq 0 ] && rm -rf $RedHatReposDir/epel* + [ ${VERIFICATION_EPELBACKUPFILES} -eq 0 ] && rm -rf $RedHatReposDirBackup/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* + ;; + 7) + sed -i "s|^#baseurl=http|baseurl=${WEB_PROTOCOL}|g" $RedHatReposDir/epel* + ;; + esac + sed -i "s|download.fedoraproject.org/pub|${SOURCE}|g" $RedHatReposDir/epel* + rm -rf $RedHatReposDir/epel*rpmnew + echo '' +} + +## 选择国内源 +function ChooseMirrors() { + 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 ' ❖ 阿里云 1)' + echo -e ' ❖ 腾讯云 2)' + echo -e ' ❖ 华为云 3)' + echo -e ' ❖ 网易 4)' + echo -e ' ❖ 搜狐 5)' + echo -e ' ❖ 清华大学 6)' + echo -e ' ❖ 浙江大学 7)' + echo -e ' ❖ 南京大学 8)' + echo -e ' ❖ 重庆大学 9)' + echo -e ' ❖ 兰州大学 10)' + echo -e ' ❖ 上海交通大学 11)' + echo -e ' ❖ 哈尔滨工业大学 12)' + echo -e ' ❖ 中国科学技术大学 13)' + echo -e '' + echo -e '#####################################################' + echo -e '' + echo -e " 运行环境 \033[34m${SYSTEM_NAME} ${SYSTEM_VERSION_NUMBER} ${SYSTEM_ARCH}\033[0m" + echo -e " 系统时间 \033[34m$(date "+%Y-%m-%d %H:%M:%S")\033[0m" + echo -e '' + echo -e '#####################################################' + CHOICE_A=$(echo -e '\n\033[37m└ 请选择并输入你想使用的软件源 [ 1-13 ]:\033[0m') + read -p "${CHOICE_A}" INPUT + case $INPUT in + 1) + SOURCE="mirrors.aliyun.com" + ;; + 2) + SOURCE="mirrors.cloud.tencent.com" + ;; + 3) + SOURCE="repo.huaweicloud.com" + ;; + 4) + SOURCE="mirrors.163.com" + ;; + 5) + SOURCE="mirrors.sohu.com" + ;; + 6) + SOURCE="mirrors.tuna.tsinghua.edu.cn" + ;; + 7) + SOURCE="mirrors.zju.edu.cn" + ;; + 8) + SOURCE="mirrors.nju.edu.cn" + ;; + 9) + SOURCE="mirrors.cqu.edu.cn" + ;; + 10) + SOURCE="mirror.lzu.edu.cn" + ;; + 11) + SOURCE="mirror.sjtu.edu.cn" + ;; + 12) + SOURCE="mirrors.hit.edu.cn" + ;; + 13) + SOURCE="mirrors.ustc.edu.cn" + ;; + *) + SOURCE="mirrors.aliyun.com" + echo -e '\n\033[33m------------ 输入错误,将默认使用阿里云作为国内源 ------------\033[0m' + sleep 1s + ;; + esac + + ## 更换基于 RHEL/CentOS 的 EPEL (Extra Packages for Enterprise Linux) 扩展国内源 + if [ ${SYSTEM_JUDGMENT} = ${SYSTEM_CENTOS} -o ${SYSTEM_JUDGMENT} = ${SYSTEM_RHEL} ]; then + ## 判断是否已安装 EPEL 软件包 + rpm -qa | grep epel-release -q + VERIFICATION_EPEL=$? + ## 判断 /etc/yum.repos.d 目录下是否存在 epel 扩展 repo 源文件 + [ -d $RedHatReposDir ] && ls $RedHatReposDir | grep epel -q + VERIFICATION_EPELFILES=$? + ## 判断 /etc/yum.repos.d.bak 目录下是否存在 epel 扩展 repo 源文件 + [ -d $RedHatReposDirBackup ] && ls $RedHatReposDirBackup | grep epel -q + VERIFICATION_EPELBACKUPFILES=$? + + if [ ${VERIFICATION_EPEL} -eq 0 ]; then + CHOICE_D=$(echo -e '\n\033[37m└ 检测到系统已安装 EPEL 扩展源,是否替换/覆盖为国内源 [ Y/n ]:\033[0m') + else + CHOICE_D=$(echo -e '\n\033[37m└ 是否安装 EPEL 扩展源 [ Y/n ]:\033[0m') + fi + read -p "${CHOICE_D}" INPUT + [ -z ${INPUT} ] && INPUT=Y + case $INPUT in + [Yy]*) + EPEL_INSTALL="True" + ;; + [Nn]*) + EPEL_INSTALL="False" + ;; + *) + echo -e '\n\033[33m------------ 输入错误,默认不更换 ------------\033[0m' + EPEL_INSTALL="False" + ;; + esac + fi + + ## 选择同步软件源所使用的 WEB 协议( HTTP:80 端口,HTTPS:443 端口) + CHOICE_E=$(echo -e "\n\033[37m└ 软件源是否使用 HTTP 协议 [ Y/n ]:\033[0m") + read -p "${CHOICE_E}" INPUT + [ -z ${INPUT} ] && INPUT=Y + case $INPUT in + [Yy]*) + WEB_PROTOCOL="http" + ;; + [Nn]*) + WEB_PROTOCOL="https" + ;; + *) + echo -e "\n\033[33m------------ 输入错误,默认使用 HTTPS 协议 ------------\033[0m" + WEB_PROTOCOL="https" + ;; + esac + + ## 关闭 防火墙 和 SELINUX + [ ${SYSTEM_FACTIONS} = ${SYSTEM_REDHAT} ] && TurnOffFirewall +} + +## 生成 CentOS 官方 repo 源文件 +function CentOSReposCreate() { + 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' + for REPOS in $CentOS8_RepoFiles; do + touch $REPOS + done + cat >$RedHatReposDir/${SYSTEM_CENTOS}-Linux-AppStream.repo <<\EOF +# CentOS-Linux-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 Linux $releasever - AppStream +mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=AppStream&infra=$infra +#baseurl=http://mirror.centos.org/$contentdir/$releasever/AppStream/$basearch/os/ +gpgcheck=1 +enabled=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial +EOF + cat >$RedHatReposDir/${SYSTEM_CENTOS}-Linux-BaseOS.repo <<\EOF +# CentOS-Linux-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 Linux $releasever - BaseOS +mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=BaseOS&infra=$infra +#baseurl=http://mirror.centos.org/$contentdir/$releasever/BaseOS/$basearch/os/ +gpgcheck=1 +enabled=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial +EOF + cat >$RedHatReposDir/${SYSTEM_CENTOS}-Linux-ContinuousRelease.repo <<\EOF +# CentOS-Linux-ContinuousRelease.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. +# +# The Continuous Release (CR) repository contains packages for the next minor +# release of CentOS Linux. This repository only has content in the time period +# between an upstream release and the official CentOS Linux release. These +# packages have not been fully tested yet and should be considered beta +# quality. They are made available for people willing to test and provide +# feedback for the next release. + +[cr] +name=CentOS Linux $releasever - ContinuousRelease +mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=cr&infra=$infra +#baseurl=http://mirror.centos.org/$contentdir/$releasever/cr/$basearch/os/ +gpgcheck=1 +enabled=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial +EOF + cat >$RedHatReposDir/${SYSTEM_CENTOS}-Linux-Debuginfo.repo <<\EOF +# CentOS-Linux-Debuginfo.repo +# +# All debug packages are merged into a single repo, split by basearch, and are +# not signed. + +[debuginfo] +name=CentOS Linux $releasever - Debuginfo +baseurl=http://debuginfo.centos.org/$releasever/$basearch/ +gpgcheck=1 +enabled=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial +EOF + cat >$RedHatReposDir/${SYSTEM_CENTOS}-Linux-Devel.repo <<\EOF +# CentOS-Linux-Devel.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. + +[devel] +name=CentOS Linux $releasever - Devel WARNING! FOR BUILDROOT USE ONLY! +mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=Devel&infra=$infra +#baseurl=http://mirror.centos.org/$contentdir/$releasever/Devel/$basearch/os/ +gpgcheck=1 +enabled=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial +EOF + cat >$RedHatReposDir/${SYSTEM_CENTOS}-Linux-Extras.repo <<\EOF +# CentOS-Linux-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 Linux $releasever - Extras +mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra +#baseurl=http://mirror.centos.org/$contentdir/$releasever/extras/$basearch/os/ +gpgcheck=1 +enabled=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial +EOF + cat >$RedHatReposDir/${SYSTEM_CENTOS}-Linux-FastTrack.repo <<\EOF +# CentOS-Linux-FastTrack.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. + +[fasttrack] +name=CentOS Linux $releasever - FastTrack +mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=fasttrack&infra=$infra +#baseurl=http://mirror.centos.org/$contentdir/$releasever/fasttrack/$basearch/os/ +gpgcheck=1 +enabled=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial +EOF + cat >$RedHatReposDir/${SYSTEM_CENTOS}-Linux-HighAvailability.repo <<\EOF +# CentOS-Linux-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 Linux $releasever - HighAvailability +mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=HighAvailability&infra=$infra +#baseurl=http://mirror.centos.org/$contentdir/$releasever/HighAvailability/$basearch/os/ +gpgcheck=1 +enabled=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial +EOF + cat >$RedHatReposDir/${SYSTEM_CENTOS}-Linux-Media.repo <<\EOF +# CentOS-Linux-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 Linux $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 Linux $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 >$RedHatReposDir/${SYSTEM_CENTOS}-Linux-Plus.repo <<\EOF +# CentOS-Linux-Plus.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. + +[plus] +name=CentOS Linux $releasever - Plus +mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra +#baseurl=http://mirror.centos.org/$contentdir/$releasever/centosplus/$basearch/os/ +gpgcheck=1 +enabled=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial +EOF + cat >$RedHatReposDir/${SYSTEM_CENTOS}-Linux-PowerTools.repo <<\EOF +# CentOS-Linux-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 Linux $releasever - PowerTools +mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=PowerTools&infra=$infra +#baseurl=http://mirror.centos.org/$contentdir/$releasever/PowerTools/$basearch/os/ +gpgcheck=1 +enabled=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial +EOF + cat >$RedHatReposDir/${SYSTEM_CENTOS}-Linux-Sources.repo <<\EOF +# CentOS-Linux-Sources.repo + + +[baseos-source] +name=CentOS Linux $releasever - BaseOS - Source +baseurl=http://vault.centos.org/$contentdir/$releasever/BaseOS/Source/ +gpgcheck=1 +enabled=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial + +[appstream-source] +name=CentOS Linux $releasever - AppStream - Source +baseurl=http://vault.centos.org/$contentdir/$releasever/AppStream/Source/ +gpgcheck=1 +enabled=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial + +[extras-source] +name=CentOS Linux $releasever - Extras - Source +baseurl=http://vault.centos.org/$contentdir/$releasever/extras/Source/ +gpgcheck=1 +enabled=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial + +[plus-source] +name=CentOS Linux $releasever - Plus - Source +baseurl=http://vault.centos.org/$contentdir/$releasever/centosplus/Source/ +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' + for REPOS in $CentOS7_RepoFiles; do + touch $REPOS + done + cat >$RedHatReposDir/${SYSTEM_CENTOS}-Base.repo <<\EOF +# CentOS-Base.repo +# +# The mirror system uses the connecting IP address of the client and the +# update status of each mirror to pick mirrors that are updated to and +# 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, as a fall back you can try the +# remarked out baseurl= line instead. +# +# + +[base] +name=CentOS-$releasever - Base +mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra +#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 + +#released updates +[updates] +name=CentOS-$releasever - Updates +mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra +#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/ +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 + +#additional packages that may be useful +[extras] +name=CentOS-$releasever - Extras +mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra +#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/ +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 + +#additional packages that extend functionality of existing packages +[centosplus] +name=CentOS-$releasever - Plus +mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra +#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/ +gpgcheck=1 +enabled=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 +EOF + cat >$RedHatReposDir/${SYSTEM_CENTOS}-CR.repo <<\EOF +# CentOS-CR.repo +# +# The Continuous Release ( CR ) repository contains rpms that are due in the next +# release for a specific CentOS Version ( eg. next release in CentOS-7 ); these rpms +# are far less tested, with no integration checking or update path testing having +# taken place. They are still built from the upstream sources, but might not map +# to an exact upstream distro release. +# +# These packages are made available soon after they are built, for people willing +# to test their environments, provide feedback on content for the next release, and +# for people looking for early-access to next release content. +# +# The CR repo is shipped in a disabled state by default; its important that users +# understand the implications of turning this on. +# +# NOTE: We do not use a mirrorlist for the CR repos, to ensure content is available +# to everyone as soon as possible, and not need to wait for the external +# mirror network to seed first. However, many local mirrors will carry CR repos +# and if desired you can use one of these local mirrors by editing the baseurl +# line in the repo config below. +# + +[cr] +name=CentOS-$releasever - cr +baseurl=http://mirror.centos.org/centos/$releasever/cr/$basearch/ +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 +enabled=0 +EOF + cat >$RedHatReposDir/${SYSTEM_CENTOS}-Debuginfo.repo <<\EOF +# CentOS-Debug.repo +# +# The mirror system uses the connecting IP address of the client and the +# update status of each mirror to pick mirrors that are updated to and +# geographically close to the client. You should use this for CentOS updates +# unless you are manually picking other mirrors. +# + +# All debug packages from all the various CentOS-7 releases +# are merged into a single repo, split by BaseArch +# +# Note: packages in the debuginfo repo are currently not signed +# + +[base-debuginfo] +name=CentOS-7 - Debuginfo +baseurl=http://debuginfo.centos.org/7/$basearch/ +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Debug-7 +enabled=0 +# +EOF + cat >$RedHatReposDir/${SYSTEM_CENTOS}-fasttrack.repo <<\EOF +[fasttrack] +name=CentOS-7 - fasttrack +mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=fasttrack&infra=$infra +#baseurl=http://mirror.centos.org/centos/$releasever/fasttrack/$basearch/ +gpgcheck=1 +enabled=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 +EOF + cat >$RedHatReposDir/${SYSTEM_CENTOS}-Media.repo <<\EOF +# CentOS-Media.repo +# +# This repo can be used with mounted DVD media, verify the mount point for +# CentOS-7. You can use this repo and yum to install items directly off the +# DVD ISO that we release. +# +# To use this repo, put in your DVD and use it with the other repos too: +# yum --enablerepo=c7-media [command] +# +# or for ONLY the media repo, do this: +# +# yum --disablerepo=\* --enablerepo=c7-media [command] + +[c7-media] +name=CentOS-$releasever - Media +baseurl=file:///media/CentOS/ + file:///media/cdrom/ + file:///media/cdrecorder/ +gpgcheck=1 +enabled=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 +EOF + cat >$RedHatReposDir/${SYSTEM_CENTOS}-Sources.repo <<\EOF +# CentOS-Sources.repo +# +# The mirror system uses the connecting IP address of the client and the +# update status of each mirror to pick mirrors that are updated to and +# 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, as a fall back you can try the +# remarked out baseurl= line instead. +# +# + +[base-source] +name=CentOS-$releasever - Base Sources +baseurl=http://vault.centos.org/centos/$releasever/os/Source/ +gpgcheck=1 +enabled=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 + +#released updates +[updates-source] +name=CentOS-$releasever - Updates Sources +baseurl=http://vault.centos.org/centos/$releasever/updates/Source/ +gpgcheck=1 +enabled=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 + +#additional packages that may be useful +[extras-source] +name=CentOS-$releasever - Extras Sources +baseurl=http://vault.centos.org/centos/$releasever/extras/Source/ +gpgcheck=1 +enabled=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 + +#additional packages that extend functionality of existing packages +[centosplus-source] +name=CentOS-$releasever - Plus Sources +baseurl=http://vault.centos.org/centos/$releasever/centosplus/Source/ +gpgcheck=1 +enabled=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 +EOF + fi +} + +## 生成 Fedora 官方 repo 源文件 +function FedoraReposCreate() { + 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 +[fedora-cisco-openh264] +name=Fedora $releasever openh264 (From Cisco) - $basearch +metalink=https://mirrors.fedoraproject.org/metalink?repo=fedora-cisco-openh264-$releasever&arch=$basearch +type=rpm +enabled=1 +metadata_expire=14d +repo_gpgcheck=0 +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch +skip_if_unavailable=True + +[fedora-cisco-openh264-debuginfo] +name=Fedora $releasever openh264 (From Cisco) - $basearch - Debug +metalink=https://mirrors.fedoraproject.org/metalink?repo=fedora-cisco-openh264-debug-$releasever&arch=$basearch +type=rpm +enabled=0 +metadata_expire=14d +repo_gpgcheck=0 +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 +[fedora] +name=Fedora $releasever - $basearch +#baseurl=http://download.example/pub/fedora/linux/releases/$releasever/Everything/$basearch/os/ +metalink=https://mirrors.fedoraproject.org/metalink?repo=fedora-$releasever&arch=$basearch +enabled=1 +countme=1 +metadata_expire=7d +repo_gpgcheck=0 +type=rpm +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch +skip_if_unavailable=False + +[fedora-debuginfo] +name=Fedora $releasever - $basearch - Debug +#baseurl=http://download.example/pub/fedora/linux/releases/$releasever/Everything/$basearch/debug/tree/ +metalink=https://mirrors.fedoraproject.org/metalink?repo=fedora-debug-$releasever&arch=$basearch +enabled=0 +metadata_expire=7d +repo_gpgcheck=0 +type=rpm +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch +skip_if_unavailable=False + +[fedora-source] +name=Fedora $releasever - Source +#baseurl=http://download.example/pub/fedora/linux/releases/$releasever/Everything/source/tree/ +metalink=https://mirrors.fedoraproject.org/metalink?repo=fedora-source-$releasever&arch=$basearch +enabled=0 +metadata_expire=7d +repo_gpgcheck=0 +type=rpm +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 +[updates] +name=Fedora $releasever - $basearch - Updates +#baseurl=http://download.example/pub/fedora/linux/updates/$releasever/Everything/$basearch/ +metalink=https://mirrors.fedoraproject.org/metalink?repo=updates-released-f$releasever&arch=$basearch +enabled=1 +countme=1 +repo_gpgcheck=0 +type=rpm +gpgcheck=1 +metadata_expire=6h +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch +skip_if_unavailable=False + +[updates-debuginfo] +name=Fedora $releasever - $basearch - Updates - Debug +#baseurl=http://download.example/pub/fedora/linux/updates/$releasever/Everything/$basearch/debug/ +metalink=https://mirrors.fedoraproject.org/metalink?repo=updates-released-debug-f$releasever&arch=$basearch +enabled=0 +repo_gpgcheck=0 +type=rpm +gpgcheck=1 +metadata_expire=6h +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch +skip_if_unavailable=False + +[updates-source] +name=Fedora $releasever - Updates Source +#baseurl=http://download.example/pub/fedora/linux/updates/$releasever/Everything/SRPMS/ +metalink=https://mirrors.fedoraproject.org/metalink?repo=updates-released-source-f$releasever&arch=$basearch +enabled=0 +repo_gpgcheck=0 +type=rpm +gpgcheck=1 +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 +[fedora-modular] +name=Fedora Modular $releasever - $basearch +#baseurl=http://download.example/pub/fedora/linux/releases/$releasever/Modular/$basearch/os/ +metalink=https://mirrors.fedoraproject.org/metalink?repo=fedora-modular-$releasever&arch=$basearch +enabled=1 +countme=1 +#metadata_expire=7d +repo_gpgcheck=0 +type=rpm +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch +skip_if_unavailable=False + +[fedora-modular-debuginfo] +name=Fedora Modular $releasever - $basearch - Debug +#baseurl=http://download.example/pub/fedora/linux/releases/$releasever/Modular/$basearch/debug/tree/ +metalink=https://mirrors.fedoraproject.org/metalink?repo=fedora-modular-debug-$releasever&arch=$basearch +enabled=0 +metadata_expire=7d +repo_gpgcheck=0 +type=rpm +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch +skip_if_unavailable=False + +[fedora-modular-source] +name=Fedora Modular $releasever - Source +#baseurl=http://download.example/pub/fedora/linux/releases/$releasever/Modular/source/tree/ +metalink=https://mirrors.fedoraproject.org/metalink?repo=fedora-modular-source-$releasever&arch=$basearch +enabled=0 +metadata_expire=7d +repo_gpgcheck=0 +type=rpm +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 +[updates-modular] +name=Fedora Modular $releasever - $basearch - Updates +#baseurl=http://download.example/pub/fedora/linux/updates/$releasever/Modular/$basearch/ +metalink=https://mirrors.fedoraproject.org/metalink?repo=updates-released-modular-f$releasever&arch=$basearch +enabled=1 +countme=1 +repo_gpgcheck=0 +type=rpm +gpgcheck=1 +metadata_expire=6h +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch +skip_if_unavailable=False + +[updates-modular-debuginfo] +name=Fedora Modular $releasever - $basearch - Updates - Debug +#baseurl=http://download.example/pub/fedora/linux/updates/$releasever/Modular/$basearch/debug/ +metalink=https://mirrors.fedoraproject.org/metalink?repo=updates-released-modular-debug-f$releasever&arch=$basearch +enabled=0 +repo_gpgcheck=0 +type=rpm +gpgcheck=1 +metadata_expire=6h +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch +skip_if_unavailable=False + +[updates-modular-source] +name=Fedora Modular $releasever - Updates Source +#baseurl=http://download.example/pub/fedora/linux/updates/$releasever/Modular/SRPMS/ +metalink=https://mirrors.fedoraproject.org/metalink?repo=updates-released-modular-source-f$releasever&arch=$basearch +enabled=0 +repo_gpgcheck=0 +type=rpm +gpgcheck=1 +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 +[updates-testing] +name=Fedora $releasever - $basearch - Test Updates +#baseurl=http://download.example/pub/fedora/linux/updates/testing/$releasever/Everything/$basearch/ +metalink=https://mirrors.fedoraproject.org/metalink?repo=updates-testing-f$releasever&arch=$basearch +enabled=0 +countme=1 +repo_gpgcheck=0 +type=rpm +gpgcheck=1 +metadata_expire=6h +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch +skip_if_unavailable=False + +[updates-testing-debuginfo] +name=Fedora $releasever - $basearch - Test Updates Debug +#baseurl=http://download.example/pub/fedora/linux/updates/testing/$releasever/Everything/$basearch/debug/ +metalink=https://mirrors.fedoraproject.org/metalink?repo=updates-testing-debug-f$releasever&arch=$basearch +enabled=0 +repo_gpgcheck=0 +type=rpm +gpgcheck=1 +metadata_expire=6h +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch +skip_if_unavailable=False + +[updates-testing-source] +name=Fedora $releasever - Test Updates Source +#baseurl=http://download.example/pub/fedora/linux/updates/testing/$releasever/Everything/SRPMS/ +metalink=https://mirrors.fedoraproject.org/metalink?repo=updates-testing-source-f$releasever&arch=$basearch +enabled=0 +repo_gpgcheck=0 +type=rpm +gpgcheck=1 +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 +[updates-testing-modular] +name=Fedora Modular $releasever - $basearch - Test Updates +#baseurl=http://download.example/pub/fedora/linux/updates/testing/$releasever/Modular/$basearch/ +metalink=https://mirrors.fedoraproject.org/metalink?repo=updates-testing-modular-f$releasever&arch=$basearch +enabled=0 +countme=1 +repo_gpgcheck=0 +type=rpm +gpgcheck=1 +metadata_expire=6h +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch +skip_if_unavailable=False + +[updates-testing-modular-debuginfo] +name=Fedora Modular $releasever - $basearch - Test Updates Debug +#baseurl=http://download.example/pub/fedora/linux/updates/$releasever/Modular/$basearch/debug/ +metalink=https://mirrors.fedoraproject.org/metalink?repo=updates-testing-modular-debug-f$releasever&arch=$basearch +enabled=0 +repo_gpgcheck=0 +type=rpm +gpgcheck=1 +metadata_expire=6h +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch +skip_if_unavailable=False + +[updates-testing-modular-source] +name=Fedora Modular $releasever - Test Updates Source +#baseurl=http://download.example/pub/fedora/linux/updates/$releasever/Modular/SRPMS/ +metalink=https://mirrors.fedoraproject.org/metalink?repo=updates-testing-modular-source-f$releasever&arch=$basearch +enabled=0 +repo_gpgcheck=0 +type=rpm +gpgcheck=1 +metadata_expire=6h +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch +skip_if_unavailable=False +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' + for REPOS in $EPEL8_RepoFiles; do + touch $REPOS + done + cat >$RedHatReposDir/epel.repo <<\EOF +[epel] +name=Extra Packages for Enterprise Linux $releasever - $basearch +#baseurl=https://download.fedoraproject.org/pub/epel/$releasever/Everything/$basearch +metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-$releasever&arch=$basearch&infra=$infra&content=$contentdir +enabled=1 +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8 + +[epel-debuginfo] +name=Extra Packages for Enterprise Linux $releasever - $basearch - Debug +#baseurl=https://download.fedoraproject.org/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-8 +gpgcheck=1 + +[epel-source] +name=Extra Packages for Enterprise Linux $releasever - $basearch - Source +#baseurl=https://download.fedoraproject.org/pub/epel/$releasever/Everything/SRPMS +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-8 +gpgcheck=1 +EOF + cat >$RedHatReposDir/epel-modular.repo <<\EOF +[epel-modular] +name=Extra Packages for Enterprise Linux Modular $releasever - $basearch +#baseurl=https://download.fedoraproject.org/pub/epel/$releasever/Modular/$basearch +metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-modular-$releasever&arch=$basearch&infra=$infra&content=$contentdir +enabled=1 +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8 + +[epel-modular-debuginfo] +name=Extra Packages for Enterprise Linux Modular $releasever - $basearch - Debug +#baseurl=https://download.fedoraproject.org/pub/epel/$releasever/Modular/$basearch/debug +metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-modular-debug-$releasever&arch=$basearch&infra=$infra&content=$contentdir +enabled=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8 +gpgcheck=1 + +[epel-modular-source] +name=Extra Packages for Enterprise Linux Modular $releasever - $basearch - Source +#baseurl=https://download.fedoraproject.org/pub/epel/$releasever/Modular/SRPMS +metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-modular-source-$releasever&arch=$basearch&infra=$infra&content=$contentdir +enabled=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8 +gpgcheck=1 +EOF + cat >$RedHatReposDir/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 +metalink=https://mirrors.fedoraproject.org/metalink?repo=playground-epel$releasever&arch=$basearch&infra=$infra&content=$contentdir +enabled=0 +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8 + +[epel-playground-debuginfo] +name=Extra Packages for Enterprise Linux $releasever - Playground - $basearch - Debug +#baseurl=https://download.fedoraproject.org/pub/epel/playground/$releasever/Everything/$basearch/debug +metalink=https://mirrors.fedoraproject.org/metalink?repo=playground-debug-epel$releasever&arch=$basearch&infra=$infra&content=$contentdir +enabled=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8 +gpgcheck=1 + +[epel-playground-source] +name=Extra Packages for Enterprise Linux $releasever - Playground - $basearch - Source +#baseurl=https://download.fedoraproject.org/pub/epel/playground/$releasever/Everything/source/tree/ +metalink=https://mirrors.fedoraproject.org/metalink?repo=playground-source-epel$releasever&arch=$basearch&infra=$infra&content=$contentdir +enabled=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8 +gpgcheck=1 +EOF + cat >$RedHatReposDir/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 +metalink=https://mirrors.fedoraproject.org/metalink?repo=testing-epel$releasever&arch=$basearch&infra=$infra&content=$contentdir +enabled=0 +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8 + +[epel-testing-debuginfo] +name=Extra Packages for Enterprise Linux $releasever - Testing - $basearch - Debug +#baseurl=https://download.fedoraproject.org/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-8 +gpgcheck=1 + +[epel-testing-source] +name=Extra Packages for Enterprise Linux $releasever - Testing - $basearch - Source +#baseurl=https://download.fedoraproject.org/pub/epel/testing/$releasever/Everything/SRPMS +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-8 +gpgcheck=1 +EOF + cat >$RedHatReposDir/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 +metalink=https://mirrors.fedoraproject.org/metalink?repo=testing-modular-epel$releasever&arch=$basearch&infra=$infra&content=$contentdir +enabled=0 +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8 + +[epel-testing-modular-debuginfo] +name=Extra Packages for Enterprise Linux Modular $releasever - Testing - $basearch - Debug +#baseurl=https://download.fedoraproject.org/pub/epel/testing/$releasever/Modular/$basearch/debug +metalink=https://mirrors.fedoraproject.org/metalink?repo=testing-modular-debug-epel$releasever&arch=$basearch&infra=$infra&content=$contentdir +enabled=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8 +gpgcheck=1 + +[epel-testing-modular-source] +name=Extra Packages for Enterprise Linux Modular $releasever - Testing - $basearch - Source +#baseurl=https://download.fedoraproject.org/pub/epel/testing/$releasever/Modular/SRPMS +metalink=https://mirrors.fedoraproject.org/metalink?repo=testing-modular-source-epel$releasever&arch=$basearch&infra=$infra&content=$contentdir +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' + for REPOS in $EPEL7_RepoFiles; do + touch $REPOS + done + cat >$RedHatReposDir/epel.repo <<\EOF +[epel] +name=Extra Packages for Enterprise Linux 7 - $basearch +#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch +metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch +failovermethod=priority +enabled=1 +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 + +[epel-debuginfo] +name=Extra Packages for Enterprise Linux 7 - $basearch - Debug +#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch/debug +metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch +failovermethod=priority +enabled=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 +gpgcheck=1 + +[epel-source] +name=Extra Packages for Enterprise Linux 7 - $basearch - Source +#baseurl=http://download.fedoraproject.org/pub/epel/7/SRPMS +metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch +failovermethod=priority +enabled=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 +gpgcheck=1 +EOF + cat >$RedHatReposDir/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 +metalink=https://mirrors.fedoraproject.org/metalink?repo=testing-epel7&arch=$basearch +failovermethod=priority +enabled=0 +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 + +[epel-testing-debuginfo] +name=Extra Packages for Enterprise Linux 7 - Testing - $basearch - Debug +#baseurl=http://download.fedoraproject.org/pub/epel/testing/7/$basearch/debug +metalink=https://mirrors.fedoraproject.org/metalink?repo=testing-debug-epel7&arch=$basearch +failovermethod=priority +enabled=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 +gpgcheck=1 + +[epel-testing-source] +name=Extra Packages for Enterprise Linux 7 - Testing - $basearch - Source +#baseurl=http://download.fedoraproject.org/pub/epel/testing/7/SRPMS +metalink=https://mirrors.fedoraproject.org/metalink?repo=testing-source-epel7&arch=$basearch +failovermethod=priority +enabled=0 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 +gpgcheck=1 +EOF + fi +} + +Combin_Function diff --git a/DockerInstallation.sh b/DockerInstallation.sh new file mode 100644 index 0000000..1a183c2 --- /dev/null +++ b/DockerInstallation.sh @@ -0,0 +1,678 @@ +#!/bin/bash +## Author: SuperManito +## Modified: 2021-09-21 +## License: GPL-2.0 +## https://github.com/SuperManito/LinuxMirrors +## https://gitee.com/SuperManito/LinuxMirrors + +function AuthorSignature() { + if [ ${SYSTEM_FACTIONS} = ${SYSTEM_DEBIAN} ]; then + apt-get install -y figlet toilet >/dev/null 2>&1 + elif [ ${SYSTEM_FACTIONS} = ${SYSTEM_REDHAT} ]; then + yum install -y figlet toilet >/dev/null 2>&1 + fi + if [[ $? -eq 0 ]]; then + echo -e "\n$(toilet -f slant -F border --gay SuperManito)\n" + else + echo -e '\n\033[35m _____ __ ___ _ __ \033[0m' + echo -e '\033[31m / ___/__ ______ ___ _____/ |/ /___ _____ (_) /_____ \033[0m' + echo -e '\033[33m \__ \/ / / / __ \/ _ \/ ___/ /|_/ / __ `/ __ \/ / __/ __ \ \033[0m' + echo -e '\033[32m ___/ / /_/ / /_/ / __/ / / / / / /_/ / / / / / /_/ /_/ / \033[0m' + echo -e '\033[36m /____/\__,_/ .___/\___/_/ /_/ /_/\__,_/_/ /_/_/\__/\____/ \033[0m' + echo -e '\033[34m /_/ \033[0m\n' + fi +} + +## 定义系统判定变量 +DebianRelease=lsb_release +Arch=$(uname -m) +SYSTEM_DEBIAN="Debian" +SYSTEM_UBUNTU="Ubuntu" +SYSTEM_KALI="Kali" +SYSTEM_REDHAT="RedHat" +SYSTEM_RHEL="RedHat" +SYSTEM_CENTOS="CentOS" +SYSTEM_FEDORA="Fedora" + +## 定义目录和文件 +LinuxRelease=/etc/os-release +RedHatRelease=/etc/redhat-release +DebianSourceList=/etc/apt/sources.list +DebianExtendListDir=/etc/apt/sources.list.d +RedHatReposDir=/etc/yum.repos.d +SelinuxConfig=/etc/selinux/config + +## 定义 Docker 相关变量 +DockerSourceList=$DebianExtendListDir/docker.list +DockerRepo=$RedHatReposDir/download.docker.com_linux_*.repo +DockerDir=/etc/docker +DockerConfig=$DockerDir/daemon.json +DockerConfigBackup=$DockerDir/daemon.json.bak +DockerCompose=/usr/local/bin/docker-compose +DockerVersionFile=docker-version.txt +DockerCEVersionFile=docker-ce-version.txt +DockerCECLIVersionFile=docker-ce-cli-version.txt +PROXY_URL=https://ghproxy.com/ +DOCKER_COMPOSE_VERSION=1.29.2 +DOCKER_COMPOSE_DOWNLOAD_URL=https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-Linux-x86_64 + +## 组合函数 +function Combin_Function() { + PermissionJudgment + NetWorkJudgment && clear + EnvJudgment + ChooseMirrors + InstallationEnvironment + ConfigureDockerCEMirror + DockerEngine + DockerCompose + ShowVersion + AuthorSignature +} + +## 系统判定变量 +function EnvJudgment() { + ## 判定当前系统基于 Debian or RedHat + if [ -f $RedHatRelease ]; then + SYSTEM_FACTIONS=${SYSTEM_REDHAT} + else + SYSTEM_FACTIONS=${SYSTEM_DEBIAN} + fi + ## 定义系统名称 + SYSTEM_NAME=$(cat $LinuxRelease | grep -E "^NAME" | awk -F '\"' '{print$2}') + ## 定义系统版本号 + SYSTEM_VERSION_NUMBER=$(cat $LinuxRelease | grep -E "VERSION_ID" | awk -F '\"' '{print$2}') + ## 判定系统名称、版本、版本号 + case ${SYSTEM_FACTIONS} in + Debian) + SYSTEM_JUDGMENT=$(${DebianRelease} -is) + SYSTEM_VERSION=$(${DebianRelease} -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) + else + CENTOS_VERSION="" + fi + ;; + esac + ## 判定系统处理器架构 + case $Arch in + x86_64) + SYSTEM_ARCH=x86_64 + SOURCE_ARCH=amd64 + ;; + aarch64) + SYSTEM_ARCH=ARM64 + SOURCE_ARCH=arm64 + ;; + armv7l) + SYSTEM_ARCH=ARMv7 + SOURCE_ARCH=armhf + ;; + armv6l) + SYSTEM_ARCH=ARMv6 + SOURCE_ARCH=armhf + ;; + i686) + SYSTEM_ARCH=x86_32 + echo -e '\n\033[31m---------- Docker Engine 不支持安装在 x86_32 架构的环境上 ----------\033[0m' + exit 1 + ;; + *) + SYSTEM_ARCH=$Arch + SOURCE_ARCH=armhf + ;; + esac + ## 定义软件源分支名称 + if [ ${SYSTEM_JUDGMENT} = ${SYSTEM_RHEL} ]; then + SOURCE_BRANCH="centos" + else + SOURCE_BRANCH=${SYSTEM_JUDGMENT,,} + fi + ## 定义软件源同步/更新文字 + case ${SYSTEM_FACTIONS} in + Debian) + SYNC_TXT="更新" + ;; + RedHat) + SYNC_TXT="同步" + ;; + esac +} + +## 基础环境判断 +function PermissionJudgment() { + if [ $UID -ne 0 ]; then + echo -e '\033[31m ---------- Permission no enough, please use user ROOT! ---------- \033[0m' + exit + fi +} +function NetWorkJudgment() { + ping -c 1 www.baidu.com >/dev/null 2>&1 + if [ $? -ne 0 ]; then + echo -e "\033[31m ----- Network connection error, please check the network environment and try again later! ----- \033[0m" + exit + fi +} + +## 关闭防火墙 +function TurnOffFirewall() { + systemctl status firewalld | grep running -q + if [ $? -eq 0 ]; then + systemctl disable --now firewalld >/dev/null 2>&1 + [ -s $SelinuxConfig ] && sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" $SelinuxConfig && setenforce 0 >/dev/null 2>&1 + fi +} + +## 安装环境包 +function InstallationEnvironment() { + case ${SYSTEM_FACTIONS} in + Debian) + sed -i '/docker-ce/d' $DebianSourceList + rm -rf $DockerSourceList + ;; + RedHat) + rm -rf $DockerRepo + ;; + esac + case ${SYSTEM_FACTIONS} in + Debian) + apt-get update + ;; + RedHat) + yum makecache + ;; + esac + VERIFICATION_SOURCESYNC=$? + if [ ${VERIFICATION_SOURCESYNC} -ne 0 ]; then + echo -e "\n\033[31m ---------- 软件源${SYNC_TXT}出错,请先确保软件包管理工具可用 ---------- \033[0m\n" + exit 1 + fi + case ${SYSTEM_FACTIONS} in + Debian) + apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common + ;; + RedHat) + yum install -y yum-utils device-mapper-persistent-data lvm2 + ;; + esac + +} + +## 卸载旧版本的 Docker Engine +function RemoveOldVersion() { + systemctl disable --now docker >/dev/null 2>&1 + sleep 2s + case ${SYSTEM_FACTIONS} in + Debian) + apt-get remove -y docker-ce docker-ce-cli containerd.io runc >/dev/null 2>&1 + apt-get autoremove -y >/dev/null 2>&1 + ;; + RedHat) + yum remove -y docker-ce docker-ce-cli containerd.io podman* runc >/dev/null 2>&1 + yum autoremove -y >/dev/null 2>&1 + ;; + esac +} + +## 查看可供安装的 Docker Engine 版本清单 +function DockerEngineVersionList() { + case ${SYSTEM_FACTIONS} in + Debian) + apt-cache madison docker-ce | awk '{print $3}' | grep -Eo "[0-9][0-9].[0-9][0-9].[0-9]{1,2}" >$DockerCEVersionFile + apt-cache madison docker-ce-cli | awk '{print $3}' | grep -Eo "[0-9][0-9].[0-9][0-9].[0-9]{1,2}" >$DockerCECLIVersionFile + grep -wf $DockerCEVersionFile $DockerCECLIVersionFile >$DockerVersionFile + ;; + RedHat) + yum list docker-ce --showduplicates | sort -r | awk '{print $2}' | grep -Eo "[0-9][0-9].[0-9][0-9].[0-9]{1,2}" >$DockerCEVersionFile + yum list docker-ce-cli --showduplicates | sort -r | awk '{print $2}' | grep -Eo "[0-9][0-9].[0-9][0-9].[0-9]{1,2}" >$DockerCECLIVersionFile + grep -wf $DockerCEVersionFile $DockerCECLIVersionFile >$DockerVersionFile + ;; + esac + rm -rf $DockerCEVersionFile $DockerCECLIVersionFile +} + +## 配置 Docker CE 源 +function ConfigureDockerCEMirror() { + if [ ${DOCKER_VERSION_INSTALL_LATEST} == "True" ]; then + SOURCE_JUDGMENT=${SOURCE} + else + SOURCE_JUDGMENT="download.docker.com" + fi + + case ${SYSTEM_FACTIONS} in + Debian) + if [ ${SYSTEM_JUDGMENT} = ${SYSTEM_KALI} ]; then + curl -fsSL https://${SOURCE_JUDGMENT}/linux/debian/gpg | apt-key add - >/dev/null 2>&1 + else + curl -fsSL https://${SOURCE_JUDGMENT}/linux/${SOURCE_BRANCH}/gpg | apt-key add - >/dev/null 2>&1 + fi + echo "deb [arch=${SOURCE_ARCH}] https://${SOURCE_JUDGMENT}/linux/${SOURCE_BRANCH} ${SYSTEM_VERSION} stable" | tee $DockerSourceList >/dev/null 2>&1 + if [ ${SYSTEM_JUDGMENT} = ${SYSTEM_KALI} ]; then + sed -i "s/${SYSTEM_VERSION}/buster/g" $DockerSourceList + sed -i "s/${SOURCE_BRANCH}/debian/g" $DockerSourceList + fi + apt-get update >/dev/null 2>&1 + ;; + RedHat) + yum-config-manager -y --add-repo https://${SOURCE_JUDGMENT}/linux/${SOURCE_BRANCH}/docker-ce.repo + yum makecache >/dev/null 2>&1 + ;; + esac +} + +## 安装 Docker Engine +function DockerEngine() { + case ${SYSTEM_FACTIONS} in + Debian) + dpkg -l | grep docker-ce-cli -q + ;; + RedHat) + rpm -qa | grep docker-ce-cli -q + ;; + esac + if [ $? -eq 0 ]; then + DockerEngineVersionList + DOCKER_INSTALLED_VERSION=$(docker -v | grep -Eo "[0-9][0-9].[0-9][0-9].[0-9]{1,2}") + DOCKER_VERSION_LATEST=$(cat $DockerVersionFile | head -n 1) + if [[ ${DOCKER_INSTALLED_VERSION} == ${DOCKER_VERSION_LATEST} ]]; then + if [ ${DOCKER_VERSION_INSTALL_LATEST} = "True" ]; then + echo -e '\n\033[32m---------- 检测到已安装最新版本的 Docker Engine,跳过安装 ----------\033[0m' + ConfigureImageAccelerator + systemctl status docker | grep running -q + if [ $? -eq 0 ]; then + systemctl restart docker + fi + echo '' + systemctl enable --now docker >/dev/null 2>&1 + DockerCompose + ShowVersion + AuthorSignature + exit + else + CHOICE_E=$(echo -e '\n\033[37m└ 检测到已安装最新版本的 Docker Engine,是否继续安装其它版本 [ Y/n ]:\033[0m') + fi + else + if [ ${DOCKER_VERSION_INSTALL_LATEST} = "True" ]; then + CHOICE_E=$(echo -e '\n\033[37m└ 检测到已安装旧版本的 Docker Engine,是否覆盖安装为最新版本 [ Y/n ]:\033[0m') + else + CHOICE_E=$(echo -e '\n\033[37m└ 检测到已安装旧版本的 Docker Engine,是否继续安装其它版本 [ Y/n ]:\033[0m') + fi + fi + read -p "${CHOICE_E}" INPUT + [ -z ${INPUT} ] && INPUT=Y + case $INPUT in + [Yy]*) + echo -en '\n[\033[34m*\033[0m] 正在卸载之前的版本... ' + RemoveOldVersion + echo -e '\n\n[\033[32mOK\033[0m] 卸载完毕\n' + DockerEngineInstall + ;; + [Nn]*) ;; + *) + echo -e '\n\033[33m---------- 输入错误,默认不覆盖安装 ----------\033[0m\n' + ;; + esac + rm -rf $DockerVersionFile + else + RemoveOldVersion + DockerEngineInstall + fi + ConfigureImageAccelerator + systemctl stop docker >/dev/null 2>&1 + systemctl enable --now docker >/dev/null 2>&1 +} +function DockerEngineInstall() { + if [ ${DOCKER_VERSION_INSTALL_LATEST} == "True" ]; then + case ${SYSTEM_FACTIONS} in + Debian) + apt-get install -y docker-ce docker-ce-cli containerd.io + ;; + RedHat) + yum install -y docker-ce docker-ce-cli containerd.io + ;; + esac + else + DockerEngineVersionList + echo -e '\n\033[32m --------- 请选择你要安装的版本,如:19.03.15 ---------- \033[0m\n' + cat $DockerVersionFile + echo -e '\n注:以上可供选择的安装版本由官方源提供,若系统过新可能无法安装较旧的版本' + while true; do + CHOICE_F=$(echo -e '\n\033[37m└ 请根据上面的列表,输入你想要安装的具体版本号:\033[0m\n') + read -p "${CHOICE_F}" DOCKER_VERSION + echo '' + cat $DockerVersionFile | grep -Ew "${DOCKER_VERSION}" >/dev/null 2>&1 + if [ $? -eq 0 ]; then + echo ${DOCKER_VERSION} | grep -Ew '[1,2][0,8,9].[0,1][0-9].[0-9]{1,2}' >/dev/null 2>&1 + if [ $? -eq 0 ]; then + rm -rf $DockerVersionFile + break + else + echo -e '\033[33m ---------- 请输入正确的版本号 ---------- \033[0m' + fi + else + echo -e '\033[33m ---------- 输入错误请重新输入 ---------- \033[0m' + fi + done + case ${SYSTEM_FACTIONS} in + Debian) + CheckVersion=$(echo ${DOCKER_VERSION} | cut -c1-2) + CheckSubversion=$(echo ${DOCKER_VERSION} | cut -c4-5) + case ${CheckVersion} in + 21 | 20 | 19) + INSTALL_JUDGMENT="5:" + ;; + 18) + if [ ${CheckSubversion} == "09" ]; then + INSTALL_JUDGMENT="5:" + else + INSTALL_JUDGMENT="" + fi + ;; + *) + INSTALL_JUDGMENT="" + ;; + esac + apt-get install -y docker-ce=${INSTALL_JUDGMENT}${DOCKER_VERSION}* docker-ce-cli=5:${DOCKER_VERSION}* containerd.io + ;; + RedHat) + yum install -y docker-ce-${DOCKER_VERSION} docker-ce-cli-${DOCKER_VERSION} containerd.io + ;; + esac + fi +} + +## 修改 Docker Hub 源 +function ConfigureImageAccelerator() { + if [ ${REGISTRY_SOURCE_OFFICIAL} = "False" ]; then + if [ -d $DockerDir ] && [ -e $DockerConfig ]; then + if [ -e $DockerConfigBackup ]; then + CHOICE_BACKUP=$(echo -e "\n\033[37m└ 检测到已备份的 Docker 配置文件,是否覆盖备份 [ Y/n ]:\033[0m") + read -p "${CHOICE_BACKUP}" INPUT + [ -z ${INPUT} ] && INPUT=Y + case $INPUT in + [Yy]*) + cp -rf $DockerConfig $DockerConfigBackup >/dev/null 2>&1 + ;; + [Nn]*) ;; + *) + echo -e '\n\033[33m------------ 输入错误,默认不覆盖 ------------\033[0m ' + ;; + esac + else + cp -rf $DockerConfig $DockerConfigBackup >/dev/null 2>&1 + echo -e "\n\033[37m└ 已备份原有 Docker 配置文件至 $DockerConfigBackup ...... \033[0m" + fi + sleep 2s + else + mkdir -p $DockerDir >/dev/null 2>&1 + touch $DockerConfig + fi + echo -e '{\n "registry-mirrors": ["https://SOURCE"]\n}' >$DockerConfig + sed -i "s/SOURCE/$REGISTRY_SOURCE/g" $DockerConfig + systemctl daemon-reload + fi +} + +## 安装 Docker Compose +function DockerCompose() { + if [ ${DOCKER_COMPOSE} == "True" ]; then + [ -e $DockerCompose ] && rm -rf $DockerCompose + if [ ${Arch} = "x86_64" ]; then + echo -e '' + if [ ${DOCKER_COMPOSE_DOWNLOAD_PROXY} = "True" ]; then + curl -L ${PROXY_URL}${DOCKER_COMPOSE_DOWNLOAD_URL} -o $DockerCompose + else + curl -L ${DOCKER_COMPOSE_DOWNLOAD_URL} -o $DockerCompose + fi + chmod +x $DockerCompose + else + echo -e '\n[*] 正在通过 pip 安装 Docker Compose ......\n' + if [ ${SYSTEM_FACTIONS} = ${SYSTEM_DEBIAN} ]; then + apt-get install -y python3-pip python3-dev gcc libffi-dev openssl >/dev/null 2>&1 + elif [ ${SYSTEM_FACTIONS} = ${SYSTEM_REDHAT} ]; then + yum install -y python3-pip python3-devel gcc libffi-devel openssl-devel >/dev/null 2>&1 + fi + pip3 install --upgrade pip + if [ ${DOCKER_COMPOSE_DOWNLOAD_PROXY} = "True" ]; then + pip3 install -i https://mirrors.aliyun.com/pypi/simple docker-compose + else + pip3 install docker-compose + fi + [ $? -ne 0 ] && echo -e "\n\033[31m---------- Docker Compose 安装失败,检测到当前处理器为 ${Arch} 架构无法保证 100% 安装成功,自行查看 pip 报错原因 ----------\033[0m\n" + fi + echo -e '' + else + echo -e '' + fi +} + +## 查看版本并验证安装结果 +function ShowVersion() { + echo -e '\033[32m---------- 验证安装版本 ----------\033[0m\n' + docker -v + VERIFICATION_DOCKER=$? + [ ${DOCKER_COMPOSE} = "True" ] && docker-compose -v + if [ ${VERIFICATION_DOCKER} -eq 0 ]; then + echo -e '\n\033[32m---------- 安装完成 ----------\033[0m' + else + echo -e '\n\033[31m---------- 安装失败 ----------\033[0m' + exit + fi + systemctl status docker | grep running -q + if [[ $? -ne 0 ]]; then + sleep 2 + systemctl disable --now docker >/dev/null 2>&1 + sleep 2 + systemctl enable --now docker >/dev/null 2>&1 + sleep 2 + systemctl status docker | grep running -q + if [[ $? -ne 0 ]]; then + echo -e '\n\033[31m [ERROR] 检测到 Docker 服务启动异常,可能由于重复安装相同版本导致\033[0m' + echo -e '\n\033[31m 请执行 systemctl start docker 或 service docker start 命令尝试启动\033[0m' + echo -e '\n\033[31m 官方安装文档:https://docs.docker.com/engine/install\033[0m' + fi + fi +} + +function ChooseMirrors() { + echo -e '+---------------------------------------------------+' + echo -e '| |' + echo -e '| ============================================= |' + echo -e '| |' + echo -e '| 欢迎使用 Docker 一键安装脚本 |' + echo -e '| |' + echo -e '| ============================================= |' + echo -e '| |' + echo -e '+---------------------------------------------------+' + echo -e '' + echo -e '#####################################################' + echo -e '' + echo -e ' 提供以下 Docker CE 和 Docker Hub 源可供选择:' + echo -e '' + echo -e '#####################################################' + echo -e '' + echo -e ' Docker CE' + echo -e '' + echo -e ' ❖ 阿里云 1)' + echo -e ' ❖ 腾讯云 2)' + echo -e ' ❖ 华为云 3)' + echo -e ' ❖ Azure 4)' + echo -e ' ❖ 网易 5)' + echo -e ' ❖ 清华大学 6)' + echo -e ' ❖ 中科大 7)' + echo -e ' ❖ 官方 8)' + echo -e '' + echo -e ' Docker Hub' + echo -e '' + echo -e ' ❖ 阿里云(北京) 1)' + echo -e ' ❖ 阿里云(杭州) 2)' + echo -e ' ❖ 阿里云(成都) 3)' + echo -e ' ❖ 阿里云(广州) 4)' + echo -e ' ❖ 阿里云(香港) 5)' + echo -e ' ❖ 腾讯云 6)' + echo -e ' ❖ 华为云 7)' + echo -e ' ❖ Azure 8)' + echo -e ' ❖ DaoCloud 9)' + echo -e ' ❖ 中科大 10)' + echo -e ' ❖ 谷歌云 11)' + echo -e ' ❖ 官方 12)' + echo -e '' + echo -e '#####################################################' + echo -e '' + echo -e " 运行环境 ${SYSTEM_NAME} ${SYSTEM_VERSION_NUMBER} ${SYSTEM_ARCH}" + echo -e " 系统时间 $(date "+%Y-%m-%d %H:%M:%S")" + echo -e '' + echo -e '#####################################################' + CHOICE_A=$(echo -e '\n\033[37m└ 请选择并输入你想使用的 Docker CE 源 [ 1~8 ]:\033[0m') + read -p "${CHOICE_A}" INPUT + case $INPUT in + 1) + SOURCE="mirrors.aliyun.com/docker-ce" + ;; + 2) + SOURCE="mirrors.cloud.tencent.com/docker-ce" + ;; + 3) + SOURCE="repo.huaweicloud.com/docker-ce" + ;; + 4) + SOURCE="mirror.azure.cn/docker-ce" + ;; + 5) + SOURCE="mirrors.163.com/docker-ce" + ;; + 6) + SOURCE="mirrors.tuna.tsinghua.edu.cn/docker-ce" + ;; + 7) + SOURCE="mirrors.ustc.edu.cn/docker-ce" + ;; + 8) + SOURCE="download.docker.com" + ;; + *) + SOURCE="mirrors.aliyun.com/docker-ce" + echo -e '\n\033[33m---------- 输入错误,默认使用阿里云 ----------\033[0m' + sleep 1s + ;; + esac + ## 是否手动选择安装版本 + CHOICE_C=$(echo -e '\n\033[37m └ 是否安装最新版本的 Docker Engine [ Y/n ]:\033[0m') + read -p "${CHOICE_C}" INPUT + [ -z ${INPUT} ] && INPUT=Y + case $INPUT in + [Yy]*) + DOCKER_VERSION_INSTALL_LATEST="True" + ;; + [Nn]*) + DOCKER_VERSION_INSTALL_LATEST="False" + if [ ${SOURCE} != "download.docker.com" ]; then + echo -e "\n\033[33m ---------- Docker CE 源已替换成官方源 ---------- \033[0m" + fi + ;; + *) + DOCKER_VERSION_INSTALL_LATEST="True" + echo -e '\n\033[33m---------- 输入错误,默认安装最新版本 ----------\033[0m' + ;; + esac + CHOICE_B=$(echo -e '\n\033[37m└ 请选择并输入你想使用的 Docker Hub 源 [ 1~12 ]:\033[0m') + read -p "${CHOICE_B}" INPUT + case $INPUT in + 1) + REGISTRY_SOURCE="registry.cn-beijing.aliyuncs.com" + REGISTRY_SOURCE_OFFICIAL="False" + ;; + 2) + REGISTRY_SOURCE="registry.cn-hangzhou.aliyuncs.com" + REGISTRY_SOURCE_OFFICIAL="False" + ;; + 3) + REGISTRY_SOURCE="registry.cn-chengdu.aliyuncs.com" + REGISTRY_SOURCE_OFFICIAL="False" + ;; + 4) + REGISTRY_SOURCE="registry.cn-guangzhou.aliyuncs.com" + REGISTRY_SOURCE_OFFICIAL="False" + ;; + 5) + REGISTRY_SOURCE="registry.cn-hongkong.aliyuncs.com" + REGISTRY_SOURCE_OFFICIAL="False" + ;; + 6) + REGISTRY_SOURCE="mirror.ccs.tencentyun.com" + REGISTRY_SOURCE_OFFICIAL="False" + ;; + 7) + REGISTRY_SOURCE="0bab0ef02500f24b0f31c00db79ffa00.mirror.swr.myhuaweicloud.com" + REGISTRY_SOURCE_OFFICIAL="False" + ;; + 8) + REGISTRY_SOURCE="dockerhub.azk8s.com" + REGISTRY_SOURCE_OFFICIAL="False" + ;; + 9) + REGISTRY_SOURCE="f1361db2.m.daocloud.io" + REGISTRY_SOURCE_OFFICIAL="False" + ;; + 10) + REGISTRY_SOURCE="docker.mirrors.ustc.edu.cn" + REGISTRY_SOURCE_OFFICIAL="False" + ;; + 11) + REGISTRY_SOURCE="gcr.io" + REGISTRY_SOURCE_OFFICIAL="False" + ;; + 12) + REGISTRY_SOURCE="registry.docker-cn.com" + REGISTRY_SOURCE_OFFICIAL="True" + ;; + *) + REGISTRY_SOURCE="registry.cn-hangzhou.aliyuncs.com" + REGISTRY_SOURCE_OFFICIAL="False" + echo -e '\n\033[33m---------- 输入错误,默认使用阿里云(杭州) ----------\033[0m' + sleep 1s + ;; + esac + if [ -x $DockerCompose ]; then + CHOICE_D=$(echo -e '\n\033[37m└ 检测到已安装 Docker Compose ,是否覆盖安装 [ Y/n ]:\033[0m') + else + CHOICE_D=$(echo -e '\n\033[37m└ 是否安装 Docker Compose [ Y/n ]:\033[0m') + fi + read -p "${CHOICE_D}" INPUT + [ -z ${INPUT} ] && INPUT=Y + case $INPUT in + [Yy]*) + DOCKER_COMPOSE="True" + CHOICE_D1=$(echo -e '\n\033[37m └ 是否使用国内代理进行下载 [ Y/n ]:\033[0m') + read -p "${CHOICE_D1}" INPUT + [ -z ${INPUT} ] && INPUT=Y + case $INPUT in + [Yy]*) + DOCKER_COMPOSE_DOWNLOAD_PROXY="True" + ;; + [Nn]*) + DOCKER_COMPOSE_DOWNLOAD_PROXY="False" + ;; + *) + DOCKER_COMPOSE_DOWNLOAD_PROXY="False" + echo -e '\n\033[33m---------- 输入错误,默认不使用 ----------\033[0m\n' + ;; + esac + ;; + [Nn]*) + DOCKER_COMPOSE="False" + ;; + *) + DOCKER_COMPOSE="False" + echo -e '\n\033[33m---------- 输入错误,默认不安装 ----------\033[0m\n' + ;; + esac + echo -e '' + + [ ${SYSTEM_FACTIONS} == ${SYSTEM_REDHAT} ] && TurnOffFirewall +} + +Combin_Function diff --git a/DockerInstallation.x b/DockerInstallation.x new file mode 100644 index 0000000..8c2f95e Binary files /dev/null and b/DockerInstallation.x differ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d159169 --- /dev/null +++ b/LICENSE @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/README.md b/README.md new file mode 100644 index 0000000..5d3182c --- /dev/null +++ b/README.md @@ -0,0 +1,144 @@ +# LinuxMirrors + + +ㅤ +- __`GNU/Linux` 一键更换国内软件源脚本__ +- __本项目旨在为从事计算机相关行业的朋友们提供便利__ +- __理论支持所有架构的环境,`arm64` 环境已经过测试__ +> 🏷️点击上方图标可快速跳转至本项目所发布在的其它仓库或博客 + +### 更新日志 +- __2021 / 06 / 05__ +ㅤ新增对于 Red Hat Enterprise Linux 的全面适配。 +- __2021 / 05 / 30__ +ㅤ新增选择软件源的 WEB 协议功能,修复了一些错误。 +- __2021 / 05 / 05__ +ㅤ新增关闭防火墙功能。 +- __2021 / 04 / 24__ +ㅤ新增基于 CentOS 的添加 EPEL 扩展源功能,修复了一些错误。 +- __2021 / 04 / 22__ +ㅤ重新定义了备份原有源功能,可以通过检测判断是否执行覆盖备份操作。 + +*** + +### 已适配的 GNU/Linux 发行版 Linux Logo + + + + + + + + + + + + + + + + + + + + + + + + + + + +
支持
版本
+
 Debian8.0 ~ 11.0
 Ubuntu16.04 ~ 21.04
 Kali Linux2.0 ~ 2021.2
 RHEL7.0 ~ 8.4
 CentOS7.0 ~ 8.4
 Fedora28 ~ 34
+ +> 目前仅支持上述基于 Debian 与 Redhat 系的发行版和及其部分衍生版本 \ +> 同样支持上述版本中拥有相同底层核心的其它发行版,例如 [`Armbian`](https://www.armbian.com) [`Kubuntu`](https://kubuntu.org) [`Oracle Linux`](https://www.oracle.com/cn/technical-resources) 等 + +### 脚本当前使用的开源镜像站 +| | 镜像站名称 | 镜像站地址 | IPv6 | Kali Linux | Fedora | EPEL | +| :------: | :------: | :------: | :------: | :------: | :------: | :------: | +| 1 | 阿里云 | [mirrors.aliyun.com](https://developer.aliyun.com/special/mirrors/notice) | √ | √ | √ | √ | +| 2 | 腾讯云 | [mirrors.cloud.tencent.com](https://mirrors.cloud.tencent.com) | √ | √ | √ | √ | +| 3 | 华为云 | [mirrors.huaweicloud.com](https://mirrors.huaweicloud.com) | √ | √ | √ | √ | +| 4 | 网易 | [mirrors.163.com](https://mirrors.163.com) | | | √ | | +| 5 | 搜狐 | [mirrors.sohu.com](https://mirrors.sohu.com) | | | | | +| 6 | 清华大学 | [mirrors.tuna.tsinghua.edu.cn](https://mirrors.tuna.tsinghua.edu.cn) | √ | √ | √ | √ | +| 7 | 浙江大学 | [mirrors.zju.edu.cn](https://mirrors.zju.edu.cn) | | √ | √ | √ | +| 8 | 南京大学 | [mirrors.nju.edu.cn](https://mirrors.nju.edu.cn) | | √ | √ | √ | +| 9 | 重庆大学 | [mirrors.cqu.edu.cn](https://mirrors.cqu.edu.cn) | | √ | √ | √ | +| 10 | 兰州大学 | [mirror.lzu.edu.cn](https://mirror.lzu.edu.cn) | √ | | √ | √ | +| 11 | 上海交通大学 | [mirror.sjtu.edu.cn](https://mirror.sjtu.edu.cn) | √ | √ | √ | √ | +| 12 | 哈尔滨工业大学 | [mirrors.hit.edu.cn](https://mirrors.hit.edu.cn) | √ | √ | | √ | +| 13 | 中国科学技术大学 | [mirrors.ustc.edu.cn](https://mirrors.ustc.edu.cn) | √ | √ | √ | √ | +> 所有镜像站均支持 `Debian` `Ubuntu` `CentOS` 软件源,建议优先选择由企业提供的软件源\ +> 如果使用过程中脚本不能正常输出中文内容则可对照此列表使用,顺序与脚本一致 + +### 脚本执行流程 +- └ 选择国内源 `交互` + - └ 检测如果是 RHEL或CentOS 系统选择是否安装/覆盖 EPEL 扩展国内源 `交互` +- └ 选择软件源使用的 WEB 协议 `交互` +- └ 检测 防火墙 和 SELINUX 如果开启并且系统是 RHEL或CentOS 选择是否关闭 `交互` +- └ 备份原有源 + - └ 检测如果存在重复的备份文件选择是否覆盖 `交互` +- └ 更换国内源 +- └ 选择是否更新软件包 `交互` + - └ 选择是否清理已下载的软件包缓存 `交互` + +*** + +### 如何使用 +> 1. 完整复制下面的命令到终端按回车键即可执行,若无法安装 `curl` 软件包可复制源码到本地后手动执行。 +> 2. 为了适配所有环境,建议使用 `Root` 用户执行脚本,切换命令为 `sudo -i` ,如遇报错请查看常见问题与帮助。 +> 3. 如果您使用的环境没有安装或不支持简体中文环境,请通过 `SSH客户端工具` 使用,否则将无法正确选择交互内容。 +> 4. 执行脚本过程中会自动备份原有源无需手动备份,期间会在终端输出多个主观选择交互内容,可按回车键快速确认。 +> 5. 脚本支持在原有源配置错误或者不存在的情况下使用,并且可以重复使用;脚本变更的软件源默认使用 `Http 协议`。 + +- `GNU/Linux` 一键更换国内软件源脚本 + + bash <(curl -sSL https://gitee.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh) +> __注意:__ +> - _Debian 系 Linux 默认注释了源码仓库和预发布软件源,若需启用可将 list 源文件中相关内容的所在行 `取消注释`。_ +> - _RedHat 系 Linux 配置了所有可以配置的仓库,但有一些仓库默认没有启用,若需启用可将 repo 源文件中的 `enabled=0`修改成 `enabled=1`。_ + +*** + +### 其它脚本 +- `Docker` 一键安装脚本 + + bash <(curl -sSL https://gitee.com/SuperManito/LinuxMirrors/raw/main/DockerInstallation.sh) + +> `Docker CE`:Docker Community Edition 镜像仓库,用于下载并安装 Docker 相关软件包。\ +> `Docker Hub`:Docker Hub 镜像仓库,默认为官方提供的公共库,用于切换下载镜像时的来源仓库,简称镜像加速器。 + +> _注意:脚本集成安装 `Docker Engine`与 `Docker Compose`,可手动选择安装版本和下载源,还可手动选择镜像加速器,支持国内外服务器环境和 `ARM`架构处理器环境使用。_ + +*** + +### 常见问题与帮助 +- 1. 如果提示 `Command 'curl' not found` 则说明当前未安装 `curl` 软件包,安装命令如下: + + sudo apt install -y curl 或 sudo yum install -y curl + +- 2. 如果提示 `Command 'wget' not found` 则说明当前未安装 `wget` 软件包,安装命令如下: + + sudo apt install -y wget 或 sudo yum install -y wget + +- 3. 如果提示 `bash: /proc/self/fd/11: No such file or directory`,请切换至 `Root` 用户执行。 + +*** + +### 捐助作者 +微信赞赏码
+> 项目已设立开源许可协议,传播时需在显著位置标注来源和作者,请尊重本人的知识成果\ +> 建议通过命令直接调用脚本,如有意见与建议您可以提交至 __Issues__,谢谢 + +*** + +### License +Copyright © 2021, [SuperManito](https://github.com/SuperManito). Released under the [GPL-2.0](https://github.com/SuperManito/LinuxMirrors/blob/main/LICENSE). + +*** + +__如果您觉得这个项目不错的话可以在右上角给颗⭐吗?方便分享给更多的朋友吗?__ diff --git a/icon/centos.svg b/icon/centos.svg new file mode 100644 index 0000000..bea939d --- /dev/null +++ b/icon/centos.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/icon/csdn.png b/icon/csdn.png new file mode 100644 index 0000000..019df09 Binary files /dev/null and b/icon/csdn.png differ diff --git a/icon/debian.svg b/icon/debian.svg new file mode 100644 index 0000000..88af0b1 --- /dev/null +++ b/icon/debian.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/icon/fedora.ico b/icon/fedora.ico new file mode 100644 index 0000000..c39d252 Binary files /dev/null and b/icon/fedora.ico differ diff --git a/icon/gitee.svg b/icon/gitee.svg new file mode 100644 index 0000000..9ed065a --- /dev/null +++ b/icon/gitee.svg @@ -0,0 +1,17 @@ + + + + logo-black + Created with Sketch. + + \ No newline at end of file diff --git a/icon/github-1.svg b/icon/github-1.svg new file mode 100644 index 0000000..18e9450 --- /dev/null +++ b/icon/github-1.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/icon/github-2.svg b/icon/github-2.svg new file mode 100644 index 0000000..d396db9 --- /dev/null +++ b/icon/github-2.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/icon/kali.svg b/icon/kali.svg new file mode 100644 index 0000000..71ce603 --- /dev/null +++ b/icon/kali.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/icon/linux.svg b/icon/linux.svg new file mode 100644 index 0000000..bebde8d --- /dev/null +++ b/icon/linux.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/icon/redhat.svg b/icon/redhat.svg new file mode 100644 index 0000000..c49accd --- /dev/null +++ b/icon/redhat.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/icon/thanks.jpg b/icon/thanks.jpg new file mode 100644 index 0000000..11629e1 Binary files /dev/null and b/icon/thanks.jpg differ diff --git a/icon/ubuntu.svg b/icon/ubuntu.svg new file mode 100644 index 0000000..c7a7ed0 --- /dev/null +++ b/icon/ubuntu.svg @@ -0,0 +1 @@ + \ No newline at end of file