Blame tests/p_yum-plugin-fastestmirror/10-fastestmirror.sh

Karanbir Singh 6f670a
#!/bin/sh
Karanbir Singh 6f670a
Karanbir Singh 6f670a
# Ensure plugin is enabled :
Karanbir Singh 6565bb
9a5ec9
if [ "$PRE_UPDATES" == "1" ]; then
9a5ec9
  t_Log "skipping $0 for pre update testing"
9a5ec9
  exit 0
9a5ec9
fi
9a5ec9
dec93c
isAltArch=$(uname -m|egrep -q 'armv7hl|aarch64|ppc64|ppc64le'|| echo 1 && echo 0)
4e7f11
4e7f11
if [ "$isAltArch" = "0" ] ; then
4e7f11
 t_Log "Skipping for altarch, using only mirror.centos.org"
4e7f11
 t_Log "SKIP"
4e7f11
 exit 0
4e7f11
fi
4e7f11
Karanbir Singh 6f670a
t_Log "Running $0 - is y-p-fastestmirror enabled."
Karanbir Singh 6f670a
grep 'enabled=1' /etc/yum/pluginconf.d/fastestmirror.conf > /dev/null
Karanbir Singh 6f670a
t_CheckExitStatus $?
Karanbir Singh 6f670a
Karanbir Singh 6f670a
# timedhosts file ends up in different places on c5 and c6
Karanbir Singh 6f670a
if [ $centos_ver == 5 ]; then 
Karanbir Singh 6565bb
	BaseDir=/var/cache/yum/
Karanbir Singh 6f670a
else
2560e2
	BaseDir=/var/cache/yum/`uname -i`/$centos_ver
Karanbir Singh 6f670a
fi
Karanbir Singh 6f670a
Karanbir Singh 6f670a
t_Log "Running $0 - Ensure we have mirrorlist enabled."
Karanbir Singh 6f670a
egrep '^mirrorlist' /etc/yum.repos.d/*.repo > /dev/null
Karanbir Singh 6f670a
t_CheckExitStatus $?
Karanbir Singh 6f670a
Christoph Galuschka dba34b
t_Log "Running $0 - y-p-fastestmirror can get hosts from mirrorlist"
Karanbir Singh 488421
find $BaseDir -type f -name timedhosts.txt -exec rm -f {} \;
Karanbir Singh 6f670a
yum -d0 list kernel > /dev/null
Karanbir Singh ca2d3e
Karanbir Singh 6565bb
hostsfound=`cat $BaseDir/timedhosts.txt | wc -l` > /dev/null
Karanbir Singh 3e0128
Karanbir Singh 3e0128
# we need to make sure the file was recreated
Karanbir Singh 6565bb
if [ -f ${BaseDir}/timedhosts.txt ]; then 
Karanbir Singh 3e0128
	if [ $hostsfound -lt 1 ]; then
Karanbir Singh 6565bb
		retval=1
Karanbir Singh 3e0128
	else
Karanbir Singh 6565bb
		retval=0
Karanbir Singh 3e0128
	fi
Karanbir Singh 6565bb
else
Karanbir Singh 6565bb
	retval=1
Karanbir Singh 3e0128
fi
Karanbir Singh 3e0128
t_CheckExitStatus $retval
Karanbir Singh 3e0128
Christoph Galuschka dba34b
t_Log "Running $0 - number of hosts y-p-fastestmirror can get: $( wc -l ${BaseDir}/timedhosts.txt )"