#!/bin/bash
-- coding: utf-8 --
Author: make.han
Email: CIASM@CIASM
Date: 2024/07/31
openEuler repo 20 21 22 23 24
echo “Delete default all repo”
rm -rf /etc/yum.repos.d/*
repo_name=huawei
basearch=‘$basearch’
repo_url=‘http://repo.huaweicloud.com’
openeuler_catalogue=openeuler
check system version
NAME=$(cat /etc/os-release | grep “^NAME=” | cut -d’=’ -f2 | tr -d ‘"’)
VERSION_ID=$(cat /etc/os-release | grep “^VERSION_ID=” | cut -d’=’ -f2 | tr -d ‘"’)
ADDITIONAL_TEXT=$(cat /etc/os-release | grep “^VERSION=” | cut -d’(’ -f2 | cut -d’)’ -f1)
Output current system version information
echo “${NAME}-${VERSION_ID}-${ADDITIONAL_TEXT}”
echo “add new repo”
cat <>/etc/yum.repos.d/openEuler.repo
[$repo_name-OS]
name=$repo_name-OS
baseurl=$repo_url/$openeuler_catalogue/${NAME}-${VERSION_ID}-${ADDITIONAL_TEXT}/OS/$basearch/
enabled=1
gpgcheck=1
gpgkey=$repo_url/$openeuler_catalogue/${NAME}-${VERSION_ID}-${ADDITIONAL_TEXT}/OS/$basearch/RPM-GPG-KEY-openEuler
[$repo_name-everything]
name=$repo_name-everything
baseurl=$repo_url/$openeuler_catalogue/${NAME}-${VERSION_ID}-${ADDITIONAL_TEXT}/everything/$basearch/
enabled=1
gpgcheck=1
gpgkey=$repo_url/$openeuler_catalogue/${NAME}-${VERSION_ID}-${ADDITIONAL_TEXT}/everything/$basearch/RPM-GPG-KEY-openEuler
[$repo_name-EPOL]
name=$repo_name-EPOL
baseurl=$repo_url/$openeuler_catalogue/${NAME}-${VERSION_ID}-${ADDITIONAL_TEXT}/EPOL/main/$basearch/
enabled=1
gpgcheck=1
gpgkey=$repo_url/$openeuler_catalogue/${NAME}-${VERSION_ID}-${ADDITIONAL_TEXT}/OS/$basearch/RPM-GPG-KEY-openEuler
[$repo_name-debuginfo]
name=$repo_name-debuginfo
baseurl=$repo_url/$openeuler_catalogue/${NAME}-${VERSION_ID}-${ADDITIONAL_TEXT}/debuginfo/$basearch/
enabled=1
gpgcheck=1
gpgkey=$repo_url/$openeuler_catalogue/${NAME}-${VERSION_ID}-${ADDITIONAL_TEXT}/debuginfo/$basearch/RPM-GPG-KEY-openEuler
[$repo_name-source]
name=$repo_name-source
baseurl=$repo_url/$openeuler_catalogue/${NAME}-${VERSION_ID}-${ADDITIONAL_TEXT}/source/
enabled=1
gpgcheck=1
gpgkey=$repo_url/$openeuler_catalogue/${NAME}-${VERSION_ID}-${ADDITIONAL_TEXT}/source/RPM-GPG-KEY-openEuler
[$repo_name-update]
name=$repo_name-update
baseurl=$repo_url/$openeuler_catalogue/${NAME}-${VERSION_ID}-${ADDITIONAL_TEXT}/update/$basearch/
enabled=1
gpgcheck=1
gpgkey=$repo_url/$openeuler_catalogue/${NAME}-${VERSION_ID}-${ADDITIONAL_TEXT}/OS/$basearch/RPM-GPG-KEY-openEuler
[$repo_name-update-source]
name=$repo_name-update-source
baseurl=$repo_url/$openeuler_catalogue/${NAME}-${VERSION_ID}-${ADDITIONAL_TEXT}/update/source/
enabled=1
gpgcheck=1
gpgkey=$repo_url/$openeuler_catalogue/${NAME}-${VERSION_ID}-${ADDITIONAL_TEXT}/source/RPM-GPG-KEY-openEuler
EOF
echo “update repo”
yum clean all
yum makecache