System maintenance

switch-centos7-repo.sh

A bundled copy of the upstream LinuxMirrors script for repository recovery. On CentOS 7 it rewrites yum repo definitions and refreshes metadata; it can also disable firewalld and SELinux if accepted at a prompt. CentOS 7 remains end-of-life.

One-liner

curl -fL 'https://www.helper.sh/switch-centos7-repo.sh' -o './switch-centos7-repo.sh'

This command downloads the bundled file only; it does not run it. Inspect the saved source and compare its version before deciding whether to execute it.

Check the file you downloaded

Compare a saved file with the exact bytes bundled in this page’s build. The file stays in this tab; this tool does not upload or persist it. Maximum 2 MiB.

Expected SHA-256
4a15976771c49d4680122d6390aa19da3b4379bb2bc086d5738472340155930c

Bundled byte count: 207954

Save checksum file

Save the script and checksum in the same directory. On Linux with GNU Coreutils, the command below checks the saved bytes only; it does not run the script. Keep the original filename for this command.

sha256sum --check './switch-centos7-repo.sh.sha256'

No comparison yet.

The checksum and script come from the same site, not an independent signature. A match does not prove safety, authenticity of upstream dependencies, or suitability for your host. Mutable remote dependencies need separate review.

Read validation and limitations

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.

Compatibility and limits

  • This bundled upstream script supports multiple Linux distributions, but this page documents its CentOS 7 yum use only. CentOS Linux 7 is end-of-life; a mirror switch restores access to archived packages, not security maintenance.
  • It requires root, Bash, systemctl on the firewalld path, yum, and network access. It is interactive. There is no dry-run or automatic rollback. The default --backup true creates /etc/yum.repos.d.bak, but an existing backup triggers a prompt that can overwrite it.
  • Important: when firewalld is active, the default answer to the prompt about disabling firewalld and SELinux is Yes. Review that prompt carefully or explicitly pass --close-firewall false. Package update and cache-cleaning actions are separate prompts/options; do not approve them unless intended.

Files, services, and data affected

  • Backs up repository files to /etc/yum.repos.d.bak when enabled, removes/replaces distribution repository definitions under /etc/yum.repos.d, and then runs yum makecache.
  • May install EPEL if selected. If package upgrade is explicitly enabled, runs yum update -y --skip-broken; if cache cleanup is enabled, runs yum autoremove -y and yum clean packages -y.
  • If accepted at the prompt, disables firewalld immediately and persistently, edits /etc/selinux/config from enforcing to disabled, and runs setenforce 0. These are security posture changes unrelated to choosing a mirror.

Read-only verification

  • Before running, inspect the host release, `systemctl is-active firewalld`, `getenforce`, `/etc/selinux/config`, and `ls -la /etc/yum.repos.d /etc/yum.repos.d.bak`.
  • After an approved repo-only change, review `diff -ru /etc/yum.repos.d.bak /etc/yum.repos.d`, inspect enabled repos with `yum repolist -v`, and check the command exit status and `yum makecache` output.
  • Re-check `systemctl is-enabled firewalld`, `systemctl is-active firewalld`, and `getenforce`; a successful yum metadata refresh does not establish that the host remains protected or receives security fixes.

If it fails

If metadata refresh fails, do not immediately retry with package upgrades. Preserve current and backup repo files; inspect `yum repolist -v`, DNS/network reachability, and the exact repository error. Restore repo files manually from a reviewed backup if needed. If firewall or SELinux changed, re-enable only under the host policy and validate remote access before ending maintenance.

Download, inspect, then verify the version before execution. A hash only identifies these exact bytes; it does not prove safety. Piped commands run remote content immediately, and upstream dependencies can change.

Related topics

CentOS 7: choose a recovery task

Separate repository failures, SSH access problems and Docker storage pressure before changing an end-of-life host.

Open topic

Problem pages

CentOS 7 yum 404: inspect the failing repository first

Distinguish an archived CentOS mirror from a third-party URL, DNS, TLS or network failure before rewriting repo files.

Open page