#!/bin/bash # Copyright (C) 2009-2010 Eric Shubert # # script to install/upgrade rpmforge repository in a qmail-toaster ###################################################################### # Change Log # 9/23/13 shubes - modified for Centos 6, changed i386 to i686 # 4/02/12 shubes - modified for new repoforge.org changes # 5/27/11 shubes - leave rpmforge repo enabled, since it's safe now # 7/29/10 shubes - modified for changed url and spec format # 8/28/08 written by Eric 'shubes' ###################################################################### PKGNAME=rpmforge-release WEB_LOC=https://raw.github.com/repoforge/rpms/master/specs/$PKGNAME ###################################################################### # Figure out which version/release is the latest # a2_determine_version(){ echo "$me $myver - getting latest version of $PKGNAME ..." # set a temp file for the working scratch. $$ is the current shell ID. tempfile=$(tempfile 2>/dev/null) || tempfile=/tmp/$me.$$ # make sure the tempfile is deleted when we're done trap "rm -f $tempfile" 0 1 2 5 15 wget -q -O $tempfile $WEB_LOC/$PKGNAME.spec if [ $? != "0" ]; then echo "$me - $WEB_LOC/$PKGNAME.spec not found, please try again later." exit 1 fi verstring=$(grep --max-count=1 "^Version: " $tempfile) version=${verstring#Version: } relstring=$(grep --max-count=1 "^Release: " $tempfile) relstring=${relstring#Release: } release=${relstring%\%\{?dist\}} } ###################################################################### # Check to see which distro and arch to install # a4_check_distro_arch(){ . qtp-whatami -s rc=$? if [ "$rc" != "0" ] && [ "$rc" != "1" ]; then echo "$me - your distro/ver is not supported for a toaster, exiting." exit 1 fi case "$BUILD_DIST" in cnt40 ) rhver=el4 rfver=el4 rfdarch=i386 rfparch=i686 ;; cnt4064 ) rhver=el4 rfver=el4 rfdarch=x86_64 rfparch=x86_64 ;; cnt50 ) rhver=el5 rfver=el5 rfdarch=i386 rfparch=i686 ;; cnt5064 ) rhver=el5 rfver=el5 rfdarch=x86_64 rfparch=x86_64 ;; cnt60 ) rhver=el6 rfver=el6 rfdarch=i386 rfparch=i686 ;; cnt6064 ) rhver=el6 rfver=el6 rfarch=x86_64 ;; rht90 ) rhver=9 rfver=rh9 rfdarch=i386 rfdarch=i686 ;; * ) echo "$me - your distro/ver is not supported by RPMforge, exiting." exit 1 ;; esac } ###################################################################### # do the rpm command to install the package, and check the result # a6_install_the_package(){ rpm -Uvh http://apt.sw.be/redhat/$rhver/en/$rfdarch/rpmforge/RPMS/$PKGNAME-$version-$release.$rfver.rf.$rfparch.rpm rc=$? if [ "$rc" != "0" ]; then echo "$me - install/upgrade failed, rc=$rc. Exiting." exit 1 fi } ###################################################################### # main routine begins here # me=${0##*/} myver=v0.4.0 a2_determine_version installed_pkg=$(rpm -q $PKGNAME) rc=$? if [ $rc == "0" ] \ && [ "${installed_pkg%.*.*.*}" == "$PKGNAME-$version-$release" ]; then echo "$me - installed package $installed_pkg is the latest - nothing done." else if [ $rc == "0" ]; then echo "$me - $installed_pkg is installed, upgrading to $version-$release" else echo "$me - $PKGNAME not installed, installing ..." fi a4_check_distro_arch a6_install_the_package echo "$me - installation/upgrade complete" fi exit 0