mirror of
https://github.com/Websoft9/websoft9.git
synced 2024-11-22 15:40:22 +00:00
Update containers_version.sh
This commit is contained in:
parent
2e2f56a236
commit
1858821638
1 changed files with 6 additions and 9 deletions
|
@ -10,7 +10,7 @@ fi
|
|||
appnames=$(ls StackHub/apps/roles |grep -v Template |grep -v README.md |grep -v role)
|
||||
|
||||
# 匹配成功的APP集合字符串
|
||||
initdata=""
|
||||
targetlist=""
|
||||
|
||||
# get all of the running container's information( containername and imagename)
|
||||
for appinfo in $(docker ps --format '{{.Names}}%{{.Image}}'); do
|
||||
|
@ -21,36 +21,33 @@ for appinfo in $(docker ps --format '{{.Names}}%{{.Image}}'); do
|
|||
for appname in $appnames; do
|
||||
|
||||
if [[ $containername == $appname ]];then
|
||||
# app的版本已经输出
|
||||
if [[ $initdata =~ $appname ]];then
|
||||
if [[ $targetlist =~ $appname ]];then
|
||||
continue
|
||||
fi
|
||||
echo "$containername容器匹配成功app:$appname"
|
||||
initdata="$initdata $appname"
|
||||
targetlist="$targetlist $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
|
||||
elif [[ $imagename =~ $appname ]];then
|
||||
# app的版本已经输出
|
||||
if [[ $initdata =~ $appname ]];then
|
||||
if [[ $targetlist =~ $appname ]];then
|
||||
continue
|
||||
fi
|
||||
tmpvar="-"
|
||||
if [[ $containername =~ $tmpvar ]];then
|
||||
echo "$imagename=镜像匹配成功app:$appname"
|
||||
initdata="$initdata $appname"
|
||||
targetlist="$targetlist $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
|
||||
fi
|
||||
else
|
||||
# 容器和镜像均未匹配成功,通过服务名匹配
|
||||
realapp=echo $containername|awk -F"-" '{print $1}'
|
||||
services=docker compose -p $realapp ps --services
|
||||
for service in $services; do
|
||||
if [[ $service == $appname ]];then
|
||||
echo "$containername容器匹配成功app:$appname"
|
||||
initdata="$initdata $appname"
|
||||
targetlist="$targetlist $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
|
||||
|
|
Loading…
Reference in a new issue