diff --git a/3-5-compute.sh b/3-5-compute.sh index f0787f8..6f7668b 100755 --- a/3-5-compute.sh +++ b/3-5-compute.sh @@ -252,8 +252,11 @@ chrony_synced() { local sources sources=$(timeout 10 chronyc -n sources) || return 1 printf '%s\n' "$sources" | awk -v ip="$CONTROLLER_IP" ' - $1=="^*" && $2==ip {found=1} - $1 ~ /^[\^=]/ && $2!=ip {bad=1} + # 时间源标记只有两个字符(如 ^*、^?、=+);排除表头的等号分隔线。 + length($1)==2 && (substr($1,1,1)=="^" || substr($1,1,1)=="=") { + if($1=="^*" && $2==ip) found=1 + if($2!=ip) bad=1 + } END{exit !(found && !bad)}' } check 2 'chrony 已安装' 'chrony 未安装(第1步:安装软件)' rpm -q chrony