websoft9/scripts/containers_version.sh

32 lines
806 B
Bash
Raw Normal View History

2022-07-15 14:55:40 +08:00
#!/bin/bash
export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
2022-07-15 15:57:02 +08:00
2022-07-15 16:40:03 +08:00
containername=$1
imagename=$2
2022-07-15 15:57:02 +08:00
# get applist
2022-07-15 16:02:54 +08:00
if [ -d StackHub ] ; then
echo "StackHub is exists"
else
git clone --depth=1 https://github.com/Websoft9/StackHub.git
fi
2022-07-15 15:57:02 +08:00
appnames=$(ls StackHub/apps/roles |grep -v Template |grep -v README.md |grep -v role)
2022-07-15 16:40:03 +08:00
2022-07-15 15:57:02 +08:00
for appname in $appnames; do
2022-07-15 16:40:03 +08:00
if [[ $containername == $appname ]];then
echo "$containername容器匹配成功app:$appname"
break
elif [[ $imagename =~ $appname ]];then
tmpvar="-"
if [[ $containername =~ $tmpvar ]];then
echo "$imagename=镜像匹配成功app:$appname"
break
else
echo "need other mothod "
fi
else
echo "容器镜像均未匹配成功app:$appname"
fi
2022-07-15 15:57:02 +08:00
done