From 2c3ee91cc2c0f45feb32940aeebb00398bd72c6f Mon Sep 17 00:00:00 2001 From: qiaofeng1227 <76487013@qq.com> Date: Mon, 18 Jul 2022 08:44:39 +0800 Subject: [PATCH] Update containers_version.sh --- scripts/containers_version.sh | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/scripts/containers_version.sh b/scripts/containers_version.sh index 8d7afaba..f63523e2 100644 --- a/scripts/containers_version.sh +++ b/scripts/containers_version.sh @@ -19,11 +19,12 @@ for appinfo in $(docker ps --format '{{.Names}}%{{.Image}}'); do imagename=$(echo $appinfo |awk -F"%" '{print $2}') for appname in $appnames; do - # app的版本已经输出 - if [[ $initdata =~ $appname ]];then - continue - fi + if [[ $containername == $appname ]];then + # app的版本已经输出 + if [[ $initdata =~ $appname ]];then + continue + fi echo "$containername容器匹配成功app:$appname" appnames=(${appnames[*]/$appname}) initdata="$initdata $appname" @@ -31,12 +32,15 @@ for appinfo in $(docker ps --format '{{.Names}}%{{.Image}}'); do bash /tmp/$appname_get_version.sh $containername break elif [[ $imagename =~ $appname ]];then - tmpvar="-" - if [[ $containername =~ $tmpvar ]];then - echo "$imagename=镜像匹配成功app:$appname" - appnames=(${appnames[*]/$appname}) - initdata="$initdata $appname" - wget -O /tmp/$appname_get_version.sh https://raw.githubusercontent.com/Websoft9/docker-$appname/main/src/get_version.sh + # app的版本已经输出 + if [[ $initdata =~ $appname ]];then + continue + fi + tmpvar="-" + if [[ $containername =~ $tmpvar ]];then + echo "$imagename=镜像匹配成功app:$appname" + initdata="$initdata $appname" + wget -O /tmp/$appname_get_version.sh https://raw.githubusercontent.com/Websoft9/docker-$appname/main/src/get_version.sh bash /tmp/$appname_get_version.sh $containername break else