From 8d79f403a142d5b46b6513e72c648655cf581cb4 Mon Sep 17 00:00:00 2001 From: Tianling Shen Date: Tue, 29 Oct 2024 23:15:17 +0800 Subject: [PATCH] feat(init): adapt dnsmasq conf-dir update Signed-off-by: Tianling Shen --- root/etc/init.d/homeproxy | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/root/etc/init.d/homeproxy b/root/etc/init.d/homeproxy index 0bd90b7f..c38dec1a 100755 --- a/root/etc/init.d/homeproxy +++ b/root/etc/init.d/homeproxy @@ -14,7 +14,14 @@ PROG="/usr/bin/sing-box" HP_DIR="/etc/homeproxy" RUN_DIR="/var/run/homeproxy" LOG_PATH="$RUN_DIR/homeproxy.log" -DNSMASQ_DIR="/tmp/dnsmasq.d/dnsmasq-homeproxy.d" + +# we don't know which is the default server, just take the first one +DNSMASQ_UCI_CONFIG="$(uci -q show "dhcp.@dnsmasq[0]" | awk 'NR==1 {split($0, conf, /[.=]/); print conf[2]}')" +if [ -f "/tmp/etc/dnsmasq.conf.$DNSMASQ_UCI_CONFIG" ]; then + DNSMASQ_DIR="$(awk -F '=' '/^conf-dir=/ {print $2}' "/tmp/etc/dnsmasq.conf.$DNSMASQ_UCI_CONFIG")/dnsmasq-homeproxy.d" +else + DNSMASQ_DIR="/tmp/dnsmasq.d/dnsmasq-homeproxy.d" +fi log() { echo -e "$(date "+%Y-%m-%d %H:%M:%S") [DAEMON] $*" >> "$LOG_PATH"