When this script is useful
switch-centos7-repo.sh is meant for old CentOS 7 hosts where yum stops working because the default repository URLs have expired, moved, or become unreachable from the current region.
It is especially useful on inherited machines, archived internal systems, and maintenance hosts that still need package installs or dependency recovery before a larger change window.
What the script changes
The core job is to replace stale yum repository definitions with a working mirror source. That usually means rewriting repo files, refreshing yum metadata, and making package installation available again.
Because repository changes affect every later package install, this is the kind of script that should be reviewed once, documented clearly, and then reused consistently across similar legacy hosts.
- Run the script with root privileges
- Review the selected mirror and repo file changes
- Run yum makecache or a small install test
- Document the chosen source for future maintenance
Recommended operating pattern
A good pattern is to start with the one-liner from helper.sh, confirm the rewritten repository files, then validate yum with a safe command such as yum makecache or a basic package query.
If the host is important, back up the previous repo files first and record which mirror source was finally chosen. CentOS 7 is end-of-life, so repository recovery should be treated as a maintenance bridge, not the final state.