您的位置:首页 > 运维架构 > Linux

自动配置RHEL5(CentOS5)中科大epel和rpmforge YUM仓库支持(32|64)

2010-04-02 13:00 549 查看
集合了rpmforge,epel,ustc三方yum仓库,其中rpmforge和epel都是针对光盘以外的yum,ustc是中科院的,主要是正对光盘上的软件包,这样就不会出现可以安装nagios,cacti却不可以安装mysql这种系统基础包的情况,正对32-64位的系统做了限制,这样就不会出现32位的系统装到64位的包,虽然这样并无影响,但是会浪费空间,大约11000左右个包,有问题欢迎拍砖。

#!/bin/bash
#create epel ustc rpmforge YUM repository
#chenjian  2011-04-12

host  www.google.com >& /dev/null

WGET=$(/usr/bin/which wget)
ECHO_OK=$(echo -e "\E[32;40m""\033[4m------------------------------------------------------------------------------\033[0m\n")
ECHO_ERR=$(echo -e "\E[33;40m""\033[4m------------------------------------------------------------------------------\033[0m\n")

if [ $? -ne 0 ]
then
echo $ECHO_ERR
echo Connection network faild.
echo $ECHO_ERR
exit 1

else

EPEL_I386="http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm"
EPEL_X86_64="http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm"
RPMFORGE_I386="http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm"
RPMFORGE_X86_64="http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS//rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm"

create_yum () {
if $WGET -q -P /tmp/ $2
then
rpm -q $1 >& /dev/null
if [ $? -ne 0 ]
then
rpm -ivh --quiet /tmp/$1\*
if [ $? -eq 0 ]
then
echo $1 repository create success.
echo $ECHO_OK
else
echo $1 repository create faild
echo $ECHO_ERR
exit 2
fi
else
echo Upgrading ...
rpm -Uvh --quiet /tmp/$1\*
echo $ECHO_OK
fi
else
echo get $1 package fail.please check your url.
echo $ECHO_ERR
exit 1
fi

rm -rf /tmp/$1\*
}

config_yum () {
if ! grep 'exclude' /etc/yum.conf >& /dev/null
then  echo $1 >> /etc/yum.conf
fi
}

echo installing ,please wait...
uname -i|grep -q 64
if [ $? -eq 1 ]
then
create_yum rpmforge-release $RPMFORGE_I386

create_yum epel-release $EPEL_I386
#the following command is no influence,only for reduce disk usage.
config_yum 'exclude=*.x86_64'
else
create_yum rpmforge-release $RPMFORGE_X86_64
create_yum epel-release $EPEL_X86_64
config_yum 'exclude=*.i?86'
fi
fi

if [ $? -ne 0 ]
then exit 2
else

cd /etc/yum.repos.d/

cat > CentOS-Base.repo <<EOF
# CentOS-Base.repo
[base]
name=CentOS - Base
baseurl=http://centos.ustc.edu.cn/centos/5/os/\$basearch/ http://centos.candishosting.com.cn/5/os/\$basearch/ gpgcheck=1
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5

#released updates
[update]
name=CentOS - Updates
baseurl=http://centos.ustc.edu.cn/centos/5/updates/\$basearch/ http://centos.candishosting.com.cn/5/updates/\$basearch/ gpgcheck=1
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5

#packages used/produced in the build but not released
[addons]
name=CentOS - Addons
baseurl=http://centos.ustc.edu.cn/centos/5/addons/\$basearch/ http://centos.candishosting.com.cn/5/addons/\$basearch/ gpgcheck=1
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5

#additional packages that may be useful
[extras]
name=CentOS - Extras
baseurl=http://centos.ustc.edu.cn/centos/5/extras/\$basearch/ http://centos.candishosting.com.cn/5/extras/\$basearch/ gpgcheck=1
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS - Plus
baseurl=http://centos.ustc.edu.cn/centos/5/centosplus/\$basearch/ http://centos.candishosting.com.cn/5/centosplus/\$basearch/ gpgcheck=1
enabled=0
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5

#contrib - packages by Centos Users
[contrib]
name=CentOS - Contrib
baseurl=http://centos.ustc.edu.cn/centos/5/contrib/\$basearch/ http://centos.candishosting.com.cn/5/contrib/\$basearch/ gpgcheck=1
enabled=0
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5
EOF

rpm --import http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5 if [ $? -eq 0 ]
then
echo USTC repository create  success.
echo $ECHO_OK
fi

echo "All yum repository create cuccessful ^ _ ^."
echo $ECHO_OK

fi

[root@localhost ~]# yum list  |wc -l This system is not registered with RHN. RHN support will be disabled. 11715
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐