This commit is contained in:
2025-10-13 18:34:48 +08:00
commit 37865d041f
116 changed files with 31168 additions and 0 deletions

38
entrypoint.sh Executable file
View File

@ -0,0 +1,38 @@
#!/bin/bash
#./entrypoint.sh -h 127.0.0.1 -p 3306,2379,6379 -c '/im/bin/file_server -flagfile=./xx.conf'
# 1. 编写一个端口探测函数,端口连接不上则循环等待
# wait_for 127.0.0.1 3306
wait_for() {
while ! nc -z $1 $2
do
echo "$2 端口连接失败,休眠等待!";
sleep 1;
done
echo "$1:$2 检测成功!";
}
# 2. 对脚本运行参数进行解析获取到ipportcommand
declare ip
declare ports
declare command
while getopts "h:p:c:" arg
do
case $arg in
h)
ip=$OPTARG;;
p)
ports=$OPTARG;;
c)
command=$OPTARG;;
esac
done
# 3. 通过执行脚本进行端口检测
# ${port //,/ } 针对port中的内容以空格替换字符串中的, shell中数组--一种以空格间隔的字符串
for port in ${ports//,/ }
do
wait_for $ip $port
done
# 4. 执行command
# eval 对一个字符串进行二次检测,将其当作命令进行执行
eval $command