From 3490ccb7a386b25f36179d5754bb4094f290531b Mon Sep 17 00:00:00 2001 From: coolsnowwolf Date: Mon, 8 Oct 2018 02:10:17 +0800 Subject: [PATCH] add watchdog for DNS cache --- config/Config-images.in | 2 +- package/lean/luci-app-flowoffload/Makefile | 2 +- .../luci-app-flowoffload/root/etc/init.d/flowoffload | 2 +- package/lean/luci-app-sfe/Makefile | 2 +- package/lean/luci-app-sfe/root/etc/init.d/sfe | 2 +- package/lean/luci-app-sfe/root/etc/uci-defaults/sfe | 3 +++ .../luci-app-sfe/root/usr/share/dnscache-watchdog.sh | 9 +++++++++ 7 files changed, 17 insertions(+), 5 deletions(-) create mode 100755 package/lean/luci-app-sfe/root/usr/share/dnscache-watchdog.sh diff --git a/config/Config-images.in b/config/Config-images.in index e606c9aeb..fef33585a 100644 --- a/config/Config-images.in +++ b/config/Config-images.in @@ -150,7 +150,7 @@ menu "Target Images" int "Block size (in KiB)" depends on TARGET_ROOTFS_SQUASHFS default 64 if LOW_MEMORY_FOOTPRINT - default 1024 + default 512 menuconfig TARGET_ROOTFS_UBIFS bool "ubifs" diff --git a/package/lean/luci-app-flowoffload/Makefile b/package/lean/luci-app-flowoffload/Makefile index 3da66aaa2..016d61aa0 100644 --- a/package/lean/luci-app-flowoffload/Makefile +++ b/package/lean/luci-app-flowoffload/Makefile @@ -9,7 +9,7 @@ LUCI_TITLE:=LuCI support for Flow Offload LUCI_DEPENDS:=+kmod-ipt-offload +pdnsd-alt @LINUX_4_14 LUCI_PKGARCH:=all PKG_VERSION:=1.0 -PKG_RELEASE:=9 +PKG_RELEASE:=10 include $(TOPDIR)/feeds/luci/luci.mk diff --git a/package/lean/luci-app-flowoffload/root/etc/init.d/flowoffload b/package/lean/luci-app-flowoffload/root/etc/init.d/flowoffload index 775c2ac5e..f10d49c9d 100755 --- a/package/lean/luci-app-flowoffload/root/etc/init.d/flowoffload +++ b/package/lean/luci-app-flowoffload/root/etc/init.d/flowoffload @@ -134,7 +134,7 @@ stop_pdnsd() { change_dns() { uci delete dhcp.@dnsmasq[0].server >/dev/null 2>&1 uci add_list dhcp.@dnsmasq[0].server=127.0.0.1#5333 - uci delete dhcp.@dnsmasq[0].resolvfile >/dev/null 2>&1 + uci set dhcp.@dnsmasq[0].resolvfile=/tmp/resolv.conf.auto uci set dhcp.@dnsmasq[0].noresolv=0 uci commit dhcp } diff --git a/package/lean/luci-app-sfe/Makefile b/package/lean/luci-app-sfe/Makefile index b6d4c91b7..29c0f80b6 100644 --- a/package/lean/luci-app-sfe/Makefile +++ b/package/lean/luci-app-sfe/Makefile @@ -9,7 +9,7 @@ LUCI_TITLE:=LuCI support for Turbo ACC (SFE) LUCI_DEPENDS:=+kmod-fast-classifier +pdnsd-alt @LINUX_4_9 LUCI_PKGARCH:=all PKG_VERSION:=1.0 -PKG_RELEASE:=12 +PKG_RELEASE:=10 include $(TOPDIR)/feeds/luci/luci.mk diff --git a/package/lean/luci-app-sfe/root/etc/init.d/sfe b/package/lean/luci-app-sfe/root/etc/init.d/sfe index 5c356597c..fb0f9d029 100755 --- a/package/lean/luci-app-sfe/root/etc/init.d/sfe +++ b/package/lean/luci-app-sfe/root/etc/init.d/sfe @@ -134,7 +134,7 @@ stop_pdnsd() { change_dns() { uci delete dhcp.@dnsmasq[0].server >/dev/null 2>&1 uci add_list dhcp.@dnsmasq[0].server=127.0.0.1#5333 - uci delete dhcp.@dnsmasq[0].resolvfile >/dev/null 2>&1 + uci set dhcp.@dnsmasq[0].resolvfile=/tmp/resolv.conf.auto uci set dhcp.@dnsmasq[0].noresolv=0 uci commit dhcp } diff --git a/package/lean/luci-app-sfe/root/etc/uci-defaults/sfe b/package/lean/luci-app-sfe/root/etc/uci-defaults/sfe index 50adb160f..5d2e653cb 100755 --- a/package/lean/luci-app-sfe/root/etc/uci-defaults/sfe +++ b/package/lean/luci-app-sfe/root/etc/uci-defaults/sfe @@ -7,6 +7,9 @@ uci -q batch <<-EOF >/dev/null commit ucitrack EOF +sed -i '/dnscache-watchdog.sh/d' /etc/crontabs/root +echo '*/1 * * * * /usr/share/dnscache-watchdog.sh' >> /etc/crontabs/root + [ ! -f /usr/sbin/dnscache ] && ln /usr/sbin/pdnsd /usr/sbin/dnscache /etc/init.d/sfe enable diff --git a/package/lean/luci-app-sfe/root/usr/share/dnscache-watchdog.sh b/package/lean/luci-app-sfe/root/usr/share/dnscache-watchdog.sh new file mode 100755 index 000000000..4bde67d57 --- /dev/null +++ b/package/lean/luci-app-sfe/root/usr/share/dnscache-watchdog.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +dns_enable=$(uci get sfe.config.dns 2>/dev/null) + +if [ $dns_enable -eq 1 ]; then + if ! pidof dnscache>/dev/null; then + /etc/init.d/sfe restart + fi +fi