#!/bin/bash
#backup the original repo and use mirrors.aliyun.com as the repository of yum 
read -p "Please Enter backup file Name:" BACKNAME
if [ -e /etc/yum.repo.d/$BACKNAME ]
then
echo "Sorry,the name $BACKNAME has been used!"
else
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/$BACKNAME &> /dev/null
if [ $? -eq 0 ]
then
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo &> /dev/null
if [ $? -eq 0 ]
then
echo "Set success!"
else
echo "Set failure!"
fi
else
echo "backup Error!"
fi
fi

乱写写CentOS7适用,其他的版本不一样啊...