centos6的yum配置脚本-163的源+epel+rpmforge源

每次讲课都要配置yum,很麻烦,自己总接了一下,写了个脚本,一键完成。

把它当作系统安装刚安装完成后的优化,是很不错的。

不废话了,上脚本

[root@localhost ~]# vi  yum_config.sh
#!/bin/bash
#by scfa 2015-08-01
############install base tools#########
echo "############################"
echo "make sure you can access internet."
yum -y install wget lftp yum-plugin-priorities 1>/dev/null &&echo "tools install ok."


##########backup repo file#########
echo "############################"
repo_d=/etc/yum.repos.d
cd $repo_d
if [ ! -e $repo_d/rbak ];then
  mkdir $repo_d/rbak
  mv $repo_d/*.repo $repo_d/rbak
fi

###########config 163.repo ###############
echo "############################"
m_163="CentOS6-Base-163.repo"
echo "config mirrors.163.com repo now."
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo &>/dev/null
if [ -e /etc/repos.d/$m_163 ];then
  sed -i -e "s/\]$/\]\npriority=1/g" /etc/yum.repos.d/$m_163
  echo "163.repo is ok."
fi

#############config epel Repository##########
echo "############################"
echo "config epel-release repo now."
yum -y install epel-release >/dev/null &&echo "epel-relase install ok."
sed -i -e "s/\]$/\]\npriority=5/g" /etc/yum.repos.d/epel.repo
sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/epel.repo
EPEL_F="/etc/yum.repos.d/epel.repo"
if [ ! -z "$(grep priority $EPEL_F)" -a ! -z "$(grep 0 $EPEL_F)" ];then
  echo "epel repo priority is 5."
  echo "epel usage:yum --enablerepo=epel install [package]."
fi

#############config rpmforge repository#############
echo "############################"
echo "config rpmforge repo now."
yum -y install http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm 1>/dev/null&&echo "rpmforge install ok."
sed -i -e "s/\]$/\]\npriority=10/g" /etc/yum.repos.d/rpmforge.repo
sed -i -e "s/enabled = 1/enabled = 0/g" /etc/yum.repos.d/rpmforge.repo
 
RPMFORGE_F="/etc/yum.repos.d/rpmforge.repo"
if [ ! -z "$(grep priority $RPMFORGE_F)" -a ! -z "$(grep 0 $RPMFORGE_F)" ];then
  echo "rpmforge priority is 10."
  echo "rpmforge usage:yum --enablerepo=rpmforge install [package]."
fi

:wq

chmod +x yum_config.sh

./yum_config.sh

本文出自 “沈工鬼斧” 博客,谢绝转载!

你可能感兴趣的:(配置Fedora,project源,配置epel源,centos配置163yum源,配置rpmforge源,centos第三方源配置)