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

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

  
  
  
  
  1. #!/bin/bash 
  2. #create epel ustc rpmforge YUM repository 
  3. #chenjian  2011-04-12 
  4.  
  5. host  www.google.com >& /dev/null 
  6.  
  7. WGET=$(/usr/bin/which wget) 
  8. ECHO_OK=$(echo -e "\E[32;40m""\033[4m------------------------------------------------------------------------------\033[0m\n"
  9. ECHO_ERR=$(echo -e "\E[33;40m""\033[4m------------------------------------------------------------------------------\033[0m\n"
  10.  
  11. if [ $? -ne 0 ] 
  12. then  
  13.     echo $ECHO_ERR 
  14.     echo Connection network faild. 
  15.     echo $ECHO_ERR 
  16.     exit 1 
  17.  
  18. else 
  19.  
  20. EPEL_I386="http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm" 
  21. EPEL_X86_64="http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm" 
  22. RPMFORGE_I386="http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm" 
  23. 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" 
  24.  
  25. create_yum () { 
  26. if $WGET -q -P /tmp/ $2  
  27. then 
  28.     rpm -q $1 >& /dev/null 
  29.     if [ $? -ne 0 ] 
  30.     then  
  31.     rpm -ivh --quiet /tmp/$1\*  
  32.         if [ $? -eq 0 ] 
  33.         then 
  34.             echo $1 repository create success. 
  35.             echo $ECHO_OK 
  36.         else 
  37.             echo $1 repository create faild 
  38.             echo $ECHO_ERR 
  39.             exit 2 
  40.         fi 
  41.     else 
  42.         echo Upgrading ... 
  43.         rpm -Uvh --quiet /tmp/$1\*  
  44.         echo $ECHO_OK  
  45.         fi 
  46. else 
  47.     echo get $1 package fail.please check your url. 
  48.     echo $ECHO_ERR 
  49.     exit 1 
  50. fi 
  51.  
  52. rm -rf /tmp/$1\* 
  53.  
  54.  
  55. config_yum () { 
  56. if ! grep 'exclude' /etc/yum.conf >& /dev/null  
  57. then  echo $1 >> /etc/yum.conf 
  58. fi  
  59.  
  60.  
  61. echo installing ,please wait... 
  62. uname -i|grep -q 64 
  63. if [ $? -eq 1 ] 
  64. then 
  65.         create_yum rpmforge-release $RPMFORGE_I386 
  66.  
  67.         create_yum epel-release $EPEL_I386 
  68. #the following command is no influence,only for reduce disk usage. 
  69.         config_yum 'exclude=*.x86_64' 
  70. else 
  71.         create_yum rpmforge-release $RPMFORGE_X86_64 
  72.         create_yum epel-release $EPEL_X86_64 
  73.         config_yum 'exclude=*.i?86'  
  74. fi 
  75. fi 
  76.  
  77. if [ $? -ne 0 ] 
  78. then exit 2 
  79. else 
  80.  
  81. cd /etc/yum.repos.d/ 
  82.  
  83. cat > CentOS-Base.repo <<EOF 
  84. # CentOS-Base.repo 
  85. [base] 
  86. name=CentOS - Base 
  87. baseurl=http://centos.ustc.edu.cn/centos/5/os/\$basearch/ 
  88. http://centos.candishosting.com.cn/5/os/\$basearch/ 
  89. gpgcheck=1 
  90. gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5 
  91.  
  92. #released updates 
  93. [update
  94. name=CentOS - Updates 
  95. baseurl=http://centos.ustc.edu.cn/centos/5/updates/\$basearch/ 
  96. http://centos.candishosting.com.cn/5/updates/\$basearch/ 
  97. gpgcheck=1 
  98. gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5 
  99.  
  100. #packages used/produced in the build but not released 
  101. [addons] 
  102. name=CentOS - Addons 
  103. baseurl=http://centos.ustc.edu.cn/centos/5/addons/\$basearch/ 
  104. http://centos.candishosting.com.cn/5/addons/\$basearch/ 
  105. gpgcheck=1 
  106. gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5 
  107.  
  108. #additional packages that may be useful 
  109. [extras] 
  110. name=CentOS - Extras 
  111. baseurl=http://centos.ustc.edu.cn/centos/5/extras/\$basearch/ 
  112. http://centos.candishosting.com.cn/5/extras/\$basearch/ 
  113. gpgcheck=1 
  114. gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5 
  115.  
  116. #additional packages that extend functionality of existing packages 
  117. [centosplus] 
  118. name=CentOS - Plus 
  119. baseurl=http://centos.ustc.edu.cn/centos/5/centosplus/\$basearch/ 
  120. http://centos.candishosting.com.cn/5/centosplus/\$basearch/ 
  121. gpgcheck=1 
  122. enabled=0 
  123. gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5 
  124.  
  125. #contrib - packages by Centos Users 
  126. [contrib] 
  127. name=CentOS - Contrib 
  128. baseurl=http://centos.ustc.edu.cn/centos/5/contrib/\$basearch/ 
  129. http://centos.candishosting.com.cn/5/contrib/\$basearch/ 
  130. gpgcheck=1 
  131. enabled=0 
  132. gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5 
  133. EOF 
  134.  
  135. rpm --import http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5 
  136. if [ $? -eq 0 ] 
  137. then 
  138.     echo USTC repository create  success. 
  139.     echo $ECHO_OK 
  140. fi 
  141.  
  142. echo "All yum repository create cuccessful ^ _ ^." 
  143. echo $ECHO_OK 
  144.  
  145. fi 




[root@localhost ~]# yum list |wc -l This system is not registered with RHN. RHN support will be disabled. 11715

你可能感兴趣的:(yum,自动,RPMForge,仓库,中科)