Rhel replace CentOS yum source one-click installation script
Most of the systems recently used are rhel, And the yum of rhel cannot be installed online. Therefore, a one-click installation script is written to support rhel5.x & rhel6.x, which is the source of Netease.
#!/bin/sh
#authorbythundermeng
.
/etc/init
.d
/functions
bit=`getconfLONG_BIT`
release=`
sed
-r-n
's/(.*)([[:digit:]])\.([[:digit:]])(.*)/\2/p'
/etc/redhat-release
`
if
[$UID-
ne
0]
then
echo
"Pleaseuserootexecthisshell"
exit
1
fi
[`rpm-qa|
grep
yum|
wc
-l`-
ge
1]&&{
rpm-qa|
grep
yum|
xargs
rpm-e--nodeps
}
[-e
/tmp/yumupdate
]||
mkdir
/tmp/yumupdate
cd
/tmp/yumupdate
rehl5()
{
wgethttp:
//mirrors
.163.com/.help
/CentOS5-Base-163
.repo-P
/etc/yum
.repos.d/
sed
-i
"s/\$releasever/5/g"
/etc/yum
.repos.d
/CentOS5-Base-163
.repo
case
$bit
in
32)
wgethttp:
//mirrors
.163.com
/centos/5/os/i386/CentOS/yum-metadata-parser-1
.1.2-4.el5.i386.rpm
rpm-ivhyum-metadata-parser-1.1.2-4.el5.i386.rpm--nodeps
;;
64)
wgethttp:
//mirrors
.163.com
/centos/5/os/x86_64/CentOS/yum-metadata-parser-1
.1.2-4.el5.x86_64.rpm
rpm-ivhyum-metadata-parser-1.1.2-4.el5.x86_64.rpm--nodeps
;;
esac
wgethttp:
//mirrors
.163.com
/centos/5/os/x86_64/CentOS/yum-3
.2.22-40.el5.centos.noarch.rpm
wgethttp:
//mirrors
.163.com
/centos/5/os/x86_64/CentOS/yum-fastestmirror-1
.1.16-21.el5.centos.noarch.rpm
wgethttp:
//mirrors
.163.com
/centos/5/os/x86_64/CentOS/yum-updatesd-0
.9-6.el5_10.noarch.rpm
rpm-ivhyum-3.2.22-40.el5.centos.noarch.rpmyum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm
rpm-ivhyum-updatesd-0.9-6.el5_10.noarch.rpm
}
rehl6()
{
#cdrehl6
#cpCentOS-Base.repo/etc/yum.repos.d/
wgethttp:
//mirrors
.163.com/.help
/CentOS6-Base-163
.repo-P
/etc/yum
.repos.d/
sed
-i
"s/\$releasever/6/g"
/etc/yum
.repos.d
/CentOS6-Base-163
.repo
wgethttp:
//mirrors
.163.com
/centos/6/os/x86_64/Packages/python-iniparse-0
.3.1-2.1.el6.noarch.rpm
rpm-ivhpython-iniparse-0.3.1-2.1.el6.noarch.rpm
case
$bit
in
32)
wgethttp:
//mirrors
.163.com
/centos/6/os/i386/Packages/yum-metadata-parser-1
.1.2-16.el6.i686.rpm
rpm-ivhyum-metadata-parser-1.1.2-16.el6.i686.rpm
;;
64)
wgethttp:
//mirrors
.163.com
/centos/6/os/x86_64/Packages/yum-metadata-parser-1
.1.2-16.el6.x86_64.rpm
rpm-ivhyum-metadata-parser-1.1.2-16.el6.x86_64.rpm
;;
esac
wgethttp:
//mirrors
.163.com
/centos/6/os/i386/Packages/yum-3
.2.29-60.el6.centos.noarch.rpm
wgethttp:
//mirrors
.163.com
/centos/6/os/i386/Packages/yum-plugin-fastestmirror-1
.1.30-30.el6.noarch.rpm
rpm-ivhyum-3.2.29-60.el6.centos.noarch.rpmyum-plugin-fastestmirror-1.1.30-30.el6.noarch.rpm
}
if
[$release-
eq
6]
then
rehl6
elif
[$release-
eq
5]
then
rehl5
else
echo
"ThisSystemReleaseNotSupport!"
fi
if
[$?-
eq
0]
then
action
"yumupdateissucessed"
/bin/true
else
action
"yumupdateisfailed"
/bin/false
exit
1
fi
rm
-rf
/tmp/yumupdate
yumcleanall
yumrepolist