Friday, March 12, 2010

Apt on Centos!

I have recently had a chat with a vendor whom as a newbie to linux, but had a fairly great grasp on Ubuntu. He was set to acquire a few centos boxes and needed assistance with keeping them up too date. I tried teaching him Yum but it really didnt work so well so :) I came up with a cool script:


### Apt Control ###
# Written by Mel to reduce the suffering of a Centos5 install for a friend.

# installs coreutils
yum install coreutils -y;
# sets the redhat release to a variable - maybe later they will change the location of this file?
# acquiring the Architecture
plat_arch=`uname -i`
# determines OS
plat_os=`cat $rh_file | cut -d" " -f1`
if [ $plat_os == CentOS ] ;
then plat_type=el ;
else plat_type=fc ;
# Creates the release for the link - ie centos 5 = el5
plat_release=$plat_type`cat $rh_file | cut -d"." -f1 | cut -d' ' -f3`
# All variables get pulled into the link and then we request the file & install it
rpm -Uhv$plat_release/en/$plat_arch/rpmforge/RPMS/rpmforge-release-0.3.6-1.$plat_release.rf.$plat_arch.rpm
# we clean current repo's of potentially crappy data
yum clean all;
# we now do a fresh install of Apt-get
yum install apt -y;
# we echo commands into the os.list file to provide repos
echo 'repomd centos/$(VERSION)/os/$(ARCH)' > /etc/apt/sources.list.d/os.list &&
echo 'repomd centos/$(VERSION)/updates/$(ARCH)' >> /etc/apt/sources.list.d/os.list &&
echo 'repomd centos/$(VERSION)/extras/$(ARCH)' >> /etc/apt/sources.list.d/os.list &&
echo 'repomd centos/$(VERSION)/fasttrack/$(ARCH)' >> /etc/apt/sources.list.d/os.list ;
# we now update our package list
apt-get update;

No comments: