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"