#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/binexport PATH# Check if user is rootif [ $(id -u) != "0" ]; then echo "Error: You must be root to run this script" exit 1ficlearecho "========================================================================="echo "Replace Redhat Enterprise Yum to CentOS Yum and Repos, Written by Licess"echo "========================================================================="# uninstall rhel yum echo "Uninstall Rhel Yum......"rpm -qa|grep yum|xargs rpm -e --nodeps# delete old rpmecho "Clean old cache......"rm -rf python-iniparse-0.3.1-2.1.el6.noarch.rpmrm -rf yum-metadata-parser-1.1.2-16.el6.x86_64.rpmrm -rf yum-3.2.29-40.el6.centos.noarch.rpmrm -rf yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm# download CentOS Yumecho "Download Python-iniparse......"wget echo "Download yum-metadata-parse......"wget echo "Download yum......"wget echo "Download yum fastmirror......"wget # install CentOS Yumecho "Installing......"rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpmrpm -ivh yum-metadata-parser-1.1.2-16.el6.x86_64.rpmrpm -ivh yum-3.2.29-60.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-30.el6.noarch.rpm# replace reposrm -rf /etc/yum.repos.d/CentOS-Base.repoecho "[base]name=CentOS-6.4 - Base - 163.combaseurl=http://mirrors.163.com/centos/6.4/os/x86_64/#mirrorlist=http://mirrors.163.com/?release=6.4&arch=$basearch&repo=osgpgcheck=1gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6#released updates [updates]name=CentOS-6.4 - Updates - 163.combaseurl=http://mirrors.163.com/centos/6.4/updates/x86_64/#mirrorlist=http://mirrors.163.com/?release=6.4&arch=$basearch&repo=updatesgpgcheck=1gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6#additional packages that may be useful[extras]name=CentOS-6.4 - Extras - 163.combaseurl=http://mirrors.163.com/centos/6.4/extras/x86_64/#mirrorlist=http://mirrors.163.com/?release=6.4&arch=$basearch&repo=extrasgpgcheck=1gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6#additional packages that extend functionality of existing packages[centosplus]name=CentOS-6.4 - Plus - 163.combaseurl=http://mirrors.163.com/centos/6.4/centosplus/x86_64/#mirrorlist=http://mirrors.163.com/?release=6.4&arch=$basearch&repo=centosplusgpgcheck=1enabled=0gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6#contrib - packages by Centos Users[contrib]name=CentOS-6.4 - Contrib - 163.combaseurl=http://mirrors.163.com/centos/6.4/contrib/x86_64/#mirrorlist=http://mirrors.163.com/?release=6.4&arch=$basearch&repo=contribgpgcheck=1enabled=0gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-6" >> /etc/yum.repos.d/CentOS-Base.repo#####yum clean allyum makecacheyum updateecho "=========================================================================="echo "You have successfully replace RedhatEnterprise Yum to CentOS yum and repos"echo "=========================================================================="