-
Notifications
You must be signed in to change notification settings - Fork 5
/
centos6_repo_fix.sh
executable file
·56 lines (46 loc) · 1.7 KB
/
centos6_repo_fix.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
# Get the version so we know which repository to add
centos_version="$(cat /etc/redhat-release | awk '{print $3}')"
# Initialize varaibles; allow a user to specify another directory name for old unwanted CentOS repos
repodir_base="/etc/yum.repos.d"
repodir_old="${repodir_base}/${1:-old_repos}"
vault_repo="CentOS-Vault.${centos_version}.repo"
# Create the folder and move unwanted repo files to it
mkdir -p $repodir_old
find ${repodir_base}/CentOS*.repo -maxdepth 1 -type f -exec mv {} ${repodir_old} \;
# Generate the repo file for the current CentOS version
cat << EOF > ${repodir_base}/${vault_repo}
[C${centos_version}-base]
name=CentOS-${centos_version} - Base
baseurl=http://vault.centos.org/${centos_version}/os/\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=1
[C${centos_version}-updates]
name=CentOS-${centos_version} - Updates
baseurl=http://vault.centos.org/${centos_version}/updates/\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=1
[C${centos_version}-extras]
name=CentOS-${centos_version} - Extras
baseurl=http://vault.centos.org/${centos_version}/extras/\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=1
[C${centos_version}-contrib]
name=CentOS-${centos_version} - Contrib
baseurl=http://vault.centos.org/${centos_version}/contrib/\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=1
[C${centos_version}-centosplus]
name=CentOS-${centos_version} - CentOSPlus
baseurl=http://vault.centos.org/${centos_version}/centosplus/\$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
enabled=1
EOF
# Clean and update yum cache
yum clean all
yum makecache