判断linux版本,更新yum源

#!/bin/bash

version=`cat /etc/redhat-release`

if [[ $version =~ “7.” ]];then

wget -O/etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

sed -i  ‘s/$releasever/7/g’ /etc/yum.repos.d/CentOS-Base.repo

yum clean all

elif

[[ $version =~ “6.” ]];then

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

sed -i  ‘s/$releasever/6/g’ /etc/yum.repos.d/CentOS-Base.repo

yum clean all

else

echo “unknown linux version! exit”

fi

Published by

silenthk

云想衣裳花相容,春风拂槛露华浓。 若非群玉山头见,会向瑶台月下逢。

发表评论

电子邮件地址不会被公开。 必填项已用*标注