argus/src/bind/build/update-dns.sh
yuyr 8a38d3d0b2 dev_1.0.0_yuyr 完成 log和bind模块开发部署测试 (#8)
- [x] 完成log模块镜像构建、本地端到端写日志——收集——查询流程;
- [x] 完成bind模块构建;
- [x] 内置域名IP自动更新脚本,使用 /private/argus/etc目录下文件进行同步,容器启动时自动写IP,定时任务刷新更新DNS服务器IP和DNS规则;

Co-authored-by: root <root@curious.host.com>
Reviewed-on: #8
Reviewed-by: sundapeng <sundp@mail.zgclab.edu.cn>
2025-09-22 16:39:38 +08:00

32 lines
648 B
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/sh
# update-dns.sh
# 从 /private/argus/etc/dns.conf 读取 IP写入 /etc/resolv.conf
DNS_CONF="/private/argus/etc/dns.conf"
RESOLV_CONF="/etc/resolv.conf"
# 检查配置文件是否存在
if [ ! -f "$DNS_CONF" ]; then
echo "配置文件不存在: $DNS_CONF" >&2
exit 1
fi
# 生成 resolv.conf 内容
{
while IFS= read -r ip; do
# 跳过空行和注释
case "$ip" in
\#*) continue ;;
"") continue ;;
esac
echo "nameserver $ip"
done < "$DNS_CONF"
} > "$RESOLV_CONF".tmp
# 替换写入 /etc/resolv.conf
cat "$RESOLV_CONF".tmp > "$RESOLV_CONF"
rm -f "$RESOLV_CONF".tmp
echo "已更新 $RESOLV_CONF"