feat(兼容Ubuntu): 兼容Ubuntu
parent
d46452ace9
commit
e4d0b582cb
|
@ -54,9 +54,14 @@ pingTool(){
|
|||
for ((i=0;i<${#ip[*]};i++))
|
||||
do
|
||||
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" ]]
|
||||
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}'`
|
||||
fi
|
||||
|
||||
## |awk -F "[/]" '{print $1$2$3}'|awk -F "[.]" '{print $1" "$3" "$5" "$7}'
|
||||
if [[ -z ${roundTrip} ]]
|
||||
then
|
||||
|
@ -91,4 +96,35 @@ init(){
|
|||
fi
|
||||
pingTool
|
||||
}
|
||||
checkSystem(){
|
||||
|
||||
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
|
||||
release="centos"
|
||||
installType='yum -y install'
|
||||
removeType='yum -y remove'
|
||||
upgrade="yum update -y --skip-broken"
|
||||
elif [[ ! -z `cat /etc/issue | grep -i "debian" | grep -v grep` ]] || [[ ! -z `cat /proc/version | grep -i "debian" | grep -v grep` ]]
|
||||
then
|
||||
release="debian"
|
||||
installType='apt -y install'
|
||||
upgrade="apt update -y"
|
||||
removeType='apt -y autoremove'
|
||||
elif [[ ! -z `cat /etc/issue | grep -i "ubuntu" | grep -v grep` ]] || [[ ! -z `cat /proc/version | grep -i "ubuntu" | grep -v grep` ]]
|
||||
then
|
||||
release="ubuntu"
|
||||
installType='apt -y install'
|
||||
upgrade="apt update -y"
|
||||
removeType='apt --purge remove'
|
||||
fi
|
||||
if [[ -z ${release} ]]
|
||||
then
|
||||
echoContent red "本脚本不支持此系统,请将下方日志反馈给开发者"
|
||||
cat /etc/issue
|
||||
cat /proc/version
|
||||
killSleep > /dev/null 2>&1
|
||||
exit 0;
|
||||
fi
|
||||
}
|
||||
checkSystem
|
||||
init
|
||||
|
|
Loading…
Reference in New Issue