autoDeploy/diffDns.sh

37 lines
1.1 KiB
Bash
Raw Permalink Normal View History

2025-03-11 08:52:19 +08:00
#!/bin/bash
# 检查参数个数是否正确
if [ $# -ne 3 ]; then
echo "用法: $0 <域名> <DNS服务器地址1> <DNS服务器地址2>"
exit 1
fi
domain="$1"
dns_server1="$2"
dns_server2="$3"
# 调用checkDns.sh获取第一个DNS服务器解析的所有IP地址
result1=$(./checkDns.sh "$domain" "$dns_server1")
# 调用checkDns.sh获取第二个DNS服务器解析的所有IP地址
result2=$(./checkDns.sh "$domain" "$dns_server2")
# 获取result1的第一个IP地址
first_ip_result1=$(echo "$result1" | head -n 1)
# 检查result1的第一个IP地址是否包含在result2中
if echo "$result2" | grep -q "^$first_ip_result1$"; then
echo "result1的第一个IP地址包含在result2的结果集合中"
else
echo "result1的第一个IP地址不包含在result2的结果集合中执行指定命令"
# 在这里替换成你实际要执行的命令,比如:
# some_command arg1 arg2
fi
# 输出第一个DNS服务器解析的所有IP地址
echo "DNS服务器 $dns_server1 解析的IP地址:"
echo "$result1"
# 输出第二个DNS服务器解析的所有IP地址
echo "DNS服务器 $dns_server2 解析的IP地址:"
echo "$result2"