Actually, I am using CentOS on production servers. CentOS native repository is very small and contains very necessary packages. If you need something more, you should consider using RPMForge repository as I do
But to add this repository to CentOS you need to do several annoying actions. And this is annoyng when you do so on each new server you are asked to setup. So, I wrote small script to automate the job which I like to share with you now.
If you are not yet in your home directory execute:
cd ~
Then we need to create a script file, which will do automatic installation. Execute the following command:
cat ->rpmforge_inst.sh
Then just paste the following code into console:
#!/bin/sh exit_with_message() { echo $1; exit 1; } echo -e "FractalizeR's RPM Forge Repository Installation Script for CentOS v0.91\n" arch=`uname -i` echo "Detected architecture is $arch" RELEASE=`awk '{ print $3 }' < /etc/redhat-release` MAJOR=`echo $RELEASE | awk -F. '{ print $1 }'` MINOR=`echo $RELEASE | awk -F. '{ print $2 }'` echo "Detected CentOS Release: $RELEASE, Major=$MAJOR, Minor=$MINOR" repoVer="0.3.6-1" if [ `id -u` != 0 ]; then echo "You need to be root!" exit 1 fi repoFileName="/etc/yum.repos.d/CentOS-Base.repo" if [ ! -r $repoFileName -o ! -w $repoFileName ]; then echo "Repository file $repoFileName is not readable or writtable!" exit 1 fi echo "Installing yum-priorities plugin..." yum -y install yum-priorities condition=`grep priority $repoFileName` if [ -z "$condition" ]; then sed -i.back -e 's/\[base\]/\[base\]\npriority=1/' -e 's/\[addons\]/\[addons\]\npriority=1/' -e 's/\[updates\]/\[updates\]\npriority=1/' -e 's/\[extras\]/\[extras\]\npriority=1/' -e 's/\[centosplus\]/\[centosplus\]\npriority=2/' -e 's/\[contrib\]/\[contrib\]\npriority=2/' $repoFileName echo "Repository file edited ok" else echo "Priorities for base packages already set!" fi echo "Loading RPMForge RPM..." wget "http://apt.sw.be/redhat/el$MAJOR/en/$arch/RPMS.dag/rpmforge-release-$repoVer.el$MAJOR.rf.$arch.rpm" || exit_with_message "RPMForge RPM download failed!" echo "Importing RPM Forge GPG key..." rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt || exit_with_message "RPMForge GPG key download failed!" echo "Verifying RPMForge RPM..." rpm -K rpmforge-release-$repoVer.el$MAJOR.rf.*.rpm || exit_with_message "RPMForge GPG key verification failed!" echo "Installing RPMForge RPM..." rpm -i rpmforge-release-$repoVer.el$MAJOR.rf.*.rpm || exit_with_message "RPMForge RPM installation failed!" echo "Editing RPMForge repo file..." repoFileName="/etc/yum.repos.d/rpmforge.repo" if [ ! -r $repoFileName -o ! -w $repoFileName ]; then "Repository file $repoFileName is not readable or writtable!" exit 1 fi condition=`grep priority $repoFileName` if [ -z "$condition" ]; then sed -i.back 's/\[rpmforge\]/\[rpmforge\]\npriority=20/' $repoFileName else echo "Priorities for rpmforge packages already set!" fi rm -f rpmforge-release-$repo_ver.el$MAJOR.rf.$arch.rpm echo "Done!"
Now press Ctrl-D. Sometimes you should press it twice (don’t know why). Now we need to make this file executable:
chmod u+x rpmforge_inst.sh
And then just execute the file we created:
./rpmforge_inst.sh
Automatic installation of RPMForge repository is now in progress. In a few seconds you are done and you can check results with
yum repolist
Voila!





