-
-
Save whatafunc/9eea50f58eeec4a8c3f8f70ed3f1dd67 to your computer and use it in GitHub Desktop.
| #!/bin/bash | |
| sed -i 's/mirror.centos.org/vault.centos.org/g' /etc/yum.repos.d/*.repo | |
| sed -i 's/^#.*baseurl=http/baseurl=http/g' /etc/yum.repos.d/*.repo | |
| sed -i 's/^mirrorlist=http/#mirrorlist=http/g' /etc/yum.repos.d/*.repo | |
| sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* | |
| sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-* | |
| sed -i 's/^metalink=/#metalink=/g' /etc/yum.repos.d/epel*.repo | |
| sed -i 's|http://download.fedoraproject.org/pub/epel|https://archives.fedoraproject.org/pub/archive/epel|g' /etc/yum.repos.d/epel*.repo | |
| sed -i '/\[base\]/,/enabled=/ s/enabled=0/enabled=1/' /etc/yum.repos.d/CentOS-Base.repo | |
| yum clean all | |
| rm -rf /var/cache/yum | |
| yum makecache | |
| yum --releasever=7 --enablerepo=ol7_kvm_utils install -y python36-libvirt | |
| # it's a repo surgery script that redirects a dead CentOS 7 system to archive mirrors so yum works again, | |
| # then installs a KVM/virtualization Python library. Safe to run if you trust the source |
But plain yum update from the vault? It's bounded and safe in terms of compatibility. The concern is more about operational disruption than package conflicts.
.. and for the
yum update -y docker-ce docker-ce-cli containerd.io- this one can broke the OS? or yum checks what it gets prior to installing?
yumdoes check before installing — it resolves dependencies automatically. So if a new version ofdocker-cerequires a newercontainerd.ioorrunc, yum will pull those in together or warn you about conflicts. It won't blindly install something broken.
But there's a small caveat for Docker specifically:
Docker packages (docker-ce, docker-ce-cli) come from Docker's own repo, not the CentOS vault. So unlike the vault which is frozen, Docker's repo does have newer versions. There's a small chance a newer Docker release has a dependency that's slightly ahead of what your CentOS 7 system libraries can support — though in practice Docker has maintained good CentOS 7 compatibility for a long time.
The more realistic risk is operational, not OS breakage:
- Running containers will not be affected mid-update
- But the Docker daemon restarts after the update, which means:
- Containers that aren't set to
restart: alwayswill stop - Any active
docker buildordocker execsessions will drop
- Containers that aren't set to
Safest way to do it:
# 1. Check what version yum would install first (dry run)
yum update --assumeno docker-ce docker-ce-cli containerd.io
# 2. If it looks fine, do it during a maintenance window
yum update -y docker-ce docker-ce-cli containerd.ioThe --assumeno flag lets yum show you exactly what it plans to do without actually doing it. Good habit on a production-ish machine.
CentOS 7 Repository Fix Script Explained
Why This Script Is Needed
CentOS 7 reached end-of-life in June 2024, so the original mirror servers (
mirror.centos.org) were shut down. Packages are now only available at a vault/archive URL. This script surgically updates your repo config files soyumworks again.The Script
Step-by-Step Breakdown
Lines 2–5 — Fix CentOS Repo Files
mirror.centos.org→vault.centos.org(the official archive)baseurl=lines so they are activemirrorlist=lines (the mirror list no longer works)Lines 6–7 — Fix the Base Repo Specifically
Same intent as above, using a slightly different
sedpattern to handle theCentOS-Base.repofile format.Lines 8–9 — Fix EPEL Repo
EPEL (Extra Packages for Enterprise Linux) also went offline for CentOS 7:
metalink=(also dead)archives.fedoraproject.org(the EPEL archive)Line 10 — Re-enable the
[base]RepoFlips
enabled=0→enabled=1in case the base repo was disabled.Lines 11–13 — Refresh Yum Cache
Line 14 — Install the Target Package
Installs
python36-libvirt— Python 3.6 bindings for libvirt/KVM virtualization — using:--releasever=7: pins to CentOS 7 release files--enablerepo=ol7_kvm_utils: pulls from an Oracle Linux repo for KVM utilitiesSummary
Why This Script Is Needed
CentOS 7 reached end-of-life in June 2024, so the original mirror servers (
mirror.centos.org) were shut down. Packages are now only available at a vault/archive URL. This script surgically updates your repo config files soyumworks again.The Script
Step-by-Step Breakdown
Lines 2–5 — Fix CentOS Repo Files
mirror.centos.org→vault.centos.org(the official archive)baseurl=lines so they are activemirrorlist=lines (the mirror list no longer works)Lines 6–7 — Fix the Base Repo Specifically
Same intent as above, using a slightly different
sedpattern to handle theCentOS-Base.repofile format.Lines 8–9 — Fix EPEL Repo
EPEL (Extra Packages for Enterprise Linux) also went offline for CentOS 7:
metalink=(also dead)archives.fedoraproject.org(the EPEL archive)Line 10 — Re-enable the
[base]RepoFlips
enabled=0→enabled=1in case the base repo was disabled.Lines 11–13 — Refresh Yum Cache
Line 14 — Install the Target Package
Installs
python36-libvirt— Python 3.6 bindings for libvirt/KVM virtualization — using:--releasever=7: pins to CentOS 7 release files--enablerepo=ol7_kvm_utils: pulls from an Oracle Linux repo for KVM utilitiesSummary
[base]repo is enabledpython36-libvirtfrom KVM utils repo