From 4516b9982041e5ad3d7520102bd601b402f9c397 Mon Sep 17 00:00:00 2001 From: mack-a <57424792+mack-a@users.noreply.github.com> Date: Tue, 11 Aug 2020 14:02:42 +0800 Subject: [PATCH] =?UTF-8?q?feat(find=5Fbest=5Fcdn=5Fip):=20=E5=85=BC?= =?UTF-8?q?=E5=AE=B9centos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- find_best_cdn_ip.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/find_best_cdn_ip.sh b/find_best_cdn_ip.sh index 43ec348..65f9f74 100755 --- a/find_best_cdn_ip.sh +++ b/find_best_cdn_ip.sh @@ -56,7 +56,7 @@ pingTool(){ pingResult=`ping -c ${num} -W ${timeout} ${ip[$i]}` packetLoss=`echo ${pingResult}|awk -F "[%]" '{print $1}'|awk -F "[p][a][c][k][e][t][s][ ][r][e][c][e][i][v][e][d][,][ ]" '{print $2}'` roundTrip=`echo ${pingResult}|awk -F "[r][o][u][n][d][-][t][r][i][p]" '{print $2}'|awk '{print $3}'|awk -F "[/]" '{print $1"."$2"."$3"."$4}'|awk -F "[/]" '{print $1$2$3$4}'|awk -F "[.]" '{print $1" "$3" "$5" "$7}'` - if [[ "${release}" = "ubuntu" ]] || [[ "${release}" = "debian" ]] + if [[ "${release}" = "ubuntu" ]] || [[ "${release}" = "debian" ]] || [[ "${release}" = "centos" ]] then packetLoss=`echo ${pingResult}|awk -F "[%]" '{print $1}'|awk -F "[r][e][c][e][i][v][e][d][,][ ]" '{print $2}'` roundTrip=`echo ${pingResult}|awk -F "[r][t][t]" '{print $2}'|awk '{print $3}'|awk -F "[/]" '{print $1"."$2"."$3"."$4}'|awk -F "[/]" '{print $1$2$3$4}'|awk -F "[.]" '{print $1" "$3" "$5" "$7}'` @@ -108,7 +108,14 @@ init(){ pingTool } checkSystem(){ - if [[ "`uname`" = "Darwin" ]] + if [[ ! -z `find /etc -name "redhat-release"` ]] || [[ ! -z `cat /proc/version | grep -i "centos" | grep -v grep ` ]] || [[ ! -z `cat /proc/version | grep -i "red hat" | grep -v grep ` ]] || [[ ! -z `cat /proc/version | grep -i "redhat" | grep -v grep ` ]] + then + centosVersion=`rpm -q centos-release|awk -F "[-]" '{print $3}'` + release="centos" + installType='yum -y install' + removeType='yum -y remove' + upgrade="yum update -y --skip-broken" + elif [[ "`uname`" = "Darwin" ]] then release="Darwin" elif [[ ! -z `cat /etc/issue | grep -i "ubuntu" | grep -v grep` ]] || [[ ! -z `cat /proc/version | grep -i "ubuntu" | grep -v grep` ]]