Skip to content

Instantly share code, notes, and snippets.

@lamoboos223
Created January 20, 2025 23:07
Show Gist options
  • Save lamoboos223/b329997a75c596fb6e412b1cc8c23bde to your computer and use it in GitHub Desktop.
Save lamoboos223/b329997a75c596fb6e412b1cc8c23bde to your computer and use it in GitHub Desktop.
This is for centos7 old mirror repository
#!/bin/bash
# Backup existing repo files
echo "Creating backup of existing repo files..."
cd /etc/yum.repos.d/
mkdir -p backup
mv CentOS-* backup/
# Create new CentOS-Base.repo file
echo "Creating new CentOS-Base.repo file..."
cat > /etc/yum.repos.d/CentOS-Base.repo << 'EOL'
[base]
name=CentOS-7 - Base
baseurl=https://vault.centos.org/7.9.2009/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[updates]
name=CentOS-7 - Updates
baseurl=https://vault.centos.org/7.9.2009/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[extras]
name=CentOS-7 - Extras
baseurl=https://vault.centos.org/7.9.2009/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
EOL
# Clean and update yum cache
echo "Cleaning yum cache..."
yum clean all
echo "Making new cache..."
yum makecache
# Install EPEL repository
echo "Installing EPEL repository..."
yum install -y epel-release
# Install nano
echo "Installing nano..."
yum install -y nano
echo "Script completed!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment