System maintenance

switch-centos7-repo.sh

A helper.sh-hosted CentOS 7 repository switching script that helps replace old or unreachable yum repos with a working mirror source so package installation and updates can continue.

One-liner

curl -fsSL -o switch-centos7-repo.sh helper.sh/switch-centos7-repo.sh && sudo bash switch-centos7-repo.sh
curl -fsSL helper.sh/switch-centos7-repo.sh | sudo bash -s -- --source mirrors.aliyun.com --source-vault mirrors.aliyun.com

Requirements

  • CentOS 7 host
  • root privileges or sudo
  • yum-based package management
  • Outbound network access

Best for

  • Restore yum on an old CentOS 7 host after the default mirror stops working
  • Prepare an archived CentOS 7 machine for package installation or updates
  • Replace dead repository URLs before a maintenance window or handoff

Highlights

  • Hosted directly on helper.sh for copy-and-run access
  • Useful when CentOS 7 mirrors have moved, expired, or become region-dependent
  • Pairs well with troubleshooting guides for old production hosts

Recommended procedure

  1. Run the helper.sh command with root privileges.
  2. Let the script rewrite the repo files and switch to a usable mirror.
  3. Refresh yum metadata and confirm package installation works again.
  4. Review the changed repo definitions before using the host in production.

Safety notes

  • CentOS 7 is end-of-life. Treat this as a maintenance recovery measure, not a long-term platform strategy.
  • Review the selected mirror and repo file changes before rolling into production.
  • Keep a backup of the existing repo configuration when working on critical hosts.

Scenario article

How to recover yum on old CentOS 7 hosts by switching repository mirrors

A practical guide for using switch-centos7-repo.sh when CentOS 7 default repositories are no longer usable and you need package installs to work again.

Related topics

CentOS 7 maintenance and recovery

Keep legacy CentOS 7 hosts installable and maintainable when yum repositories fail, mirrors expire, or Docker data needs to be moved off a crowded disk.

Open topic

Problem pages

How to fix CentOS 7 yum 404 errors

Restore package installation on old CentOS 7 hosts when the default repositories no longer work.

Open page

When should I switch CentOS 7 repositories

Switch repository definitions when old CentOS 7 mirrors fail, time out, or no longer return valid metadata.

Open page